diff options
1682 files changed, 24142 insertions, 10125 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 52d7307525..26dd2543e5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -548,6 +548,7 @@ S: Maintained T: git https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze.git F: arch/arm/mach-zynq/ F: doc/board/xilinx/ +F: doc/device-tree-bindings/video/syncoam,seps525.txt F: drivers/clk/clk_zynq.c F: drivers/fpga/zynqpl.c F: drivers/gpio/zynq_gpio.c @@ -589,6 +590,7 @@ F: drivers/spi/zynq_qspi.c F: drivers/spi/zynq_spi.c F: drivers/timer/cadence-ttc.c F: drivers/usb/host/ehci-zynq.c +F: drivers/video/seps525.c F: drivers/watchdog/cdns_wdt.c F: include/zynqmppl.h F: include/zynqmp_firmware.h @@ -3,7 +3,7 @@ VERSION = 2021 PATCHLEVEL = 01 SUBLEVEL = -EXTRAVERSION = -rc5 +EXTRAVERSION = NAME = # *DOCUMENTATION* @@ -1005,7 +1005,7 @@ cmd_cat = cat $(filter-out $(PHONY), $^) > $@ append = cat $(filter-out $< $(PHONY), $^) >> $@ quiet_cmd_pad_cat = CAT $@ -cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@ +cmd_pad_cat = $(cmd_objcopy) && $(append) || { rm -f $@; false; } quiet_cmd_lzma = LZMA $@ cmd_lzma = lzma -c -z -k -9 $< > $@ @@ -1312,7 +1312,7 @@ endif shell_cmd = { $(call echo-cmd,$(1)) $(cmd_$(1)); } quiet_cmd_objcopy_uboot = OBJCOPY $@ -cmd_objcopy_uboot = $(cmd_objcopy) && $(call shell_cmd,static_rela,$<,$@,$(CONFIG_SYS_TEXT_BASE)) || rm -f $@ +cmd_objcopy_uboot = $(cmd_objcopy) && $(call shell_cmd,static_rela,$<,$@,$(CONFIG_SYS_TEXT_BASE)) || { rm -f $@; false; } u-boot-nodtb.bin: u-boot FORCE $(call if_changed,objcopy_uboot) @@ -1584,12 +1584,12 @@ u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE ifneq ($(CONFIG_ARCH_SOCFPGA),) quiet_cmd_gensplx4 = GENSPLX4 $@ cmd_gensplx4 = cat spl/u-boot-spl.sfp spl/u-boot-spl.sfp \ - spl/u-boot-spl.sfp spl/u-boot-spl.sfp > $@ || rm -f $@ + spl/u-boot-spl.sfp spl/u-boot-spl.sfp > $@ || { rm -f $@; false; } spl/u-boot-splx4.sfp: spl/u-boot-spl.sfp FORCE $(call if_changed,gensplx4) quiet_cmd_socboot = SOCBOOT $@ -cmd_socboot = cat spl/u-boot-splx4.sfp u-boot.img > $@ || rm -f $@ +cmd_socboot = cat spl/u-boot-splx4.sfp u-boot.img > $@ || { rm -f $@; false; } u-boot-with-spl.sfp: spl/u-boot-splx4.sfp u-boot.img FORCE $(call if_changed,socboot) @@ -1599,12 +1599,12 @@ cmd_gensplpadx4 = dd if=/dev/zero of=spl/u-boot-spl.pad bs=64 count=1024 ; \ spl/u-boot-spl.sfp spl/u-boot-spl.pad \ spl/u-boot-spl.sfp spl/u-boot-spl.pad \ spl/u-boot-spl.sfp spl/u-boot-spl.pad > $@ || \ - rm -f $@ spl/u-boot-spl.pad + { rm -f $@ spl/u-boot-spl.pad; false; } u-boot-spl-padx4.sfp: spl/u-boot-spl.sfp FORCE $(call if_changed,gensplpadx4) quiet_cmd_socnandboot = SOCNANDBOOT $@ -cmd_socnandboot = cat u-boot-spl-padx4.sfp u-boot.img > $@ || rm -f $@ +cmd_socnandboot = cat u-boot-spl-padx4.sfp u-boot.img > $@ || { rm -f $@; false; } u-boot-with-nand-spl.sfp: u-boot-spl-padx4.sfp u-boot.img FORCE $(call if_changed,socnandboot) @@ -1925,13 +1925,6 @@ The following options need to be configured: try longer timeout such as #define CONFIG_NFS_TIMEOUT 10000UL -- Command Interpreter: - CONFIG_SYS_PROMPT_HUSH_PS2 - - This defines the secondary prompt string, which is - printed when the command interpreter needs more input - to complete a command. Usually "> ". - Note: In the current implementation, the local variables diff --git a/arch/Kconfig b/arch/Kconfig index 3aa99e08fc..27843cd79c 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -7,6 +7,17 @@ config HAVE_ARCH_IOREMAP config NEEDS_MANUAL_RELOC bool +config LINKER_LIST_ALIGN + int + default 32 if SANDBOX + default 8 if ARM64 || X86 + default 4 + help + Force the each linker list to be aligned to this boundary. This + is required if ll_entry_get() is used, since otherwise the linker + may add padding into the table, thus breaking it. + See linker_lists.rst for full details. + choice prompt "Architecture select" default SANDBOX @@ -112,6 +123,7 @@ config SANDBOX imply BITREVERSE select BLOBLIST imply CMD_DM + imply CMD_EXCEPTION imply CMD_GETTIME imply CMD_HASH imply CMD_IO @@ -146,6 +158,8 @@ config SANDBOX imply ACPI_PMC_SANDBOX imply CMD_PMC imply CMD_CLONE + imply SILENT_CONSOLE + imply BOOTARGS_SUBST config SH bool "SuperH architecture" diff --git a/arch/arc/include/asm/spl.h b/arch/arc/include/asm/spl.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/arch/arc/include/asm/spl.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index fbe90875ae..95557d6ed6 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -799,6 +799,7 @@ config ARCH_OMAP2PLUS select SPL_BOARD_INIT if SPL select SPL_STACK_R if SPL select SUPPORT_SPL + imply TI_SYSC if DM && OF_CONTROL imply FIT config ARCH_MESON @@ -1045,6 +1046,7 @@ config ARCH_SUNXI select SPL_USE_TINY_PRINTF select USE_PREBOOT select SYS_RELOC_GD_ENV_ADDR + imply BOARD_LATE_INIT imply CMD_DM imply CMD_GPT imply CMD_UBI if MTD_RAW_NAND diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c index d8cb78ecc6..2556980cde 100644 --- a/arch/arm/cpu/armv7/ls102xa/fdt.c +++ b/arch/arm/cpu/armv7/ls102xa/fdt.c @@ -52,7 +52,11 @@ void ft_fixup_enet_phy_connect_type(void *fdt) continue; } +#ifdef CONFIG_DM_ETH + priv = dev_get_priv(dev); +#else priv = dev->priv; +#endif if (priv->flags & TSEC_SGMII) continue; diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile index 93d26f9856..f7b4a5ee46 100644 --- a/arch/arm/cpu/armv8/Makefile +++ b/arch/arm/cpu/armv8/Makefile @@ -27,6 +27,8 @@ obj-$(CONFIG_ARM_SMCCC) += smccc-call.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_ARMV8_SPIN_TABLE) += spin_table.o spin_table_v8.o +else +obj-$(CONFIG_ARCH_SUNXI) += fel_utils.o endif obj-$(CONFIG_$(SPL_)ARMV8_SEC_FIRMWARE_SUPPORT) += sec_firmware.o sec_firmware_asm.o diff --git a/arch/arm/cpu/armv8/cpu-dt.c b/arch/arm/cpu/armv8/cpu-dt.c index 97d4473a68..61c38b17cb 100644 --- a/arch/arm/cpu/armv8/cpu-dt.c +++ b/arch/arm/cpu/armv8/cpu-dt.c @@ -9,7 +9,7 @@ #include <asm/system.h> #include <asm/armv8/sec_firmware.h> -#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) int psci_update_dt(void *fdt) { /* diff --git a/arch/arm/cpu/armv8/fel_utils.S b/arch/arm/cpu/armv8/fel_utils.S new file mode 100644 index 0000000000..9510dcd9e4 --- /dev/null +++ b/arch/arm/cpu/armv8/fel_utils.S @@ -0,0 +1,78 @@ +/* + * Utility functions for FEL mode, when running SPL in AArch64. + * + * Copyright (c) 2017 Arm Ltd. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <asm-offsets.h> +#include <config.h> +#include <asm/system.h> +#include <linux/linkage.h> + +/* + * We don't overwrite save_boot_params() here, to save the FEL state upon + * entry, since this would run *after* the RMR reset, which clobbers that + * state. + * Instead we store the state _very_ early in the boot0 hook, *before* + * resetting to AArch64. + */ + +/* + * The FEL routines in BROM run in AArch32. + * Reset back into 32-bit mode here and restore the saved FEL state + * afterwards. + * Resetting back into AArch32/EL3 using the RMR always enters the BROM, + * but we can use the CPU hotplug mechanism to branch back to our code + * immediately. + */ +ENTRY(return_to_fel) + /* + * the RMR reset will clear all registers, so save the arguments + * (LR and SP) in the fel_stash structure, which we read anyways later + */ + adr x2, fel_stash + str w0, [x2] + str w1, [x2, #4] + + adr x1, fel_stash_addr // to find the fel_stash address in AA32 + str w2, [x1] + + ldr x0, =0xfa50392f // CPU hotplug magic +#ifdef CONFIG_MACH_SUN50I_H6 + ldr x2, =(SUNXI_RTC_BASE + 0x1b8) // BOOT_CPU_HP_FLAG_REG + str w0, [x2], #0x4 +#else + ldr x2, =(SUNXI_CPUCFG_BASE + 0x1a4) // offset for CPU hotplug base + str w0, [x2, #0x8] +#endif + adr x0, back_in_32 + str w0, [x2] + + dsb sy + isb sy + mov x0, #2 // RMR reset into AArch32 + dsb sy + msr RMR_EL3, x0 + isb sy +1: wfi + b 1b + +/* AArch32 code to restore the state from fel_stash and return back to FEL. */ +back_in_32: + .word 0xe59f0028 // ldr r0, [pc, #40] ; load fel_stash address + .word 0xe5901008 // ldr r1, [r0, #8] + .word 0xe129f001 // msr CPSR_fc, r1 + .word 0xf57ff06f // isb + .word 0xe590d000 // ldr sp, [r0] + .word 0xe590e004 // ldr lr, [r0, #4] + .word 0xe5901010 // ldr r1, [r0, #16] + .word 0xee0c1f10 // mcr 15, 0, r1, cr12, cr0, {0} ; VBAR + .word 0xe590100c // ldr r1, [r0, #12] + .word 0xee011f10 // mcr 15, 0, r1, cr1, cr0, {0} ; SCTLR + .word 0xf57ff06f // isb + .word 0xe12fff1e // bx lr ; return to FEL +fel_stash_addr: + .word 0x00000000 // receives fel_stash addr, by AA64 code above +ENDPROC(return_to_fel) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c index 3a04dce56f..7f29aa4725 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c @@ -26,7 +26,7 @@ #endif #include <fsl_sec.h> #include <asm/arch-fsl-layerscape/soc.h> -#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) #include <asm/armv8/sec_firmware.h> #endif #include <asm/arch/speed.h> @@ -81,7 +81,7 @@ void ft_fixup_cpu(void *blob) "device_type", "cpu", 4); } -#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \ +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) && \ defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) int node; u32 psci_ver; @@ -383,7 +383,7 @@ static void fdt_fixup_msi(void *blob) } #endif -#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) /* Remove JR node used by SEC firmware */ void fdt_fixup_remove_jr(void *blob) { @@ -490,7 +490,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) else { ccsr_sec_t __iomem *sec; -#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) fdt_fixup_remove_jr(blob); fdt_fixup_kaslr(blob); #endif diff --git a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S index a519f6ed67..d8803738f1 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S +++ b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S @@ -192,6 +192,7 @@ ENTRY(lowlevel_init) #endif /* Initialize GIC Secure Bank Status */ +#if !defined(CONFIG_SPL_BUILD) #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3) branch_if_slave x0, 1f bl get_gic_offset @@ -205,6 +206,7 @@ ENTRY(lowlevel_init) bl gic_init_secure_percpu #endif #endif +#endif 100: branch_if_master x0, x1, 2f diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c index 1ddb267093..2285296ea0 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c @@ -16,7 +16,7 @@ #elif defined(CONFIG_FSL_LSCH2) #include <asm/arch/immap_lsch2.h> #endif -#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) #include <asm/armv8/sec_firmware.h> #endif #ifdef CONFIG_CHAIN_OF_TRUST diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c index 77724336d6..215ed9759e 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c @@ -38,6 +38,9 @@ u32 spl_boot_device(void) #ifdef CONFIG_SPL_BUILD +/* Define board data structure */ +static struct bd_info bdata __attribute__ ((section(".data"))); + void spl_board_init(void) { #if defined(CONFIG_NXP_ESBC) && defined(CONFIG_FSL_LSCH2) @@ -74,7 +77,7 @@ void board_init_f(ulong dummy) get_clocks(); preloader_console_init(); - spl_set_bd(); + gd->bd = &bdata; #ifdef CONFIG_SYS_I2C #ifdef CONFIG_SPL_I2C_SUPPORT diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 287ac63da4..a9d36e0e9c 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -595,6 +595,7 @@ dtb-$(CONFIG_MACH_SUN8I_R40) += \ sun8i-r40-bananapi-m2-ultra.dtb \ sun8i-v40-bananapi-m2-berry.dtb dtb-$(CONFIG_MACH_SUN8I_V3S) += \ + sun8i-s3-pinecube.dtb \ sun8i-v3s-licheepi-zero.dtb dtb-$(CONFIG_MACH_SUN50I_H5) += \ sun50i-h5-bananapi-m2-plus.dtb \ @@ -894,6 +895,9 @@ dtb-$(CONFIG_TARGET_OMAP4_SDP4430) += \ dtb-$(CONFIG_TARGET_OMAP5_UEVM) += \ omap5-uevm.dtb +dtb-$(CONFIG_TARGET_SAMA7G5EK) += \ + sama7g5ek.dtb + dtb-$(CONFIG_TARGET_SAMA5D2_PTC_EK) += \ at91-sama5d2_ptc_ek.dtb diff --git a/arch/arm/dts/am335x-brppt1-mmc.dts b/arch/arm/dts/am335x-brppt1-mmc.dts index 6f919711f0..bd2f6c2e3e 100644 --- a/arch/arm/dts/am335x-brppt1-mmc.dts +++ b/arch/arm/dts/am335x-brppt1-mmc.dts @@ -53,8 +53,6 @@ bkl-pwm = <&pwmbacklight>; bkl-tps = <&tps_bl>; - u-boot,dm-pre-reloc; - panel-info { ac-bias = <255>; ac-bias-intrpt = <0>; @@ -238,8 +236,19 @@ status = "okay"; }; -&lcdc { - status = "disabled"; +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + status = "disabled"; + }; + }; + }; }; &elm { diff --git a/arch/arm/dts/am335x-brppt1-nand.dts b/arch/arm/dts/am335x-brppt1-nand.dts index 9d4340f591..67c609739f 100644 --- a/arch/arm/dts/am335x-brppt1-nand.dts +++ b/arch/arm/dts/am335x-brppt1-nand.dts @@ -53,8 +53,6 @@ bkl-pwm = <&pwmbacklight>; bkl-tps = <&tps_bl>; - u-boot,dm-pre-reloc; - panel-info { ac-bias = <255>; ac-bias-intrpt = <0>; @@ -228,8 +226,19 @@ status = "disabled"; }; -&lcdc { - status = "disabled"; +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + status = "disabled"; + }; + }; + }; }; &elm { diff --git a/arch/arm/dts/am335x-brppt1-spi.dts b/arch/arm/dts/am335x-brppt1-spi.dts index c078af8fba..ce3dce204d 100644 --- a/arch/arm/dts/am335x-brppt1-spi.dts +++ b/arch/arm/dts/am335x-brppt1-spi.dts @@ -54,8 +54,6 @@ bkl-pwm = <&pwmbacklight>; bkl-tps = <&tps_bl>; - u-boot,dm-pre-reloc; - panel-info { ac-bias = <255>; ac-bias-intrpt = <0>; @@ -259,8 +257,19 @@ status = "okay"; }; -&lcdc { - status = "disabled"; +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + status = "disabled"; + }; + }; + }; }; &elm { diff --git a/arch/arm/dts/am335x-brsmarc1.dts b/arch/arm/dts/am335x-brsmarc1.dts index 7e9516e8f8..25cdb11164 100644 --- a/arch/arm/dts/am335x-brsmarc1.dts +++ b/arch/arm/dts/am335x-brsmarc1.dts @@ -59,7 +59,6 @@ /*backlight = <&tps_bl>; */ compatible = "ti,tilcdc,panel"; status = "okay"; - u-boot,dm-pre-reloc; panel-info { ac-bias = <255>; @@ -298,10 +297,21 @@ status = "okay"; }; -&lcdc { - status = "okay"; - ti,no-reset-on-init; - ti,no-idle-on-init; +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + status = "okay"; + ti,no-reset-on-init; + ti,no-idle-on-init; + }; + }; + }; }; &elm { diff --git a/arch/arm/dts/am335x-brxre1.dts b/arch/arm/dts/am335x-brxre1.dts index 6091a12fb7..485c8e3613 100644 --- a/arch/arm/dts/am335x-brxre1.dts +++ b/arch/arm/dts/am335x-brxre1.dts @@ -79,8 +79,6 @@ backlight = <&tps_bl>; - u-boot,dm-pre-reloc; - panel-info { ac-bias = <255>; ac-bias-intrpt = <0>; @@ -254,10 +252,21 @@ status = "okay"; }; -&lcdc { - status = "okay"; - ti,no-reset-on-init; - ti,no-idle-on-init; +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + status = "okay"; + ti,no-reset-on-init; + ti,no-idle-on-init; + }; + }; + }; }; &elm { diff --git a/arch/arm/dts/am335x-chiliboard-u-boot.dtsi b/arch/arm/dts/am335x-chiliboard-u-boot.dtsi index 4f9d308039..06a13872ee 100644 --- a/arch/arm/dts/am335x-chiliboard-u-boot.dtsi +++ b/arch/arm/dts/am335x-chiliboard-u-boot.dtsi @@ -4,6 +4,8 @@ * Author: Marcin Niestroj <m.niestroj@grinn-global.com> */ +#include "am33xx-u-boot.dtsi" + / { chosen { stdout-path = &uart0; diff --git a/arch/arm/dts/am335x-draco.dtsi b/arch/arm/dts/am335x-draco.dtsi index b38ff55e1d..2c125fcec9 100644 --- a/arch/arm/dts/am335x-draco.dtsi +++ b/arch/arm/dts/am335x-draco.dtsi @@ -20,11 +20,6 @@ }; ocp { - uart0: serial@44e09000 { - pinctrl-names = "default"; - pinctrl-0 = <&uart0_pins>; - status = "okay"; - }; i2c0: i2c@44e0b000 { pinctrl-names = "default"; @@ -112,6 +107,12 @@ status = "disabled"; }; +&uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins>; + status = "okay"; +}; + &uart4 { status = "disabled"; }; diff --git a/arch/arm/dts/am335x-evm-u-boot.dtsi b/arch/arm/dts/am335x-evm-u-boot.dtsi index d7b049ef20..4cf5f9928d 100644 --- a/arch/arm/dts/am335x-evm-u-boot.dtsi +++ b/arch/arm/dts/am335x-evm-u-boot.dtsi @@ -3,13 +3,22 @@ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ */ -/ { - panel { - u-boot,dm-pre-reloc; +#include "am33xx-u-boot.dtsi" + +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + }; + }; }; }; - &mmc3 { status = "disabled"; }; diff --git a/arch/arm/dts/am335x-evm.dts b/arch/arm/dts/am335x-evm.dts index 0bda4d4429..07288fb188 100644 --- a/arch/arm/dts/am335x-evm.dts +++ b/arch/arm/dts/am335x-evm.dts @@ -486,7 +486,7 @@ &epwmss0 { status = "okay"; - ecap0: ecap@48300100 { + ecap0: ecap@100 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&ecap0_pins>; diff --git a/arch/arm/dts/am335x-evmsk-u-boot.dtsi b/arch/arm/dts/am335x-evmsk-u-boot.dtsi index 599fb377e6..1003f4d31a 100644 --- a/arch/arm/dts/am335x-evmsk-u-boot.dtsi +++ b/arch/arm/dts/am335x-evmsk-u-boot.dtsi @@ -5,8 +5,18 @@ * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> */ -/ { - panel { - u-boot,dm-pre-reloc; +#include "am33xx-u-boot.dtsi" + +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + }; + }; }; }; diff --git a/arch/arm/dts/am335x-evmsk.dts b/arch/arm/dts/am335x-evmsk.dts index 5762967cf7..c94c33b595 100644 --- a/arch/arm/dts/am335x-evmsk.dts +++ b/arch/arm/dts/am335x-evmsk.dts @@ -531,7 +531,7 @@ &epwmss2 { status = "okay"; - ecap2: ecap@48304100 { + ecap2: ecap@100 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&ecap2_pins>; diff --git a/arch/arm/dts/am335x-guardian-u-boot.dtsi b/arch/arm/dts/am335x-guardian-u-boot.dtsi index 705ef335bf..986f58e664 100644 --- a/arch/arm/dts/am335x-guardian-u-boot.dtsi +++ b/arch/arm/dts/am335x-guardian-u-boot.dtsi @@ -4,20 +4,32 @@ * Copyright (C) 2018 Robert Bosch Power Tools GmbH */ +#include "am33xx-u-boot.dtsi" + / { ocp { u-boot,dm-pre-reloc; }; - - panel { - u-boot,dm-pre-reloc; - }; }; &l4_wkup { u-boot,dm-pre-reloc; }; +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + }; + }; + }; +}; + &mmc1 { u-boot,dm-pre-reloc; }; @@ -26,11 +38,6 @@ u-boot,dm-pre-reloc; }; -&rtc { - clocks = <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; - clock-names = "int-clk"; -}; - &scm { u-boot,dm-pre-reloc; }; diff --git a/arch/arm/dts/am335x-icev2-u-boot.dtsi b/arch/arm/dts/am335x-icev2-u-boot.dtsi index cc9569af03..67bfac916e 100644 --- a/arch/arm/dts/am335x-icev2-u-boot.dtsi +++ b/arch/arm/dts/am335x-icev2-u-boot.dtsi @@ -2,6 +2,9 @@ /* * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ */ + +#include "am33xx-u-boot.dtsi" + / { xtal25mhz: xtal25mhz { compatible = "fixed-clock"; diff --git a/arch/arm/dts/am335x-pdu001-u-boot.dtsi b/arch/arm/dts/am335x-pdu001-u-boot.dtsi index a799fe9bc3..686a152fd9 100644 --- a/arch/arm/dts/am335x-pdu001-u-boot.dtsi +++ b/arch/arm/dts/am335x-pdu001-u-boot.dtsi @@ -3,20 +3,32 @@ * Copyright (C) 2018 EETS GmbH - https://www.eets.ch/ */ +#include "am33xx-u-boot.dtsi" + / { ocp { u-boot,dm-pre-reloc; }; - - panel { - u-boot,dm-pre-reloc; - }; }; &l4_wkup { u-boot,dm-pre-reloc; }; +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + }; + }; + }; +}; + &scm { u-boot,dm-pre-reloc; }; diff --git a/arch/arm/dts/am335x-pxm2.dtsi b/arch/arm/dts/am335x-pxm2.dtsi index 19bd7e2420..645d221507 100644 --- a/arch/arm/dts/am335x-pxm2.dtsi +++ b/arch/arm/dts/am335x-pxm2.dtsi @@ -148,7 +148,7 @@ &epwmss0 { status = "okay"; - ecap0: ecap@48300100 { + ecap0: ecap@100 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&ecap0_pins>; diff --git a/arch/arm/dts/am335x-pxm50-u-boot.dtsi b/arch/arm/dts/am335x-pxm50-u-boot.dtsi index 77dfe6e262..e5af9fdf89 100644 --- a/arch/arm/dts/am335x-pxm50-u-boot.dtsi +++ b/arch/arm/dts/am335x-pxm50-u-boot.dtsi @@ -5,8 +5,18 @@ * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> */ -/ { - panel { - u-boot,dm-pre-reloc; +#include "am33xx-u-boot.dtsi" + +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + }; + }; }; }; diff --git a/arch/arm/dts/am335x-regor-rdk-u-boot.dtsi b/arch/arm/dts/am335x-regor-rdk-u-boot.dtsi index 1ddd715875..4052d0ee21 100644 --- a/arch/arm/dts/am335x-regor-rdk-u-boot.dtsi +++ b/arch/arm/dts/am335x-regor-rdk-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (C) 2020 Linumiz */ +#include "am33xx-u-boot.dtsi" + / { chosen { #address-cells = <1>; diff --git a/arch/arm/dts/am335x-rut-u-boot.dtsi b/arch/arm/dts/am335x-rut-u-boot.dtsi index b2b4aa596a..a38c2dc607 100644 --- a/arch/arm/dts/am335x-rut-u-boot.dtsi +++ b/arch/arm/dts/am335x-rut-u-boot.dtsi @@ -5,8 +5,18 @@ * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> */ -/ { - panel { - u-boot,dm-pre-reloc; +#include "am33xx-u-boot.dtsi" + +&l4_per { + + segment@300000 { + + target-module@e000 { + u-boot,dm-pre-reloc; + + lcdc: lcdc@0 { + u-boot,dm-pre-reloc; + }; + }; }; }; diff --git a/arch/arm/dts/am335x-rut.dts b/arch/arm/dts/am335x-rut.dts index 145247344f..cc06f5d23a 100644 --- a/arch/arm/dts/am335x-rut.dts +++ b/arch/arm/dts/am335x-rut.dts @@ -174,7 +174,7 @@ &epwmss0 { status = "okay"; - ecap0: ecap@48300100 { + ecap0: ecap@100 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&ecap0_pins>; diff --git a/arch/arm/dts/am335x-shc-u-boot.dtsi b/arch/arm/dts/am335x-shc-u-boot.dtsi index 2975839ea7..359ae05209 100644 --- a/arch/arm/dts/am335x-shc-u-boot.dtsi +++ b/arch/arm/dts/am335x-shc-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (C) 2019 Heiko Schocher <hs@denx.de> */ +#include "am33xx-u-boot.dtsi" + / { ocp { u-boot,dm-pre-reloc; diff --git a/arch/arm/dts/am335x-shc.dts b/arch/arm/dts/am335x-shc.dts index 8e35c439e5..a41a0606b1 100644 --- a/arch/arm/dts/am335x-shc.dts +++ b/arch/arm/dts/am335x-shc.dts @@ -136,7 +136,7 @@ &epwmss1 { status = "okay"; - ehrpwm1: pwm@48302200 { + ehrpwm1: pwm@200 { pinctrl-names = "default"; pinctrl-0 = <&ehrpwm1_pins>; status = "okay"; diff --git a/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi b/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi index 634f1b0712..28fd62e231 100644 --- a/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi +++ b/arch/arm/dts/am335x-wega-rdk-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (C) 2019 DENX Software Engineering GmbH */ +#include "am33xx-u-boot.dtsi" + / { chosen { #address-cells = <1>; diff --git a/arch/arm/dts/am33xx-clocks.dtsi b/arch/arm/dts/am33xx-clocks.dtsi index 95d5c9d136..87c4410ee2 100644 --- a/arch/arm/dts/am33xx-clocks.dtsi +++ b/arch/arm/dts/am33xx-clocks.dtsi @@ -334,49 +334,49 @@ timer1_fck: timer1_fck@528 { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&sys_clkin_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>, <&tclkin_ck>, <&clk_rc32k_ck>, <&clk_32768_ck>; + clocks = <&sys_clkin_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>, <&tclkin_ck>, <&clk_rc32k_ck>, <&clk_32768_ck>; reg = <0x0528>; }; timer2_fck: timer2_fck@508 { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x0508>; }; timer3_fck: timer3_fck@50c { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x050c>; }; timer4_fck: timer4_fck@510 { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x0510>; }; timer5_fck: timer5_fck@518 { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x0518>; }; timer6_fck: timer6_fck@51c { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x051c>; }; timer7_fck: timer7_fck@504 { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&tclkin_ck>, <&sys_clkin_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x0504>; }; @@ -407,7 +407,7 @@ wdt1_fck: wdt1_fck@538 { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&clk_rc32k_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&clk_rc32k_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x0538>; }; @@ -477,7 +477,7 @@ gpio0_dbclk_mux_ck: gpio0_dbclk_mux_ck@53c { #clock-cells = <0>; compatible = "ti,mux-clock"; - clocks = <&clk_rc32k_ck>, <&clk_32768_ck>, <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; + clocks = <&clk_rc32k_ck>, <&clk_32768_ck>, <&clk_24mhz_clkctrl AM3_CLK_24MHZ_CLKDIV32K_CLKCTRL 0>; reg = <0x053c>; }; @@ -539,77 +539,131 @@ }; &prcm { - l4_per_cm: l4_per_cm@0 { + l4_per_cm: l4_per-cm@0 { compatible = "ti,omap4-cm"; - reg = <0x0 0x200>; + reg = <0x0 0x400>; #address-cells = <1>; #size-cells = <1>; - ranges = <0 0x0 0x200>; + ranges = <0 0x0 0x400>; - l4_per_clkctrl: clk@14 { + l4ls_clkctrl: l4ls-clkctrl@38 { compatible = "ti,clkctrl"; - reg = <0x14 0x13c>; + reg = <0x38 0x2c>, <0x6c 0x28>, <0xac 0xc>, <0xc0 0x1c>, <0xec 0xc>, <0x10c 0x8>, <0x130 0x4>; + #clock-cells = <2>; + }; + + l3s_clkctrl: l3s-clkctrl@1c { + compatible = "ti,clkctrl"; + reg = <0x1c 0x4>, <0x30 0x8>, <0x68 0x4>, <0xf8 0x4>; + #clock-cells = <2>; + }; + + l3_clkctrl: l3-clkctrl@24 { + compatible = "ti,clkctrl"; + reg = <0x24 0xc>, <0x94 0x10>, <0xbc 0x4>, <0xdc 0x8>, <0xfc 0x8>; + #clock-cells = <2>; + }; + + l4hs_clkctrl: l4hs-clkctrl@120 { + compatible = "ti,clkctrl"; + reg = <0x120 0x4>; + #clock-cells = <2>; + }; + + pruss_ocp_clkctrl: pruss-ocp-clkctrl@e8 { + compatible = "ti,clkctrl"; + reg = <0xe8 0x4>; + #clock-cells = <2>; + }; + + cpsw_125mhz_clkctrl: cpsw-125mhz-clkctrl@0 { + compatible = "ti,clkctrl"; + reg = <0x0 0x18>; + #clock-cells = <2>; + }; + + lcdc_clkctrl: lcdc-clkctrl@18 { + compatible = "ti,clkctrl"; + reg = <0x18 0x4>; + #clock-cells = <2>; + }; + + clk_24mhz_clkctrl: clk-24mhz-clkctrl@14c { + compatible = "ti,clkctrl"; + reg = <0x14c 0x4>; #clock-cells = <2>; }; }; - l4_wkup_cm: l4_wkup_cm@400 { + wkup_cm: wkup-cm@400 { compatible = "ti,omap4-cm"; reg = <0x400 0x100>; #address-cells = <1>; #size-cells = <1>; ranges = <0 0x400 0x100>; - l4_wkup_clkctrl: clk@4 { + l4_wkup_clkctrl: l4-wkup-clkctrl@0 { + compatible = "ti,clkctrl"; + reg = <0x4 0x10>, <0xb4 0x24>; + #clock-cells = <2>; + }; + + l3_aon_clkctrl: l3-aon-clkctrl@14 { + compatible = "ti,clkctrl"; + reg = <0x14 0x4>; + #clock-cells = <2>; + }; + + l4_wkup_aon_clkctrl: l4-wkup-aon-clkctrl@b0 { compatible = "ti,clkctrl"; - reg = <0x4 0xd4>; + reg = <0xb0 0x4>; #clock-cells = <2>; }; }; - mpu_cm: mpu_cm@600 { + mpu_cm: mpu-cm@600 { compatible = "ti,omap4-cm"; reg = <0x600 0x100>; #address-cells = <1>; #size-cells = <1>; ranges = <0 0x600 0x100>; - mpu_clkctrl: clk@4 { + mpu_clkctrl: mpu-clkctrl@0 { compatible = "ti,clkctrl"; - reg = <0x4 0x4>; + reg = <0x0 0x8>; #clock-cells = <2>; }; }; - l4_rtc_cm: l4_rtc_cm@800 { + l4_rtc_cm: l4-rtc-cm@800 { compatible = "ti,omap4-cm"; reg = <0x800 0x100>; #address-cells = <1>; #size-cells = <1>; ranges = <0 0x800 0x100>; - l4_rtc_clkctrl: clk@0 { + l4_rtc_clkctrl: l4-rtc-clkctrl@0 { compatible = "ti,clkctrl"; reg = <0x0 0x4>; #clock-cells = <2>; }; }; - gfx_l3_cm: gfx_l3_cm@900 { + gfx_l3_cm: gfx-l3-cm@900 { compatible = "ti,omap4-cm"; reg = <0x900 0x100>; #address-cells = <1>; #size-cells = <1>; ranges = <0 0x900 0x100>; - gfx_l3_clkctrl: clk@4 { + gfx_l3_clkctrl: gfx-l3-clkctrl@0 { compatible = "ti,clkctrl"; - reg = <0x4 0x4>; + reg = <0x0 0x8>; #clock-cells = <2>; }; }; - l4_cefuse_cm: l4_cefuse_cm@a00 { + l4_cefuse_cm: l4-cefuse-cm@a00 { compatible = "ti,omap4-cm"; reg = <0xa00 0x100>; #address-cells = <1>; diff --git a/arch/arm/dts/am33xx-l4.dtsi b/arch/arm/dts/am33xx-l4.dtsi new file mode 100644 index 0000000000..257991e2ad --- /dev/null +++ b/arch/arm/dts/am33xx-l4.dtsi @@ -0,0 +1,1962 @@ +&l4_wkup { /* 0x44c00000 */ + compatible = "ti,am33xx-l4-wkup", "simple-bus"; + reg = <0x44c00000 0x800>, + <0x44c00800 0x800>, + <0x44c01000 0x400>, + <0x44c01400 0x400>; + reg-names = "ap", "la", "ia0", "ia1"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x44c00000 0x100000>, /* segment 0 */ + <0x00100000 0x44d00000 0x100000>, /* segment 1 */ + <0x00200000 0x44e00000 0x100000>; /* segment 2 */ + + segment@0 { /* 0x44c00000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00000000 0x000800>, /* ap 0 */ + <0x00000800 0x00000800 0x000800>, /* ap 1 */ + <0x00001000 0x00001000 0x000400>, /* ap 2 */ + <0x00001400 0x00001400 0x000400>; /* ap 3 */ + }; + + segment@100000 { /* 0x44d00000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00100000 0x004000>, /* ap 4 */ + <0x00004000 0x00104000 0x001000>, /* ap 5 */ + <0x00080000 0x00180000 0x002000>, /* ap 6 */ + <0x00082000 0x00182000 0x001000>; /* ap 7 */ + + target-module@0 { /* 0x44d00000, ap 4 28.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x0 0x4>; + reg-names = "rev"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x0 0x4000>; + status = "disabled"; + }; + + target-module@80000 { /* 0x44d80000, ap 6 10.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x80000 0x2000>; + }; + }; + + segment@200000 { /* 0x44e00000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00200000 0x002000>, /* ap 8 */ + <0x00002000 0x00202000 0x001000>, /* ap 9 */ + <0x00003000 0x00203000 0x001000>, /* ap 10 */ + <0x00004000 0x00204000 0x001000>, /* ap 11 */ + <0x00005000 0x00205000 0x001000>, /* ap 12 */ + <0x00006000 0x00206000 0x001000>, /* ap 13 */ + <0x00007000 0x00207000 0x001000>, /* ap 14 */ + <0x00008000 0x00208000 0x001000>, /* ap 15 */ + <0x00009000 0x00209000 0x001000>, /* ap 16 */ + <0x0000a000 0x0020a000 0x001000>, /* ap 17 */ + <0x0000b000 0x0020b000 0x001000>, /* ap 18 */ + <0x0000c000 0x0020c000 0x001000>, /* ap 19 */ + <0x0000d000 0x0020d000 0x001000>, /* ap 20 */ + <0x0000f000 0x0020f000 0x001000>, /* ap 21 */ + <0x00010000 0x00210000 0x010000>, /* ap 22 */ + <0x00020000 0x00220000 0x010000>, /* ap 23 */ + <0x00030000 0x00230000 0x001000>, /* ap 24 */ + <0x00031000 0x00231000 0x001000>, /* ap 25 */ + <0x00032000 0x00232000 0x001000>, /* ap 26 */ + <0x00033000 0x00233000 0x001000>, /* ap 27 */ + <0x00034000 0x00234000 0x001000>, /* ap 28 */ + <0x00035000 0x00235000 0x001000>, /* ap 29 */ + <0x00036000 0x00236000 0x001000>, /* ap 30 */ + <0x00037000 0x00237000 0x001000>, /* ap 31 */ + <0x00038000 0x00238000 0x001000>, /* ap 32 */ + <0x00039000 0x00239000 0x001000>, /* ap 33 */ + <0x0003a000 0x0023a000 0x001000>, /* ap 34 */ + <0x0003e000 0x0023e000 0x001000>, /* ap 35 */ + <0x0003f000 0x0023f000 0x001000>, /* ap 36 */ + <0x0000e000 0x0020e000 0x001000>, /* ap 37 */ + <0x00040000 0x00240000 0x040000>, /* ap 38 */ + <0x00080000 0x00280000 0x001000>; /* ap 39 */ + + target-module@0 { /* 0x44e00000, ap 8 58.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0 0x4>; + reg-names = "rev"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x0 0x2000>; + + prcm: prcm@0 { + compatible = "ti,am3-prcm", "simple-bus"; + reg = <0 0x2000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0 0x2000>; + + prcm_clocks: clocks { + #address-cells = <1>; + #size-cells = <0>; + }; + + prcm_clockdomains: clockdomains { + }; + }; + }; + + target-module@3000 { /* 0x44e03000, ap 10 0a.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x3000 0x1000>; + }; + + target-module@5000 { /* 0x44e05000, ap 12 30.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x5000 0x1000>; + }; + + gpio0_target: target-module@7000 { /* 0x44e07000, ap 14 20.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x7000 0x4>, + <0x7010 0x4>, + <0x7114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): wkup_pwrdm, l4_wkup_clkdm */ + clocks = <&l4_wkup_clkctrl AM3_L4_WKUP_GPIO1_CLKCTRL 0>, + <&l4_wkup_clkctrl AM3_L4_WKUP_GPIO1_CLKCTRL 18>; + clock-names = "fck", "dbclk"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x7000 0x1000>; + }; + + target-module@9000 { /* 0x44e09000, ap 16 04.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x9050 0x4>, + <0x9054 0x4>, + <0x9058 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): wkup_pwrdm, l4_wkup_clkdm */ + clocks = <&l4_wkup_clkctrl AM3_L4_WKUP_UART1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x9000 0x1000>; + + uart0: serial@0 { + compatible = "ti,am3352-uart", "ti,omap3-uart"; + clock-frequency = <48000000>; + reg = <0x0 0x1000>; + interrupts = <72>; + status = "disabled"; + dmas = <&edma 26 0>, <&edma 27 0>; + dma-names = "tx", "rx"; + }; + }; + + target-module@b000 { /* 0x44e0b000, ap 18 48.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xb000 0x8>, + <0xb010 0x8>, + <0xb090 0x8>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): wkup_pwrdm, l4_wkup_clkdm */ + clocks = <&l4_wkup_clkctrl AM3_L4_WKUP_I2C1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xb000 0x1000>; + }; + + target-module@d000 { /* 0x44e0d000, ap 20 38.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0xd000 0x4>, + <0xd010 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): wkup_pwrdm, l4_wkup_clkdm */ + clocks = <&l4_wkup_clkctrl AM3_L4_WKUP_ADC_TSC_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x0000d000 0x00001000>, + <0x00001000 0x0000e000 0x00001000>; + + tscadc: tscadc@0 { + compatible = "ti,am3359-tscadc"; + reg = <0x0 0x1000>; + interrupts = <16>; + status = "disabled"; + dmas = <&edma 53 0>, <&edma 57 0>; + dma-names = "fifo0", "fifo1"; + + tsc { + compatible = "ti,am3359-tsc"; + }; + am335x_adc: adc { + #io-channel-cells = <1>; + compatible = "ti,am3359-adc"; + }; + }; + + }; + + target-module@10000 { /* 0x44e10000, ap 22 0c.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x10000 0x4>; + reg-names = "rev"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00010000 0x00010000>, + <0x00010000 0x00020000 0x00010000>; + + scm: scm@0 { + compatible = "ti,am3-scm", "simple-bus"; + reg = <0x0 0x2000>; + #address-cells = <1>; + #size-cells = <1>; + #pinctrl-cells = <1>; + ranges = <0 0 0x2000>; + + am33xx_pinmux: pinmux@800 { + compatible = "pinctrl-single"; + reg = <0x800 0x238>; + #pinctrl-cells = <2>; + pinctrl-single,register-width = <32>; + pinctrl-single,function-mask = <0x7f>; + }; + + scm_conf: scm_conf@0 { + compatible = "syscon", "simple-bus"; + reg = <0x0 0x800>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0 0x800>; + + phy_gmii_sel: phy-gmii-sel { + compatible = "ti,am3352-phy-gmii-sel"; + reg = <0x650 0x4>; + #phy-cells = <2>; + }; + + scm_clocks: clocks { + #address-cells = <1>; + #size-cells = <0>; + }; + }; + + wkup_m3_ipc: wkup_m3_ipc@1324 { + compatible = "ti,am3352-wkup-m3-ipc"; + reg = <0x1324 0x24>; + interrupts = <78>; + ti,rproc = <&wkup_m3>; + mboxes = <&mailbox &mbox_wkupm3>; + }; + + edma_xbar: dma-router@f90 { + compatible = "ti,am335x-edma-crossbar"; + reg = <0xf90 0x40>; + #dma-cells = <3>; + dma-requests = <32>; + dma-masters = <&edma>; + }; + + scm_clockdomains: clockdomains { + }; + }; + }; + + timer1_target: target-module@31000 { /* 0x44e31000, ap 25 40.0 */ + compatible = "ti,sysc-omap2-timer", "ti,sysc"; + reg = <0x31000 0x4>, + <0x31010 0x4>, + <0x31014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): wkup_pwrdm, l4_wkup_clkdm */ + clocks = <&l4_wkup_clkctrl AM3_L4_WKUP_TIMER1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x31000 0x1000>; + + timer1: timer@0 { + compatible = "ti,am335x-timer-1ms"; + reg = <0x0 0x400>; + interrupts = <67>; + ti,timer-alwon; + clocks = <&timer1_fck>; + clock-names = "fck"; + }; + }; + + target-module@33000 { /* 0x44e33000, ap 27 18.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x33000 0x1000>; + }; + + target-module@35000 { /* 0x44e35000, ap 29 50.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x35000 0x4>, + <0x35010 0x4>, + <0x35014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_EMUFREE | + SYSC_OMAP2_SOFTRESET)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): wkup_pwrdm, l4_wkup_clkdm */ + clocks = <&l4_wkup_clkctrl AM3_L4_WKUP_WD_TIMER2_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x35000 0x1000>; + }; + + target-module@37000 { /* 0x44e37000, ap 31 08.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x37000 0x1000>; + }; + + target-module@39000 { /* 0x44e39000, ap 33 02.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x39000 0x1000>; + }; + + target-module@3e000 { /* 0x44e3e000, ap 35 60.0 */ + compatible = "ti,sysc-omap4-simple", "ti,sysc"; + reg = <0x3e074 0x4>, + <0x3e078 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): rtc_pwrdm, l4_rtc_clkdm */ + clocks = <&l4_rtc_clkctrl AM3_L4_RTC_RTC_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x3e000 0x1000>; + + rtc: rtc@0 { + compatible = "ti,am3352-rtc", "ti,da830-rtc"; + reg = <0x0 0x1000>; + interrupts = <75 76>; + }; + }; + + target-module@40000 { /* 0x44e40000, ap 38 68.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x40000 0x40000>; + }; + }; +}; + +&l4_fw { /* 0x47c00000 */ + compatible = "ti,am33xx-l4-fw", "simple-bus"; + reg = <0x47c00000 0x800>, + <0x47c00800 0x800>, + <0x47c01000 0x400>; + reg-names = "ap", "la", "ia0"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x47c00000 0x1000000>; /* segment 0 */ + + segment@0 { /* 0x47c00000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00000000 0x000800>, /* ap 0 */ + <0x00000800 0x00000800 0x000800>, /* ap 1 */ + <0x00001000 0x00001000 0x000400>, /* ap 2 */ + <0x0000c000 0x0000c000 0x001000>, /* ap 3 */ + <0x0000d000 0x0000d000 0x001000>, /* ap 4 */ + <0x0000e000 0x0000e000 0x001000>, /* ap 5 */ + <0x0000f000 0x0000f000 0x001000>, /* ap 6 */ + <0x00010000 0x00010000 0x001000>, /* ap 7 */ + <0x00011000 0x00011000 0x001000>, /* ap 8 */ + <0x0001a000 0x0001a000 0x001000>, /* ap 9 */ + <0x0001b000 0x0001b000 0x001000>, /* ap 10 */ + <0x00024000 0x00024000 0x001000>, /* ap 11 */ + <0x00025000 0x00025000 0x001000>, /* ap 12 */ + <0x00026000 0x00026000 0x001000>, /* ap 13 */ + <0x00027000 0x00027000 0x001000>, /* ap 14 */ + <0x00030000 0x00030000 0x001000>, /* ap 15 */ + <0x00031000 0x00031000 0x001000>, /* ap 16 */ + <0x00038000 0x00038000 0x001000>, /* ap 17 */ + <0x00039000 0x00039000 0x001000>, /* ap 18 */ + <0x0003a000 0x0003a000 0x001000>, /* ap 19 */ + <0x0003b000 0x0003b000 0x001000>, /* ap 20 */ + <0x0003e000 0x0003e000 0x001000>, /* ap 21 */ + <0x0003f000 0x0003f000 0x001000>, /* ap 22 */ + <0x0003c000 0x0003c000 0x001000>, /* ap 23 */ + <0x00040000 0x00040000 0x001000>, /* ap 24 */ + <0x00046000 0x00046000 0x001000>, /* ap 25 */ + <0x00047000 0x00047000 0x001000>, /* ap 26 */ + <0x00044000 0x00044000 0x001000>, /* ap 27 */ + <0x00045000 0x00045000 0x001000>, /* ap 28 */ + <0x00028000 0x00028000 0x001000>, /* ap 29 */ + <0x00029000 0x00029000 0x001000>, /* ap 30 */ + <0x00032000 0x00032000 0x001000>, /* ap 31 */ + <0x00033000 0x00033000 0x001000>, /* ap 32 */ + <0x0003d000 0x0003d000 0x001000>, /* ap 33 */ + <0x00041000 0x00041000 0x001000>, /* ap 34 */ + <0x00042000 0x00042000 0x001000>, /* ap 35 */ + <0x00043000 0x00043000 0x001000>, /* ap 36 */ + <0x00014000 0x00014000 0x001000>, /* ap 37 */ + <0x00015000 0x00015000 0x001000>; /* ap 38 */ + + target-module@c000 { /* 0x47c0c000, ap 3 04.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xc000 0x1000>; + }; + + target-module@e000 { /* 0x47c0e000, ap 5 0c.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xe000 0x1000>; + }; + + target-module@10000 { /* 0x47c10000, ap 7 20.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x10000 0x1000>; + }; + + target-module@14000 { /* 0x47c14000, ap 37 3c.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x14000 0x1000>; + }; + + target-module@1a000 { /* 0x47c1a000, ap 9 08.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x1a000 0x1000>; + }; + + target-module@24000 { /* 0x47c24000, ap 11 28.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x24000 0x1000>; + }; + + target-module@26000 { /* 0x47c26000, ap 13 30.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x26000 0x1000>; + }; + + target-module@28000 { /* 0x47c28000, ap 29 40.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x28000 0x1000>; + }; + + target-module@30000 { /* 0x47c30000, ap 15 14.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x30000 0x1000>; + }; + + target-module@32000 { /* 0x47c32000, ap 31 06.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x32000 0x1000>; + }; + + target-module@38000 { /* 0x47c38000, ap 17 18.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x38000 0x1000>; + }; + + target-module@3a000 { /* 0x47c3a000, ap 19 1c.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x3a000 0x1000>; + }; + + target-module@3c000 { /* 0x47c3c000, ap 23 38.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x3c000 0x1000>; + }; + + target-module@3e000 { /* 0x47c3e000, ap 21 10.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x3e000 0x1000>; + }; + + target-module@40000 { /* 0x47c40000, ap 24 02.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x40000 0x1000>; + }; + + target-module@42000 { /* 0x47c42000, ap 35 34.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x42000 0x1000>; + }; + + target-module@44000 { /* 0x47c44000, ap 27 24.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x44000 0x1000>; + }; + + target-module@46000 { /* 0x47c46000, ap 25 2c.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x46000 0x1000>; + }; + }; +}; + +&l4_fast { /* 0x4a000000 */ + compatible = "ti,am33xx-l4-fast", "simple-bus"; + reg = <0x4a000000 0x800>, + <0x4a000800 0x800>, + <0x4a001000 0x400>; + reg-names = "ap", "la", "ia0"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x4a000000 0x1000000>; /* segment 0 */ + + segment@0 { /* 0x4a000000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00000000 0x000800>, /* ap 0 */ + <0x00000800 0x00000800 0x000800>, /* ap 1 */ + <0x00001000 0x00001000 0x000400>, /* ap 2 */ + <0x00100000 0x00100000 0x008000>, /* ap 3 */ + <0x00108000 0x00108000 0x001000>, /* ap 4 */ + <0x00180000 0x00180000 0x020000>, /* ap 5 */ + <0x001a0000 0x001a0000 0x001000>, /* ap 6 */ + <0x00200000 0x00200000 0x080000>, /* ap 7 */ + <0x00280000 0x00280000 0x001000>, /* ap 8 */ + <0x00300000 0x00300000 0x080000>, /* ap 9 */ + <0x00380000 0x00380000 0x001000>; /* ap 10 */ + + target-module@100000 { /* 0x4a100000, ap 3 08.0 */ + compatible = "ti,sysc-omap4-simple", "ti,sysc"; + reg = <0x101200 0x4>, + <0x101208 0x4>, + <0x101204 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <0>; + ti,sysc-midle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>; + ti,syss-mask = <1>; + clocks = <&cpsw_125mhz_clkctrl AM3_CPSW_125MHZ_CPGMAC0_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x100000 0x8000>; + }; + + target-module@180000 { /* 0x4a180000, ap 5 10.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x180000 0x20000>; + }; + + target-module@200000 { /* 0x4a200000, ap 7 02.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x200000 0x80000>; + }; + + pruss_tm: target-module@300000 { /* 0x4a300000, ap 9 04.0 */ + compatible = "ti,sysc-pruss", "ti,sysc"; + reg = <0x326000 0x4>, + <0x326004 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-mask = <(SYSC_PRUSS_STANDBY_INIT | + SYSC_PRUSS_SUB_MWAIT)>; + ti,sysc-midle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + clocks = <&pruss_ocp_clkctrl AM3_PRUSS_OCP_PRUSS_CLKCTRL 0>; + clock-names = "fck"; + resets = <&prm_per 1>; + reset-names = "rstctrl"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x300000 0x80000>; + status = "disabled"; + }; + }; +}; + +&l4_mpuss { /* 0x4b140000 */ + compatible = "ti,am33xx-l4-mpuss", "simple-bus"; + reg = <0x4b144400 0x100>, + <0x4b144800 0x400>; + reg-names = "la", "ap"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x4b140000 0x008000>; /* segment 0 */ + + segment@0 { /* 0x4b140000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00004800 0x00004800 0x000400>, /* ap 0 */ + <0x00001000 0x00001000 0x001000>, /* ap 1 */ + <0x00002000 0x00002000 0x001000>, /* ap 2 */ + <0x00004000 0x00004000 0x000400>, /* ap 3 */ + <0x00005000 0x00005000 0x000400>, /* ap 4 */ + <0x00000000 0x00000000 0x001000>, /* ap 5 */ + <0x00003000 0x00003000 0x001000>, /* ap 6 */ + <0x00000800 0x00000800 0x000800>; /* ap 7 */ + + target-module@0 { /* 0x4b140000, ap 5 02.2 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00000000 0x00001000>, + <0x00001000 0x00001000 0x00001000>, + <0x00002000 0x00002000 0x00001000>; + }; + + target-module@3000 { /* 0x4b143000, ap 6 04.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x3000 0x1000>; + }; + }; +}; + +&l4_per { /* 0x48000000 */ + compatible = "ti,am33xx-l4-per", "simple-bus"; + reg = <0x48000000 0x800>, + <0x48000800 0x800>, + <0x48001000 0x400>, + <0x48001400 0x400>, + <0x48001800 0x400>, + <0x48001c00 0x400>; + reg-names = "ap", "la", "ia0", "ia1", "ia2", "ia3"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x48000000 0x100000>, /* segment 0 */ + <0x00100000 0x48100000 0x100000>, /* segment 1 */ + <0x00200000 0x48200000 0x100000>, /* segment 2 */ + <0x00300000 0x48300000 0x100000>, /* segment 3 */ + <0x46000000 0x46000000 0x400000>, /* l3 data port */ + <0x46400000 0x46400000 0x400000>; /* l3 data port */ + + segment@0 { /* 0x48000000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00000000 0x000800>, /* ap 0 */ + <0x00000800 0x00000800 0x000800>, /* ap 1 */ + <0x00001000 0x00001000 0x000400>, /* ap 2 */ + <0x00001400 0x00001400 0x000400>, /* ap 3 */ + <0x00001800 0x00001800 0x000400>, /* ap 4 */ + <0x00001c00 0x00001c00 0x000400>, /* ap 5 */ + <0x00008000 0x00008000 0x001000>, /* ap 6 */ + <0x00009000 0x00009000 0x001000>, /* ap 7 */ + <0x00016000 0x00016000 0x001000>, /* ap 8 */ + <0x00017000 0x00017000 0x001000>, /* ap 9 */ + <0x00022000 0x00022000 0x001000>, /* ap 10 */ + <0x00023000 0x00023000 0x001000>, /* ap 11 */ + <0x00024000 0x00024000 0x001000>, /* ap 12 */ + <0x00025000 0x00025000 0x001000>, /* ap 13 */ + <0x0002a000 0x0002a000 0x001000>, /* ap 14 */ + <0x0002b000 0x0002b000 0x001000>, /* ap 15 */ + <0x00038000 0x00038000 0x002000>, /* ap 16 */ + <0x0003a000 0x0003a000 0x001000>, /* ap 17 */ + <0x00014000 0x00014000 0x001000>, /* ap 18 */ + <0x00015000 0x00015000 0x001000>, /* ap 19 */ + <0x0003c000 0x0003c000 0x002000>, /* ap 20 */ + <0x0003e000 0x0003e000 0x001000>, /* ap 21 */ + <0x00040000 0x00040000 0x001000>, /* ap 22 */ + <0x00041000 0x00041000 0x001000>, /* ap 23 */ + <0x00042000 0x00042000 0x001000>, /* ap 24 */ + <0x00043000 0x00043000 0x001000>, /* ap 25 */ + <0x00044000 0x00044000 0x001000>, /* ap 26 */ + <0x00045000 0x00045000 0x001000>, /* ap 27 */ + <0x00046000 0x00046000 0x001000>, /* ap 28 */ + <0x00047000 0x00047000 0x001000>, /* ap 29 */ + <0x00048000 0x00048000 0x001000>, /* ap 30 */ + <0x00049000 0x00049000 0x001000>, /* ap 31 */ + <0x0004c000 0x0004c000 0x001000>, /* ap 32 */ + <0x0004d000 0x0004d000 0x001000>, /* ap 33 */ + <0x00050000 0x00050000 0x002000>, /* ap 34 */ + <0x00052000 0x00052000 0x001000>, /* ap 35 */ + <0x00060000 0x00060000 0x001000>, /* ap 36 */ + <0x00061000 0x00061000 0x001000>, /* ap 37 */ + <0x00080000 0x00080000 0x010000>, /* ap 38 */ + <0x00090000 0x00090000 0x001000>, /* ap 39 */ + <0x000a0000 0x000a0000 0x010000>, /* ap 40 */ + <0x000b0000 0x000b0000 0x001000>, /* ap 41 */ + <0x00030000 0x00030000 0x001000>, /* ap 77 */ + <0x00031000 0x00031000 0x001000>, /* ap 78 */ + <0x0004a000 0x0004a000 0x001000>, /* ap 85 */ + <0x0004b000 0x0004b000 0x001000>, /* ap 86 */ + <0x000c8000 0x000c8000 0x001000>, /* ap 87 */ + <0x000c9000 0x000c9000 0x001000>, /* ap 88 */ + <0x000cc000 0x000cc000 0x001000>, /* ap 89 */ + <0x000cd000 0x000cd000 0x001000>, /* ap 90 */ + <0x000ca000 0x000ca000 0x001000>, /* ap 91 */ + <0x000cb000 0x000cb000 0x001000>, /* ap 92 */ + <0x46000000 0x46000000 0x400000>, /* l3 data port */ + <0x46400000 0x46400000 0x400000>; /* l3 data port */ + + target-module@8000 { /* 0x48008000, ap 6 10.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x8000 0x1000>; + }; + + target-module@14000 { /* 0x48014000, ap 18 58.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x14000 0x1000>; + }; + + target-module@16000 { /* 0x48016000, ap 8 3c.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x16000 0x1000>; + }; + + target-module@22000 { /* 0x48022000, ap 10 12.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x22050 0x4>, + <0x22054 0x4>, + <0x22058 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_UART2_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x22000 0x1000>; + + uart1: serial@0 { + compatible = "ti,am3352-uart", "ti,omap3-uart"; + clock-frequency = <48000000>; + reg = <0x0 0x1000>; + interrupts = <73>; + status = "disabled"; + dmas = <&edma 28 0>, <&edma 29 0>; + dma-names = "tx", "rx"; + }; + }; + + target-module@24000 { /* 0x48024000, ap 12 14.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x24050 0x4>, + <0x24054 0x4>, + <0x24058 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_UART3_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x24000 0x1000>; + + uart2: serial@0 { + compatible = "ti,am3352-uart", "ti,omap3-uart"; + clock-frequency = <48000000>; + reg = <0x0 0x1000>; + interrupts = <74>; + status = "disabled"; + dmas = <&edma 30 0>, <&edma 31 0>; + dma-names = "tx", "rx"; + }; + }; + + target-module@2a000 { /* 0x4802a000, ap 14 2a.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x2a000 0x8>, + <0x2a010 0x8>, + <0x2a090 0x8>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_I2C2_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x2a000 0x1000>; + }; + + target-module@30000 { /* 0x48030000, ap 77 08.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x30000 0x4>, + <0x30110 0x4>, + <0x30114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_SPI0_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x30000 0x1000>; + + spi0: spi@0 { + compatible = "ti,omap4-mcspi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x0 0x400>; + interrupts = <65>; + ti,spi-num-cs = <2>; + dmas = <&edma 16 0 + &edma 17 0 + &edma 18 0 + &edma 19 0>; + dma-names = "tx0", "rx0", "tx1", "rx1"; + status = "disabled"; + }; + }; + + target-module@38000 { /* 0x48038000, ap 16 02.0 */ + compatible = "ti,sysc-omap4-simple", "ti,sysc"; + reg = <0x38000 0x4>, + <0x38004 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + /* Domains (P, C): per_pwrdm, l3s_clkdm */ + clocks = <&l3s_clkctrl AM3_L3S_MCASP0_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x38000 0x2000>, + <0x46000000 0x46000000 0x400000>; + + mcasp0: mcasp@0 { + compatible = "ti,am33xx-mcasp-audio"; + reg = <0x0 0x2000>, + <0x46000000 0x400000>; + reg-names = "mpu", "dat"; + interrupts = <80>, <81>; + interrupt-names = "tx", "rx"; + status = "disabled"; + dmas = <&edma 8 2>, + <&edma 9 2>; + dma-names = "tx", "rx"; + }; + }; + + target-module@3c000 { /* 0x4803c000, ap 20 32.0 */ + compatible = "ti,sysc-omap4-simple", "ti,sysc"; + reg = <0x3c000 0x4>, + <0x3c004 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + /* Domains (P, C): per_pwrdm, l3s_clkdm */ + clocks = <&l3s_clkctrl AM3_L3S_MCASP1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x3c000 0x2000>, + <0x46400000 0x46400000 0x400000>; + + mcasp1: mcasp@0 { + compatible = "ti,am33xx-mcasp-audio"; + reg = <0x0 0x2000>, + <0x46400000 0x400000>; + reg-names = "mpu", "dat"; + interrupts = <82>, <83>; + interrupt-names = "tx", "rx"; + status = "disabled"; + dmas = <&edma 10 2>, + <&edma 11 2>; + dma-names = "tx", "rx"; + }; + }; + + timer2_target: target-module@40000 { /* 0x48040000, ap 22 1e.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + reg = <0x40000 0x4>, + <0x40010 0x4>, + <0x40014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_TIMER2_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x40000 0x1000>; + + timer2: timer@0 { + compatible = "ti,am335x-timer"; + reg = <0x0 0x400>; + interrupts = <68>; + clocks = <&timer2_fck>; + clock-names = "fck"; + }; + }; + + target-module@42000 { /* 0x48042000, ap 24 1c.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + reg = <0x42000 0x4>, + <0x42010 0x4>, + <0x42014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_TIMER3_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x42000 0x1000>; + + timer3: timer@0 { + compatible = "ti,am335x-timer"; + reg = <0x0 0x400>; + interrupts = <69>; + }; + }; + + target-module@44000 { /* 0x48044000, ap 26 26.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + reg = <0x44000 0x4>, + <0x44010 0x4>, + <0x44014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_TIMER4_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x44000 0x1000>; + + timer4: timer@0 { + compatible = "ti,am335x-timer"; + reg = <0x0 0x400>; + interrupts = <92>; + ti,timer-pwm; + }; + }; + + target-module@46000 { /* 0x48046000, ap 28 28.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + reg = <0x46000 0x4>, + <0x46010 0x4>, + <0x46014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_TIMER5_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x46000 0x1000>; + + timer5: timer@0 { + compatible = "ti,am335x-timer"; + reg = <0x0 0x400>; + interrupts = <93>; + ti,timer-pwm; + }; + }; + + target-module@48000 { /* 0x48048000, ap 30 22.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + reg = <0x48000 0x4>, + <0x48010 0x4>, + <0x48014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_TIMER6_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x48000 0x1000>; + + timer6: timer@0 { + compatible = "ti,am335x-timer"; + reg = <0x0 0x400>; + interrupts = <94>; + ti,timer-pwm; + }; + }; + + target-module@4a000 { /* 0x4804a000, ap 85 60.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + reg = <0x4a000 0x4>, + <0x4a010 0x4>, + <0x4a014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_TIMER7_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x4a000 0x1000>; + + timer7: timer@0 { + compatible = "ti,am335x-timer"; + reg = <0x0 0x400>; + interrupts = <95>; + ti,timer-pwm; + }; + }; + + target-module@4c000 { /* 0x4804c000, ap 32 36.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x4c000 0x4>, + <0x4c010 0x4>, + <0x4c114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_GPIO2_CLKCTRL 0>, + <&l4ls_clkctrl AM3_L4LS_GPIO2_CLKCTRL 18>; + clock-names = "fck", "dbclk"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x4c000 0x1000>; + }; + + target-module@50000 { /* 0x48050000, ap 34 2c.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x50000 0x2000>; + }; + + target-module@60000 { /* 0x48060000, ap 36 0c.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x602fc 0x4>, + <0x60110 0x4>, + <0x60114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_MMC1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x60000 0x1000>; + }; + + target-module@80000 { /* 0x48080000, ap 38 18.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x80000 0x4>, + <0x80010 0x4>, + <0x80014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_ELM_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x80000 0x10000>; + + elm: elm@0 { + compatible = "ti,am3352-elm"; + reg = <0x0 0x2000>; + interrupts = <4>; + status = "disabled"; + }; + }; + + target-module@a0000 { /* 0x480a0000, ap 40 5e.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xa0000 0x10000>; + }; + + target-module@c8000 { /* 0x480c8000, ap 87 06.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0xc8000 0x4>, + <0xc8010 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_MAILBOX_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xc8000 0x1000>; + + mailbox: mailbox@0 { + compatible = "ti,omap4-mailbox"; + reg = <0x0 0x200>; + interrupts = <77>; + #mbox-cells = <1>; + ti,mbox-num-users = <4>; + ti,mbox-num-fifos = <8>; + mbox_wkupm3: wkup_m3 { + ti,mbox-send-noirq; + ti,mbox-tx = <0 0 0>; + ti,mbox-rx = <0 0 3>; + }; + }; + }; + + target-module@ca000 { /* 0x480ca000, ap 91 40.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xca000 0x4>, + <0xca010 0x4>, + <0xca014 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_SPINLOCK_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xca000 0x1000>; + + hwspinlock: spinlock@0 { + compatible = "ti,omap4-hwspinlock"; + reg = <0x0 0x1000>; + #hwlock-cells = <1>; + }; + }; + + target-module@cc000 { /* 0x480cc000, ap 89 0e.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xcc000 0x1000>; + }; + }; + + segment@100000 { /* 0x48100000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0008c000 0x0018c000 0x001000>, /* ap 42 */ + <0x0008d000 0x0018d000 0x001000>, /* ap 43 */ + <0x0008e000 0x0018e000 0x001000>, /* ap 44 */ + <0x0008f000 0x0018f000 0x001000>, /* ap 45 */ + <0x0009c000 0x0019c000 0x001000>, /* ap 46 */ + <0x0009d000 0x0019d000 0x001000>, /* ap 47 */ + <0x000a6000 0x001a6000 0x001000>, /* ap 48 */ + <0x000a7000 0x001a7000 0x001000>, /* ap 49 */ + <0x000a8000 0x001a8000 0x001000>, /* ap 50 */ + <0x000a9000 0x001a9000 0x001000>, /* ap 51 */ + <0x000aa000 0x001aa000 0x001000>, /* ap 52 */ + <0x000ab000 0x001ab000 0x001000>, /* ap 53 */ + <0x000ac000 0x001ac000 0x001000>, /* ap 54 */ + <0x000ad000 0x001ad000 0x001000>, /* ap 55 */ + <0x000ae000 0x001ae000 0x001000>, /* ap 56 */ + <0x000af000 0x001af000 0x001000>, /* ap 57 */ + <0x000b0000 0x001b0000 0x010000>, /* ap 58 */ + <0x000c0000 0x001c0000 0x001000>, /* ap 59 */ + <0x000cc000 0x001cc000 0x002000>, /* ap 60 */ + <0x000ce000 0x001ce000 0x002000>, /* ap 61 */ + <0x000d0000 0x001d0000 0x002000>, /* ap 62 */ + <0x000d2000 0x001d2000 0x002000>, /* ap 63 */ + <0x000d8000 0x001d8000 0x001000>, /* ap 64 */ + <0x000d9000 0x001d9000 0x001000>, /* ap 65 */ + <0x000a0000 0x001a0000 0x001000>, /* ap 79 */ + <0x000a1000 0x001a1000 0x001000>, /* ap 80 */ + <0x000a2000 0x001a2000 0x001000>, /* ap 81 */ + <0x000a3000 0x001a3000 0x001000>, /* ap 82 */ + <0x000a4000 0x001a4000 0x001000>, /* ap 83 */ + <0x000a5000 0x001a5000 0x001000>; /* ap 84 */ + + target-module@8c000 { /* 0x4818c000, ap 42 04.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x8c000 0x1000>; + }; + + target-module@8e000 { /* 0x4818e000, ap 44 0a.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x8e000 0x1000>; + }; + + target-module@9c000 { /* 0x4819c000, ap 46 5a.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x9c000 0x8>, + <0x9c010 0x8>, + <0x9c090 0x8>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_I2C3_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x9c000 0x1000>; + }; + + target-module@a0000 { /* 0x481a0000, ap 79 24.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xa0000 0x4>, + <0xa0110 0x4>, + <0xa0114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_SPI1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xa0000 0x1000>; + + spi1: spi@0 { + compatible = "ti,omap4-mcspi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x0 0x400>; + interrupts = <125>; + ti,spi-num-cs = <2>; + dmas = <&edma 42 0 + &edma 43 0 + &edma 44 0 + &edma 45 0>; + dma-names = "tx0", "rx0", "tx1", "rx1"; + status = "disabled"; + }; + }; + + target-module@a2000 { /* 0x481a2000, ap 81 2e.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xa2000 0x1000>; + }; + + target-module@a4000 { /* 0x481a4000, ap 83 30.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xa4000 0x1000>; + }; + + target-module@a6000 { /* 0x481a6000, ap 48 16.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xa6050 0x4>, + <0xa6054 0x4>, + <0xa6058 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_UART4_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xa6000 0x1000>; + + uart3: serial@0 { + compatible = "ti,am3352-uart", "ti,omap3-uart"; + clock-frequency = <48000000>; + reg = <0x0 0x1000>; + interrupts = <44>; + status = "disabled"; + }; + }; + + target-module@a8000 { /* 0x481a8000, ap 50 20.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xa8050 0x4>, + <0xa8054 0x4>, + <0xa8058 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_UART5_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xa8000 0x1000>; + + uart4: serial@0 { + compatible = "ti,am3352-uart", "ti,omap3-uart"; + clock-frequency = <48000000>; + reg = <0x0 0x1000>; + interrupts = <45>; + status = "disabled"; + }; + }; + + target-module@aa000 { /* 0x481aa000, ap 52 1a.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xaa050 0x4>, + <0xaa054 0x4>, + <0xaa058 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_UART6_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xaa000 0x1000>; + + uart5: serial@0 { + compatible = "ti,am3352-uart", "ti,omap3-uart"; + clock-frequency = <48000000>; + reg = <0x0 0x1000>; + interrupts = <46>; + status = "disabled"; + }; + }; + + target-module@ac000 { /* 0x481ac000, ap 54 38.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xac000 0x4>, + <0xac010 0x4>, + <0xac114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_GPIO3_CLKCTRL 0>, + <&l4ls_clkctrl AM3_L4LS_GPIO3_CLKCTRL 18>; + clock-names = "fck", "dbclk"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xac000 0x1000>; + }; + + target-module@ae000 { /* 0x481ae000, ap 56 3a.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xae000 0x4>, + <0xae010 0x4>, + <0xae114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_GPIO4_CLKCTRL 0>, + <&l4ls_clkctrl AM3_L4LS_GPIO4_CLKCTRL 18>; + clock-names = "fck", "dbclk"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xae000 0x1000>; + }; + + target-module@b0000 { /* 0x481b0000, ap 58 50.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xb0000 0x10000>; + }; + + target-module@cc000 { /* 0x481cc000, ap 60 46.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0xcc020 0x4>; + reg-names = "rev"; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_D_CAN0_CLKCTRL 0>, + <&dcan0_fck>; + clock-names = "fck", "osc"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xcc000 0x2000>; + + dcan0: can@0 { + compatible = "ti,am3352-d_can"; + reg = <0x0 0x2000>; + clocks = <&dcan0_fck>; + clock-names = "fck"; + syscon-raminit = <&scm_conf 0x644 0>; + interrupts = <52>; + status = "disabled"; + }; + }; + + target-module@d0000 { /* 0x481d0000, ap 62 42.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0xd0020 0x4>; + reg-names = "rev"; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_D_CAN1_CLKCTRL 0>, + <&dcan1_fck>; + clock-names = "fck", "osc"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xd0000 0x2000>; + + dcan1: can@0 { + compatible = "ti,am3352-d_can"; + reg = <0x0 0x2000>; + clocks = <&dcan1_fck>; + clock-names = "fck"; + syscon-raminit = <&scm_conf 0x644 1>; + interrupts = <55>; + status = "disabled"; + }; + }; + + target-module@d8000 { /* 0x481d8000, ap 64 66.0 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0xd82fc 0x4>, + <0xd8110 0x4>, + <0xd8114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_CLOCKACTIVITY | + SYSC_OMAP2_ENAWAKEUP | + SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_MMC2_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xd8000 0x1000>; + }; + }; + + segment@200000 { /* 0x48200000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + }; + + segment@300000 { /* 0x48300000 */ + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00300000 0x001000>, /* ap 66 */ + <0x00001000 0x00301000 0x001000>, /* ap 67 */ + <0x00002000 0x00302000 0x001000>, /* ap 68 */ + <0x00003000 0x00303000 0x001000>, /* ap 69 */ + <0x00004000 0x00304000 0x001000>, /* ap 70 */ + <0x00005000 0x00305000 0x001000>, /* ap 71 */ + <0x0000e000 0x0030e000 0x001000>, /* ap 72 */ + <0x0000f000 0x0030f000 0x001000>, /* ap 73 */ + <0x00018000 0x00318000 0x004000>, /* ap 74 */ + <0x0001c000 0x0031c000 0x001000>, /* ap 75 */ + <0x00010000 0x00310000 0x002000>, /* ap 76 */ + <0x00012000 0x00312000 0x001000>, /* ap 93 */ + <0x00015000 0x00315000 0x001000>, /* ap 94 */ + <0x00016000 0x00316000 0x001000>, /* ap 95 */ + <0x00017000 0x00317000 0x001000>, /* ap 96 */ + <0x00013000 0x00313000 0x001000>, /* ap 97 */ + <0x00014000 0x00314000 0x001000>, /* ap 98 */ + <0x00020000 0x00320000 0x001000>, /* ap 99 */ + <0x00021000 0x00321000 0x001000>, /* ap 100 */ + <0x00022000 0x00322000 0x001000>, /* ap 101 */ + <0x00023000 0x00323000 0x001000>, /* ap 102 */ + <0x00024000 0x00324000 0x001000>, /* ap 103 */ + <0x00025000 0x00325000 0x001000>; /* ap 104 */ + + target-module@0 { /* 0x48300000, ap 66 48.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x0 0x4>, + <0x4 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-midle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_EPWMSS0_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x0 0x1000>; + + epwmss0: epwmss@0 { + compatible = "ti,am33xx-pwmss"; + reg = <0x0 0x10>; + #address-cells = <1>; + #size-cells = <1>; + status = "disabled"; + ranges = <0 0 0x1000>; + + ecap0: ecap@100 { + compatible = "ti,am3352-ecap", + "ti,am33xx-ecap"; + #pwm-cells = <3>; + reg = <0x100 0x80>; + clocks = <&l4ls_gclk>; + clock-names = "fck"; + interrupts = <31>; + interrupt-names = "ecap0"; + status = "disabled"; + }; + + ehrpwm0: pwm@200 { + compatible = "ti,am3352-ehrpwm", + "ti,am33xx-ehrpwm"; + #pwm-cells = <3>; + reg = <0x200 0x80>; + clocks = <&ehrpwm0_tbclk>, <&l4ls_gclk>; + clock-names = "tbclk", "fck"; + status = "disabled"; + }; + }; + }; + + target-module@2000 { /* 0x48302000, ap 68 52.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x2000 0x4>, + <0x2004 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-midle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_EPWMSS1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x2000 0x1000>; + + epwmss1: epwmss@0 { + compatible = "ti,am33xx-pwmss"; + reg = <0x0 0x10>; + #address-cells = <1>; + #size-cells = <1>; + status = "disabled"; + ranges = <0 0 0x1000>; + + ecap1: ecap@100 { + compatible = "ti,am3352-ecap", + "ti,am33xx-ecap"; + #pwm-cells = <3>; + reg = <0x100 0x80>; + clocks = <&l4ls_gclk>; + clock-names = "fck"; + interrupts = <47>; + interrupt-names = "ecap1"; + status = "disabled"; + }; + + ehrpwm1: pwm@200 { + compatible = "ti,am3352-ehrpwm", + "ti,am33xx-ehrpwm"; + #pwm-cells = <3>; + reg = <0x200 0x80>; + clocks = <&ehrpwm1_tbclk>, <&l4ls_gclk>; + clock-names = "tbclk", "fck"; + status = "disabled"; + }; + }; + }; + + target-module@4000 { /* 0x48304000, ap 70 44.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x4000 0x4>, + <0x4004 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-midle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_EPWMSS2_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x4000 0x1000>; + + epwmss2: epwmss@0 { + compatible = "ti,am33xx-pwmss"; + reg = <0x0 0x10>; + #address-cells = <1>; + #size-cells = <1>; + status = "disabled"; + ranges = <0 0 0x1000>; + + ecap2: ecap@100 { + compatible = "ti,am3352-ecap", + "ti,am33xx-ecap"; + #pwm-cells = <3>; + reg = <0x100 0x80>; + clocks = <&l4ls_gclk>; + clock-names = "fck"; + interrupts = <61>; + interrupt-names = "ecap2"; + status = "disabled"; + }; + + ehrpwm2: pwm@200 { + compatible = "ti,am3352-ehrpwm", + "ti,am33xx-ehrpwm"; + #pwm-cells = <3>; + reg = <0x200 0x80>; + clocks = <&ehrpwm2_tbclk>, <&l4ls_gclk>; + clock-names = "tbclk", "fck"; + status = "disabled"; + }; + }; + }; + + target-module@e000 { /* 0x4830e000, ap 72 4a.0 */ + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0xe000 0x4>, + <0xe054 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-midle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + /* Domains (P, C): per_pwrdm, lcdc_clkdm */ + clocks = <&lcdc_clkctrl AM3_LCDC_LCDC_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xe000 0x1000>; + + lcdc: lcdc@0 { + compatible = "ti,am33xx-tilcdc"; + reg = <0x0 0x1000>; + interrupts = <36>; + status = "disabled"; + }; + }; + + target-module@10000 { /* 0x48310000, ap 76 4e.1 */ + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x11fe0 0x4>, + <0x11fe4 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-mask = <SYSC_OMAP2_AUTOIDLE>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>; + /* Domains (P, C): per_pwrdm, l4ls_clkdm */ + clocks = <&l4ls_clkctrl AM3_L4LS_RNG_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x10000 0x2000>; + + rng: rng@0 { + compatible = "ti,omap4-rng"; + reg = <0x0 0x2000>; + interrupts = <111>; + }; + }; + + target-module@13000 { /* 0x48313000, ap 97 62.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x13000 0x1000>; + }; + + target-module@15000 { /* 0x48315000, ap 94 56.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x00000000 0x00015000 0x00001000>, + <0x00001000 0x00016000 0x00001000>; + }; + + target-module@18000 { /* 0x48318000, ap 74 4c.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x18000 0x4000>; + }; + + target-module@20000 { /* 0x48320000, ap 99 34.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x20000 0x1000>; + }; + + target-module@22000 { /* 0x48322000, ap 101 3e.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x22000 0x1000>; + }; + + target-module@24000 { /* 0x48324000, ap 103 68.0 */ + compatible = "ti,sysc"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x24000 0x1000>; + }; + }; +}; diff --git a/arch/arm/dts/am33xx-u-boot.dtsi b/arch/arm/dts/am33xx-u-boot.dtsi index 78f5e2c4d3..61d10b841b 100644 --- a/arch/arm/dts/am33xx-u-boot.dtsi +++ b/arch/arm/dts/am33xx-u-boot.dtsi @@ -9,3 +9,11 @@ u-boot,dm-pre-reloc; }; }; + +&prcm_clocks { + compatible = "simple-bus"; +}; + +&scm_clocks { + compatible = "simple-bus"; +}; diff --git a/arch/arm/dts/am33xx.dtsi b/arch/arm/dts/am33xx.dtsi index d3dd6a16e7..3e5ed00aae 100644 --- a/arch/arm/dts/am33xx.dtsi +++ b/arch/arm/dts/am33xx.dtsi @@ -8,6 +8,7 @@ * kind, whether express or implied. */ +#include <dt-bindings/bus/ti-sysc.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/pinctrl/am33xx.h> #include <dt-bindings/clock/am3.h> @@ -46,6 +47,7 @@ #size-cells = <0>; cpu@0 { compatible = "arm,cortex-a8"; + enable-method = "ti,am3352"; device_type = "cpu"; reg = <0>; @@ -55,6 +57,17 @@ clock-names = "cpu"; clock-latency = <300000>; /* From omap-cpufreq driver */ + cpu-idle-states = <&mpu_gate>; + }; + + idle-states { + mpu_gate: mpu_gate { + compatible = "arm,idle-state"; + entry-latency-us = <40>; + exit-latency-us = <90>; + min-residency-us = <300>; + ti,idle-wkup-m3; + }; }; }; @@ -167,11 +180,6 @@ ti,hwmods = "l3_main"; l4_wkup: l4_wkup@44c00000 { - compatible = "ti,am3-l4-wkup", "simple-bus"; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0 0x44c00000 0x280000>; - wkup_m3: wkup_m3@100000 { compatible = "ti,am3352-wkup-m3"; reg = <0x100000 0x4000>, @@ -180,73 +188,14 @@ ti,hwmods = "wkup_m3"; ti,pm-firmware = "am335x-pm-firmware.elf"; }; - - prcm: prcm@200000 { - compatible = "ti,am3-prcm", "simple-bus"; - reg = <0x200000 0x4000>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0 0x200000 0x4000>; - - prcm_clocks: clocks { - #address-cells = <1>; - #size-cells = <0>; - }; - - prcm_clockdomains: clockdomains { - }; - }; - - scm: scm@210000 { - compatible = "ti,am3-scm", "simple-bus"; - reg = <0x210000 0x2000>; - #address-cells = <1>; - #size-cells = <1>; - #pinctrl-cells = <1>; - ranges = <0 0x210000 0x2000>; - - am33xx_pinmux: pinmux@800 { - compatible = "pinctrl-single"; - reg = <0x800 0x238>; - #address-cells = <1>; - #size-cells = <0>; - #pinctrl-cells = <1>; - pinctrl-single,register-width = <32>; - pinctrl-single,function-mask = <0x7f>; - }; - - scm_conf: scm_conf@0 { - compatible = "syscon", "simple-bus"; - reg = <0x0 0x800>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0 0 0x800>; - - scm_clocks: clocks { - #address-cells = <1>; - #size-cells = <0>; - }; - }; - - wkup_m3_ipc: wkup_m3_ipc@1324 { - compatible = "ti,am3352-wkup-m3-ipc"; - reg = <0x1324 0x24>; - interrupts = <78>; - ti,rproc = <&wkup_m3>; - mboxes = <&mailbox &mbox_wkupm3>; - }; - - edma_xbar: dma-router@f90 { - compatible = "ti,am335x-edma-crossbar"; - reg = <0xf90 0x40>; - #dma-cells = <3>; - dma-requests = <32>; - dma-masters = <&edma>; - }; - - scm_clockdomains: clockdomains { - }; - }; + }; + l4_per: interconnect@48000000 { + }; + l4_fw: interconnect@47c00000 { + }; + l4_fast: interconnect@4a000000 { + }; + l4_mpuss: interconnect@4b140000 { }; intc: interrupt-controller@48200000 { @@ -256,45 +205,100 @@ reg = <0x48200000 0x1000>; }; - edma: edma@49000000 { - compatible = "ti,edma3-tpcc"; - ti,hwmods = "tpcc"; - reg = <0x49000000 0x10000>; - reg-names = "edma3_cc"; - interrupts = <12 13 14>; - interrupt-names = "edma3_ccint", "edma3_mperr", - "edma3_ccerrint"; - dma-requests = <64>; - #dma-cells = <2>; - - ti,tptcs = <&edma_tptc0 7>, <&edma_tptc1 5>, - <&edma_tptc2 0>; - - ti,edma-memcpy-channels = <20 21>; + target-module@49000000 { + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x49000000 0x4>; + reg-names = "rev"; + clocks = <&l3_clkctrl AM3_L3_TPCC_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x49000000 0x10000>; + + edma: dma@0 { + compatible = "ti,edma3-tpcc"; + reg = <0 0x10000>; + reg-names = "edma3_cc"; + interrupts = <12 13 14>; + interrupt-names = "edma3_ccint", "edma3_mperr", + "edma3_ccerrint"; + dma-requests = <64>; + #dma-cells = <2>; + + ti,tptcs = <&edma_tptc0 7>, <&edma_tptc1 5>, + <&edma_tptc2 0>; + + ti,edma-memcpy-channels = <20 21>; + }; }; - edma_tptc0: tptc@49800000 { - compatible = "ti,edma3-tptc"; - ti,hwmods = "tptc0"; - reg = <0x49800000 0x100000>; - interrupts = <112>; - interrupt-names = "edma3_tcerrint"; + target-module@49800000 { + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x49800000 0x4>, + <0x49800010 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-midle = <SYSC_IDLE_FORCE>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_SMART>; + clocks = <&l3_clkctrl AM3_L3_TPTC0_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x49800000 0x100000>; + + edma_tptc0: dma@0 { + compatible = "ti,edma3-tptc"; + reg = <0 0x100000>; + interrupts = <112>; + interrupt-names = "edma3_tcerrint"; + }; }; - edma_tptc1: tptc@49900000 { - compatible = "ti,edma3-tptc"; - ti,hwmods = "tptc1"; - reg = <0x49900000 0x100000>; - interrupts = <113>; - interrupt-names = "edma3_tcerrint"; + target-module@49900000 { + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x49900000 0x4>, + <0x49900010 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-midle = <SYSC_IDLE_FORCE>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_SMART>; + clocks = <&l3_clkctrl AM3_L3_TPTC1_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x49900000 0x100000>; + + edma_tptc1: dma@0 { + compatible = "ti,edma3-tptc"; + reg = <0 0x100000>; + interrupts = <113>; + interrupt-names = "edma3_tcerrint"; + }; }; - edma_tptc2: tptc@49a00000 { - compatible = "ti,edma3-tptc"; - ti,hwmods = "tptc2"; - reg = <0x49a00000 0x100000>; - interrupts = <114>; - interrupt-names = "edma3_tcerrint"; + target-module@49a00000 { + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x49a00000 0x4>, + <0x49a00010 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-mask = <SYSC_OMAP4_SOFTRESET>; + ti,sysc-midle = <SYSC_IDLE_FORCE>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_SMART>; + clocks = <&l3_clkctrl AM3_L3_TPTC2_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x49a00000 0x100000>; + + edma_tptc2: dma@0 { + compatible = "ti,edma3-tptc"; + reg = <0 0x100000>; + interrupts = <114>; + interrupt-names = "edma3_tcerrint"; + }; }; gpio0: gpio@44e07000 { @@ -341,66 +345,6 @@ interrupts = <62>; }; - uart0: serial@44e09000 { - compatible = "ti,am3352-uart", "ti,omap3-uart"; - ti,hwmods = "uart1"; - clock-frequency = <48000000>; - reg = <0x44e09000 0x2000>; - interrupts = <72>; - status = "disabled"; - dmas = <&edma 26 0>, <&edma 27 0>; - dma-names = "tx", "rx"; - }; - - uart1: serial@48022000 { - compatible = "ti,am3352-uart", "ti,omap3-uart"; - ti,hwmods = "uart2"; - clock-frequency = <48000000>; - reg = <0x48022000 0x2000>; - interrupts = <73>; - status = "disabled"; - dmas = <&edma 28 0>, <&edma 29 0>; - dma-names = "tx", "rx"; - }; - - uart2: serial@48024000 { - compatible = "ti,am3352-uart", "ti,omap3-uart"; - ti,hwmods = "uart3"; - clock-frequency = <48000000>; - reg = <0x48024000 0x2000>; - interrupts = <74>; - status = "disabled"; - dmas = <&edma 30 0>, <&edma 31 0>; - dma-names = "tx", "rx"; - }; - - uart3: serial@481a6000 { - compatible = "ti,am3352-uart", "ti,omap3-uart"; - ti,hwmods = "uart4"; - clock-frequency = <48000000>; - reg = <0x481a6000 0x2000>; - interrupts = <44>; - status = "disabled"; - }; - - uart4: serial@481a8000 { - compatible = "ti,am3352-uart", "ti,omap3-uart"; - ti,hwmods = "uart5"; - clock-frequency = <48000000>; - reg = <0x481a8000 0x2000>; - interrupts = <45>; - status = "disabled"; - }; - - uart5: serial@481aa000 { - compatible = "ti,am3352-uart", "ti,omap3-uart"; - ti,hwmods = "uart6"; - clock-frequency = <48000000>; - reg = <0x481aa000 0x2000>; - interrupts = <46>; - status = "disabled"; - }; - i2c0: i2c@44e0b000 { compatible = "ti,omap4-i2c"; #address-cells = <1>; @@ -466,13 +410,6 @@ status = "disabled"; }; - hwspinlock: spinlock@480ca000 { - compatible = "ti,omap4-hwspinlock"; - reg = <0x480ca000 0x1000>; - ti,hwmods = "spinlock"; - #hwlock-cells = <1>; - }; - wdt2: wdt@44e35000 { compatible = "ti,omap3-wdt"; ti,hwmods = "wd_timer2"; @@ -480,143 +417,6 @@ interrupts = <91>; }; - dcan0: can@481cc000 { - compatible = "ti,am3352-d_can"; - ti,hwmods = "d_can0"; - reg = <0x481cc000 0x2000>; - clocks = <&dcan0_fck>; - clock-names = "fck"; - syscon-raminit = <&scm_conf 0x644 0>; - interrupts = <52>; - status = "disabled"; - }; - - dcan1: can@481d0000 { - compatible = "ti,am3352-d_can"; - ti,hwmods = "d_can1"; - reg = <0x481d0000 0x2000>; - clocks = <&dcan1_fck>; - clock-names = "fck"; - syscon-raminit = <&scm_conf 0x644 1>; - interrupts = <55>; - status = "disabled"; - }; - - mailbox: mailbox@480c8000 { - compatible = "ti,omap4-mailbox"; - reg = <0x480C8000 0x200>; - interrupts = <77>; - ti,hwmods = "mailbox"; - #mbox-cells = <1>; - ti,mbox-num-users = <4>; - ti,mbox-num-fifos = <8>; - mbox_wkupm3: wkup_m3 { - ti,mbox-send-noirq; - ti,mbox-tx = <0 0 0>; - ti,mbox-rx = <0 0 3>; - }; - }; - - timer1: timer@44e31000 { - compatible = "ti,am335x-timer-1ms"; - reg = <0x44e31000 0x400>; - interrupts = <67>; - ti,hwmods = "timer1"; - ti,timer-alwon; - clocks = <&timer1_fck>; - clock-names = "fck"; - }; - - timer2: timer@48040000 { - compatible = "ti,am335x-timer"; - reg = <0x48040000 0x400>; - interrupts = <68>; - ti,hwmods = "timer2"; - clocks = <&timer2_fck>; - clock-names = "fck"; - }; - - timer3: timer@48042000 { - compatible = "ti,am335x-timer"; - reg = <0x48042000 0x400>; - interrupts = <69>; - ti,hwmods = "timer3"; - }; - - timer4: timer@48044000 { - compatible = "ti,am335x-timer"; - reg = <0x48044000 0x400>; - interrupts = <92>; - ti,hwmods = "timer4"; - ti,timer-pwm; - }; - - timer5: timer@48046000 { - compatible = "ti,am335x-timer"; - reg = <0x48046000 0x400>; - interrupts = <93>; - ti,hwmods = "timer5"; - ti,timer-pwm; - }; - - timer6: timer@48048000 { - compatible = "ti,am335x-timer"; - reg = <0x48048000 0x400>; - interrupts = <94>; - ti,hwmods = "timer6"; - ti,timer-pwm; - }; - - timer7: timer@4804a000 { - compatible = "ti,am335x-timer"; - reg = <0x4804a000 0x400>; - interrupts = <95>; - ti,hwmods = "timer7"; - ti,timer-pwm; - }; - - rtc: rtc@44e3e000 { - compatible = "ti,am3352-rtc", "ti,da830-rtc"; - reg = <0x44e3e000 0x1000>; - interrupts = <75 - 76>; - ti,hwmods = "rtc"; - clocks = <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>; - clock-names = "int-clk"; - }; - - spi0: spi@48030000 { - compatible = "ti,omap4-mcspi"; - #address-cells = <1>; - #size-cells = <0>; - reg = <0x48030000 0x400>; - interrupts = <65>; - ti,spi-num-cs = <2>; - ti,hwmods = "spi0"; - dmas = <&edma 16 0 - &edma 17 0 - &edma 18 0 - &edma 19 0>; - dma-names = "tx0", "rx0", "tx1", "rx1"; - status = "disabled"; - }; - - spi1: spi@481a0000 { - compatible = "ti,omap4-mcspi"; - #address-cells = <1>; - #size-cells = <0>; - reg = <0x481a0000 0x400>; - interrupts = <125>; - ti,spi-num-cs = <2>; - ti,hwmods = "spi1"; - dmas = <&edma 42 0 - &edma 43 0 - &edma 44 0 - &edma 45 0>; - dma-names = "tx0", "rx0", "tx1", "rx1"; - status = "disabled"; - }; - usb: usb@47400000 { compatible = "ti,am33xx-usb"; reg = <0x47400000 0x1000>; @@ -731,121 +531,18 @@ "tx14", "tx15"; }; - cppi41dma: dma-controller@47402000 { + cppi41dma: dma-controller@2000 { compatible = "ti,am3359-cppi41"; - reg = <0x47400000 0x1000 - 0x47402000 0x1000 - 0x47403000 0x1000 - 0x47404000 0x4000>; + reg = <0x0000 0x1000>, + <0x2000 0x1000>, + <0x3000 0x1000>, + <0x4000 0x4000>; reg-names = "glue", "controller", "scheduler", "queuemgr"; interrupts = <17>; interrupt-names = "glue"; #dma-cells = <2>; #dma-channels = <30>; #dma-requests = <256>; - status = "disabled"; - }; - }; - - epwmss0: epwmss@48300000 { - compatible = "ti,am33xx-pwmss"; - reg = <0x48300000 0x10>; - ti,hwmods = "epwmss0"; - #address-cells = <1>; - #size-cells = <1>; - status = "disabled"; - ranges = <0x48300100 0x48300100 0x80 /* ECAP */ - 0x48300180 0x48300180 0x80 /* EQEP */ - 0x48300200 0x48300200 0x80>; /* EHRPWM */ - - ecap0: ecap@48300100 { - compatible = "ti,am3352-ecap", - "ti,am33xx-ecap"; - #pwm-cells = <3>; - reg = <0x48300100 0x80>; - clocks = <&l4ls_gclk>; - clock-names = "fck"; - interrupts = <31>; - interrupt-names = "ecap0"; - status = "disabled"; - }; - - ehrpwm0: pwm@48300200 { - compatible = "ti,am3352-ehrpwm", - "ti,am33xx-ehrpwm"; - #pwm-cells = <3>; - reg = <0x48300200 0x80>; - clocks = <&ehrpwm0_tbclk>, <&l4ls_gclk>; - clock-names = "tbclk", "fck"; - status = "disabled"; - }; - }; - - epwmss1: epwmss@48302000 { - compatible = "ti,am33xx-pwmss"; - reg = <0x48302000 0x10>; - ti,hwmods = "epwmss1"; - #address-cells = <1>; - #size-cells = <1>; - status = "disabled"; - ranges = <0x48302100 0x48302100 0x80 /* ECAP */ - 0x48302180 0x48302180 0x80 /* EQEP */ - 0x48302200 0x48302200 0x80>; /* EHRPWM */ - - ecap1: ecap@48302100 { - compatible = "ti,am3352-ecap", - "ti,am33xx-ecap"; - #pwm-cells = <3>; - reg = <0x48302100 0x80>; - clocks = <&l4ls_gclk>; - clock-names = "fck"; - interrupts = <47>; - interrupt-names = "ecap1"; - status = "disabled"; - }; - - ehrpwm1: pwm@48302200 { - compatible = "ti,am3352-ehrpwm", - "ti,am33xx-ehrpwm"; - #pwm-cells = <3>; - reg = <0x48302200 0x80>; - clocks = <&ehrpwm1_tbclk>, <&l4ls_gclk>; - clock-names = "tbclk", "fck"; - status = "disabled"; - }; - }; - - epwmss2: epwmss@48304000 { - compatible = "ti,am33xx-pwmss"; - reg = <0x48304000 0x10>; - ti,hwmods = "epwmss2"; - #address-cells = <1>; - #size-cells = <1>; - status = "disabled"; - ranges = <0x48304100 0x48304100 0x80 /* ECAP */ - 0x48304180 0x48304180 0x80 /* EQEP */ - 0x48304200 0x48304200 0x80>; /* EHRPWM */ - - ecap2: ecap@48304100 { - compatible = "ti,am3352-ecap", - "ti,am33xx-ecap"; - #pwm-cells = <3>; - reg = <0x48304100 0x80>; - clocks = <&l4ls_gclk>; - clock-names = "fck"; - interrupts = <61>; - interrupt-names = "ecap2"; - status = "disabled"; - }; - - ehrpwm2: pwm@48304200 { - compatible = "ti,am3352-ehrpwm", - "ti,am33xx-ehrpwm"; - #pwm-cells = <3>; - reg = <0x48304200 0x80>; - clocks = <&ehrpwm2_tbclk>, <&l4ls_gclk>; - clock-names = "tbclk", "fck"; - status = "disabled"; }; }; @@ -904,60 +601,26 @@ }; }; - ocmcram: ocmcram@40300000 { + ocmcram: sram@40300000 { compatible = "mmio-sram"; reg = <0x40300000 0x10000>; /* 64k */ ranges = <0x0 0x40300000 0x10000>; #address-cells = <1>; #size-cells = <1>; - pm_sram_code: pm-sram-code@0 { + pm_sram_code: pm-code-sram@0 { compatible = "ti,sram"; reg = <0x0 0x1000>; protect-exec; }; - pm_sram_data: pm-sram-data@1000 { + pm_sram_data: pm-data-sram@1000 { compatible = "ti,sram"; reg = <0x1000 0x1000>; pool; }; }; - elm: elm@48080000 { - compatible = "ti,am3352-elm"; - reg = <0x48080000 0x2000>; - interrupts = <4>; - ti,hwmods = "elm"; - status = "disabled"; - }; - - lcdc: lcdc@4830e000 { - compatible = "ti,am33xx-tilcdc"; - reg = <0x4830e000 0x1000>; - interrupts = <36>; - ti,hwmods = "lcdc"; - status = "disabled"; - }; - - tscadc: tscadc@44e0d000 { - compatible = "ti,am3359-tscadc"; - reg = <0x44e0d000 0x1000>; - interrupts = <16>; - ti,hwmods = "adc_tsc"; - status = "disabled"; - dmas = <&edma 53 0>, <&edma 57 0>; - dma-names = "fifo0", "fifo1"; - - tsc { - compatible = "ti,am3359-tsc"; - }; - am335x_adc: adc { - #io-channel-cells = <1>; - compatible = "ti,am3359-adc"; - }; - }; - emif: emif@4c000000 { compatible = "ti,emif-am3352"; reg = <0x4c000000 0x1000000>; @@ -987,60 +650,116 @@ status = "disabled"; }; - sham: sham@53100000 { - compatible = "ti,omap4-sham"; - ti,hwmods = "sham"; - reg = <0x53100000 0x200>; - interrupts = <109>; - dmas = <&edma 36 0>; - dma-names = "rx"; - }; - - aes: aes@53500000 { - compatible = "ti,omap4-aes"; - ti,hwmods = "aes"; - reg = <0x53500000 0xa0>; - interrupts = <103>; - dmas = <&edma 6 0>, - <&edma 5 0>; - dma-names = "tx", "rx"; + sham_target: target-module@53100000 { + compatible = "ti,sysc-omap3-sham", "ti,sysc"; + reg = <0x53100100 0x4>, + <0x53100110 0x4>, + <0x53100114 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l3_clkdm */ + clocks = <&l3_clkctrl AM3_L3_SHAM_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x53100000 0x1000>; + + sham: sham@0 { + compatible = "ti,omap4-sham"; + reg = <0 0x200>; + interrupts = <109>; + dmas = <&edma 36 0>; + dma-names = "rx"; + }; }; - mcasp0: mcasp@48038000 { - compatible = "ti,am33xx-mcasp-audio"; - ti,hwmods = "mcasp0"; - reg = <0x48038000 0x2000>, - <0x46000000 0x400000>; - reg-names = "mpu", "dat"; - interrupts = <80>, <81>; - interrupt-names = "tx", "rx"; - status = "disabled"; - dmas = <&edma 8 2>, - <&edma 9 2>; - dma-names = "tx", "rx"; + aes_target: target-module@53500000 { + compatible = "ti,sysc-omap2", "ti,sysc"; + reg = <0x53500080 0x4>, + <0x53500084 0x4>, + <0x53500088 0x4>; + reg-names = "rev", "sysc", "syss"; + ti,sysc-mask = <(SYSC_OMAP2_SOFTRESET | + SYSC_OMAP2_AUTOIDLE)>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>, + <SYSC_IDLE_SMART_WKUP>; + ti,syss-mask = <1>; + /* Domains (P, C): per_pwrdm, l3_clkdm */ + clocks = <&l3_clkctrl AM3_L3_AES_CLKCTRL 0>; + clock-names = "fck"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x53500000 0x1000>; + + aes: aes@0 { + compatible = "ti,omap4-aes"; + reg = <0 0xa0>; + interrupts = <103>; + dmas = <&edma 6 0>, + <&edma 5 0>; + dma-names = "tx", "rx"; + }; }; - mcasp1: mcasp@4803c000 { - compatible = "ti,am33xx-mcasp-audio"; - ti,hwmods = "mcasp1"; - reg = <0x4803C000 0x2000>, - <0x46400000 0x400000>; - reg-names = "mpu", "dat"; - interrupts = <82>, <83>; - interrupt-names = "tx", "rx"; - status = "disabled"; - dmas = <&edma 10 2>, - <&edma 11 2>; - dma-names = "tx", "rx"; - }; + target-module@56000000 { + compatible = "ti,sysc-omap4", "ti,sysc"; + reg = <0x5600fe00 0x4>, + <0x5600fe10 0x4>; + reg-names = "rev", "sysc"; + ti,sysc-midle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + ti,sysc-sidle = <SYSC_IDLE_FORCE>, + <SYSC_IDLE_NO>, + <SYSC_IDLE_SMART>; + clocks = <&gfx_l3_clkctrl AM3_GFX_L3_GFX_CLKCTRL 0>; + clock-names = "fck"; + resets = <&prm_gfx 0>; + reset-names = "rstctrl"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x56000000 0x1000000>; - rng: rng@48310000 { - compatible = "ti,omap4-rng"; - ti,hwmods = "rng"; - reg = <0x48310000 0x2000>; - interrupts = <111>; + /* + * Closed source PowerVR driver, no child device + * binding or driver in mainline + */ }; }; }; +#include "am33xx-l4.dtsi" #include "am33xx-clocks.dtsi" + +&prcm { + prm_per: prm@c00 { + compatible = "ti,am3-prm-inst", "ti,omap-prm-inst"; + reg = <0xc00 0x100>; + #reset-cells = <1>; + }; + + prm_wkup: prm@d00 { + compatible = "ti,am3-prm-inst", "ti,omap-prm-inst"; + reg = <0xd00 0x100>; + #reset-cells = <1>; + }; + + prm_device: prm@f00 { + compatible = "ti,am3-prm-inst", "ti,omap-prm-inst"; + reg = <0xf00 0x100>; + #reset-cells = <1>; + }; + + prm_gfx: prm@1100 { + compatible = "ti,am3-prm-inst", "ti,omap-prm-inst"; + reg = <0x1100 0x100>; + #reset-cells = <1>; + }; +}; diff --git a/arch/arm/dts/dm8168-evm-u-boot.dtsi b/arch/arm/dts/dm8168-evm-u-boot.dtsi new file mode 100644 index 0000000000..de0bb9bc81 --- /dev/null +++ b/arch/arm/dts/dm8168-evm-u-boot.dtsi @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * dm8168-evm U-Boot Additions + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +/ { + ocp { + u-boot,dm-pre-reloc; + }; +}; diff --git a/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi b/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi index e63684c334..9b4e0298a7 100644 --- a/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi +++ b/arch/arm/dts/fsl-ls1028a-kontron-sl28-u-boot.dtsi @@ -16,7 +16,7 @@ ethernet3 = &enetc6; }; - binman { + binman: binman { filename = "u-boot.rom"; pad-byte = <0xff>; @@ -80,21 +80,18 @@ conf-1 { description = "fsl-ls1028a-kontron-sl28"; firmware = "uboot"; - loadables = "uboot"; fdt = "fdt-1"; }; conf-2 { description = "fsl-ls1028a-kontron-sl28-var3"; firmware = "uboot"; - loadables = "uboot"; fdt = "fdt-2"; }; conf-3 { description = "fsl-ls1028a-kontron-sl28-var4"; firmware = "uboot"; - loadables = "uboot"; fdt = "fdt-3"; }; }; @@ -102,6 +99,81 @@ }; }; +#ifdef CONFIG_SL28_SPL_LOADS_ATF_BL31 +&binman { + fit { + images { + bl31 { + description = "ARM Trusted Firmware (bl31)"; + type = "firmware"; + arch = "arm"; + os = "arm-trusted-firmware"; + compression = "none"; + load = <CONFIG_SL28_BL31_ENTRY_ADDR>; + entry = <CONFIG_SL28_BL31_ENTRY_ADDR>; + + blob-ext { + filename = "bl31.bin"; + }; + }; + }; + + configurations { + conf-1 { + firmware = "bl31"; + loadables = "uboot"; + }; + + conf-2 { + firmware = "bl31"; + loadables = "uboot"; + }; + + conf-3 { + firmware = "bl31"; + loadables = "uboot"; + }; + }; + }; +}; +#endif + +#ifdef CONFIG_SL28_SPL_LOADS_OPTEE_BL32 +&binman { + fit { + images { + bl32 { + description = "OP-TEE Trusted OS (bl32)"; + type = "firmware"; + arch = "arm"; + os = "tee"; + compression = "none"; + load = <CONFIG_SL28_BL32_ENTRY_ADDR>; + entry = <CONFIG_SL28_BL32_ENTRY_ADDR>; + + blob-ext { + filename = "tee.bin"; + }; + }; + }; + + configurations { + conf-1 { + loadables = "uboot", "bl32"; + }; + + conf-2 { + loadables = "uboot", "bl32"; + }; + + conf-3 { + loadables = "uboot", "bl32"; + }; + }; + }; +}; +#endif + &i2c0 { rtc: rtc@32 { }; diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi index d75d1b1c28..727bc3e8a0 100644 --- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi +++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi @@ -14,6 +14,8 @@ aliases { serial2 = &main_uart0; ethernet0 = &cpsw_port1; + usb0 = &usb0; + usb1 = &usb1; }; }; @@ -270,7 +272,7 @@ &usb0 { pinctrl-names = "default"; pinctrl-0 = <&usb0_pins_default>; - dr_mode = "peripheral"; + dr_mode = "host"; u-boot,dm-spl; }; diff --git a/arch/arm/dts/k3-am654-r5-base-board.dts b/arch/arm/dts/k3-am654-r5-base-board.dts index d43a4edc71..f12510259d 100644 --- a/arch/arm/dts/k3-am654-r5-base-board.dts +++ b/arch/arm/dts/k3-am654-r5-base-board.dts @@ -36,6 +36,7 @@ power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>, <&k3_pds 202 TI_SCI_PD_EXCLUSIVE>; resets = <&k3_reset 202 0>; + clocks = <&k3_clks 61 0>; assigned-clocks = <&k3_clks 202 0>; assigned-clock-rates = <800000000>; ti,sci = <&dmsc>; diff --git a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts index db63d93777..2ac887b180 100644 --- a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts @@ -32,6 +32,7 @@ power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>, <&k3_pds 202 TI_SCI_PD_EXCLUSIVE>; resets = <&k3_reset 202 0>; + clocks = <&k3_clks 61 1>; assigned-clocks = <&k3_clks 202 2>, <&k3_clks 61 1>; assigned-clock-rates = <2000000000>, <200000000>; ti,sci = <&dmsc>; diff --git a/arch/arm/dts/k3-j721e-ddr-evm-lp4-3733.dtsi b/arch/arm/dts/k3-j721e-ddr-evm-lp4-4266.dtsi index 5ac32a0ffa..ca05e06e93 100644 --- a/arch/arm/dts/k3-j721e-ddr-evm-lp4-3733.dtsi +++ b/arch/arm/dts/k3-j721e-ddr-evm-lp4-4266.dtsi @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ - * This file was generated by the AM752x_DRA82x_TDA4x_DDRSS_RegConfigTool, Revision: 0.2.0 - * This file was generated on 10/09/2019 + * This file was generated by the Jacinto7_DDRSS_RegConfigTool, Revision: 0.5.0 + * This file was generated on 09/25/2020 */ #define DDRSS_PLL_FHS_CNT 10 -#define DDRSS_PLL_FREQUENCY_1 933000000 -#define DDRSS_PLL_FREQUENCY_2 933000000 +#define DDRSS_PLL_FREQUENCY_1 1066500000 +#define DDRSS_PLL_FREQUENCY_2 1066500000 #define DDRSS_CTL_00_DATA 0x00000B00 #define DDRSS_CTL_01_DATA 0x00000000 @@ -20,14 +20,14 @@ #define DDRSS_CTL_08_DATA 0x000186A0 #define DDRSS_CTL_09_DATA 0x00000005 #define DDRSS_CTL_10_DATA 0x00000064 -#define DDRSS_CTL_11_DATA 0x0005B18F -#define DDRSS_CTL_12_DATA 0x0038EF90 +#define DDRSS_CTL_11_DATA 0x000681C8 +#define DDRSS_CTL_12_DATA 0x004111C9 #define DDRSS_CTL_13_DATA 0x00000005 -#define DDRSS_CTL_14_DATA 0x00000E94 -#define DDRSS_CTL_15_DATA 0x0005B18F -#define DDRSS_CTL_16_DATA 0x0038EF90 +#define DDRSS_CTL_14_DATA 0x000010A9 +#define DDRSS_CTL_15_DATA 0x000681C8 +#define DDRSS_CTL_16_DATA 0x004111C9 #define DDRSS_CTL_17_DATA 0x00000005 -#define DDRSS_CTL_18_DATA 0x00000E94 +#define DDRSS_CTL_18_DATA 0x000010A9 #define DDRSS_CTL_19_DATA 0x01010000 #define DDRSS_CTL_20_DATA 0x02011001 #define DDRSS_CTL_21_DATA 0x02010000 @@ -37,66 +37,66 @@ #define DDRSS_CTL_25_DATA 0x00000000 #define DDRSS_CTL_26_DATA 0x00000000 #define DDRSS_CTL_27_DATA 0x02020200 -#define DDRSS_CTL_28_DATA 0x00004B4B +#define DDRSS_CTL_28_DATA 0x00005656 #define DDRSS_CTL_29_DATA 0x00100000 #define DDRSS_CTL_30_DATA 0x00000000 #define DDRSS_CTL_31_DATA 0x00000000 #define DDRSS_CTL_32_DATA 0x00000000 #define DDRSS_CTL_33_DATA 0x00000000 #define DDRSS_CTL_34_DATA 0x040C0000 -#define DDRSS_CTL_35_DATA 0x10401040 +#define DDRSS_CTL_35_DATA 0x12481248 #define DDRSS_CTL_36_DATA 0x00050804 #define DDRSS_CTL_37_DATA 0x09040008 -#define DDRSS_CTL_38_DATA 0x12000204 -#define DDRSS_CTL_39_DATA 0x1854007A -#define DDRSS_CTL_40_DATA 0x12003A26 -#define DDRSS_CTL_41_DATA 0x1854007A -#define DDRSS_CTL_42_DATA 0x20003A26 +#define DDRSS_CTL_38_DATA 0x15000204 +#define DDRSS_CTL_39_DATA 0x1B60008B +#define DDRSS_CTL_40_DATA 0x1500422B +#define DDRSS_CTL_41_DATA 0x1B60008B +#define DDRSS_CTL_42_DATA 0x2000422B #define DDRSS_CTL_43_DATA 0x000A0A09 #define DDRSS_CTL_44_DATA 0x040006DB -#define DDRSS_CTL_45_DATA 0x1B130F04 -#define DDRSS_CTL_46_DATA 0x0E00FFCD -#define DDRSS_CTL_47_DATA 0x1B130F0E -#define DDRSS_CTL_48_DATA 0x0E00FFCD -#define DDRSS_CTL_49_DATA 0x0203040E -#define DDRSS_CTL_50_DATA 0x26040500 -#define DDRSS_CTL_51_DATA 0x08282628 +#define DDRSS_CTL_45_DATA 0x1E161104 +#define DDRSS_CTL_46_DATA 0x10012458 +#define DDRSS_CTL_47_DATA 0x1E161110 +#define DDRSS_CTL_48_DATA 0x10012458 +#define DDRSS_CTL_49_DATA 0x02030410 +#define DDRSS_CTL_50_DATA 0x2C040500 +#define DDRSS_CTL_51_DATA 0x082D2C2D #define DDRSS_CTL_52_DATA 0x14000D0A -#define DDRSS_CTL_53_DATA 0x03010A0A -#define DDRSS_CTL_54_DATA 0x01010003 -#define DDRSS_CTL_55_DATA 0x044E4E08 -#define DDRSS_CTL_56_DATA 0x042B2B04 -#define DDRSS_CTL_57_DATA 0x00002B2B +#define DDRSS_CTL_53_DATA 0x04010A0A +#define DDRSS_CTL_54_DATA 0x01010004 +#define DDRSS_CTL_55_DATA 0x04585808 +#define DDRSS_CTL_56_DATA 0x04313104 +#define DDRSS_CTL_57_DATA 0x00003131 #define DDRSS_CTL_58_DATA 0x00010100 #define DDRSS_CTL_59_DATA 0x03010000 #define DDRSS_CTL_60_DATA 0x00000E08 #define DDRSS_CTL_61_DATA 0x000000BB -#define DDRSS_CTL_62_DATA 0x0000020B -#define DDRSS_CTL_63_DATA 0x00001C64 -#define DDRSS_CTL_64_DATA 0x0000020B -#define DDRSS_CTL_65_DATA 0x00001C64 +#define DDRSS_CTL_62_DATA 0x00000256 +#define DDRSS_CTL_63_DATA 0x00002073 +#define DDRSS_CTL_64_DATA 0x00000256 +#define DDRSS_CTL_65_DATA 0x00002073 #define DDRSS_CTL_66_DATA 0x00000005 #define DDRSS_CTL_67_DATA 0x00030000 -#define DDRSS_CTL_68_DATA 0x00830010 -#define DDRSS_CTL_69_DATA 0x00830386 -#define DDRSS_CTL_70_DATA 0x00400386 +#define DDRSS_CTL_68_DATA 0x00950010 +#define DDRSS_CTL_69_DATA 0x00950408 +#define DDRSS_CTL_70_DATA 0x00400408 #define DDRSS_CTL_71_DATA 0x00120103 -#define DDRSS_CTL_72_DATA 0x000E0005 -#define DDRSS_CTL_73_DATA 0x2908000E -#define DDRSS_CTL_74_DATA 0x05050129 +#define DDRSS_CTL_72_DATA 0x00100005 +#define DDRSS_CTL_73_DATA 0x2F080010 +#define DDRSS_CTL_74_DATA 0x0505012F #define DDRSS_CTL_75_DATA 0x0401030A -#define DDRSS_CTL_76_DATA 0x041B0E0A -#define DDRSS_CTL_77_DATA 0x0E0A0401 -#define DDRSS_CTL_78_DATA 0x0001041B +#define DDRSS_CTL_76_DATA 0x041E100B +#define DDRSS_CTL_77_DATA 0x100B0401 +#define DDRSS_CTL_78_DATA 0x0001041E #define DDRSS_CTL_79_DATA 0x000F000F -#define DDRSS_CTL_80_DATA 0x02190219 -#define DDRSS_CTL_81_DATA 0x02190219 +#define DDRSS_CTL_80_DATA 0x02660266 +#define DDRSS_CTL_81_DATA 0x02660266 #define DDRSS_CTL_82_DATA 0x03050505 #define DDRSS_CTL_83_DATA 0x03010303 -#define DDRSS_CTL_84_DATA 0x1C0A0E0A -#define DDRSS_CTL_85_DATA 0x04040E04 -#define DDRSS_CTL_86_DATA 0x1C0A0E0A -#define DDRSS_CTL_87_DATA 0x04040E04 +#define DDRSS_CTL_84_DATA 0x200B100B +#define DDRSS_CTL_85_DATA 0x04041004 +#define DDRSS_CTL_86_DATA 0x200B100B +#define DDRSS_CTL_87_DATA 0x04041004 #define DDRSS_CTL_88_DATA 0x03010000 #define DDRSS_CTL_89_DATA 0x00010000 #define DDRSS_CTL_90_DATA 0x00000000 @@ -118,20 +118,20 @@ #define DDRSS_CTL_106_DATA 0x00002EC0 #define DDRSS_CTL_107_DATA 0x00000000 #define DDRSS_CTL_108_DATA 0x0000051D -#define DDRSS_CTL_109_DATA 0x00071900 -#define DDRSS_CTL_110_DATA 0x00071900 -#define DDRSS_CTL_111_DATA 0x00071900 -#define DDRSS_CTL_112_DATA 0x00071900 -#define DDRSS_CTL_113_DATA 0x00071900 +#define DDRSS_CTL_109_DATA 0x00081CC0 +#define DDRSS_CTL_110_DATA 0x00081CC0 +#define DDRSS_CTL_111_DATA 0x00081CC0 +#define DDRSS_CTL_112_DATA 0x00081CC0 +#define DDRSS_CTL_113_DATA 0x00081CC0 #define DDRSS_CTL_114_DATA 0x00000000 -#define DDRSS_CTL_115_DATA 0x0000C6BC -#define DDRSS_CTL_116_DATA 0x00071900 -#define DDRSS_CTL_117_DATA 0x00071900 -#define DDRSS_CTL_118_DATA 0x00071900 -#define DDRSS_CTL_119_DATA 0x00071900 -#define DDRSS_CTL_120_DATA 0x00071900 +#define DDRSS_CTL_115_DATA 0x0000E325 +#define DDRSS_CTL_116_DATA 0x00081CC0 +#define DDRSS_CTL_117_DATA 0x00081CC0 +#define DDRSS_CTL_118_DATA 0x00081CC0 +#define DDRSS_CTL_119_DATA 0x00081CC0 +#define DDRSS_CTL_120_DATA 0x00081CC0 #define DDRSS_CTL_121_DATA 0x00000000 -#define DDRSS_CTL_122_DATA 0x0000C6BC +#define DDRSS_CTL_122_DATA 0x0000E325 #define DDRSS_CTL_123_DATA 0x00000000 #define DDRSS_CTL_124_DATA 0x00000000 #define DDRSS_CTL_125_DATA 0x00000000 @@ -140,8 +140,8 @@ #define DDRSS_CTL_128_DATA 0x00000000 #define DDRSS_CTL_129_DATA 0x00000000 #define DDRSS_CTL_130_DATA 0x00000000 -#define DDRSS_CTL_131_DATA 0x0A030500 -#define DDRSS_CTL_132_DATA 0x00040A04 +#define DDRSS_CTL_131_DATA 0x0B030500 +#define DDRSS_CTL_132_DATA 0x00040B04 #define DDRSS_CTL_133_DATA 0x0A090000 #define DDRSS_CTL_134_DATA 0x0A090701 #define DDRSS_CTL_135_DATA 0x0900000E @@ -176,23 +176,23 @@ #define DDRSS_CTL_164_DATA 0x000A0000 #define DDRSS_CTL_165_DATA 0x000D0005 #define DDRSS_CTL_166_DATA 0x000D0404 -#define DDRSS_CTL_167_DATA 0x00BB0176 -#define DDRSS_CTL_168_DATA 0x0E0E01D3 -#define DDRSS_CTL_169_DATA 0x017601D3 -#define DDRSS_CTL_170_DATA 0x01D300BB -#define DDRSS_CTL_171_DATA 0x01D30E0E +#define DDRSS_CTL_167_DATA 0x00D601AB +#define DDRSS_CTL_168_DATA 0x10100216 +#define DDRSS_CTL_169_DATA 0x01AB0216 +#define DDRSS_CTL_170_DATA 0x021600D6 +#define DDRSS_CTL_171_DATA 0x02161010 #define DDRSS_CTL_172_DATA 0x00000000 #define DDRSS_CTL_173_DATA 0x00000000 #define DDRSS_CTL_174_DATA 0x00000000 -#define DDRSS_CTL_175_DATA 0x36E40084 -#define DDRSS_CTL_176_DATA 0x330036E4 +#define DDRSS_CTL_175_DATA 0x3FF40084 +#define DDRSS_CTL_176_DATA 0x33003FF4 #define DDRSS_CTL_177_DATA 0x00003333 #define DDRSS_CTL_178_DATA 0x56000000 #define DDRSS_CTL_179_DATA 0x27270056 #define DDRSS_CTL_180_DATA 0x0F0F0000 #define DDRSS_CTL_181_DATA 0x00000000 #define DDRSS_CTL_182_DATA 0x00840606 -#define DDRSS_CTL_183_DATA 0x36E436E4 +#define DDRSS_CTL_183_DATA 0x3FF43FF4 #define DDRSS_CTL_184_DATA 0x33333300 #define DDRSS_CTL_185_DATA 0x00000000 #define DDRSS_CTL_186_DATA 0x00565600 @@ -270,12 +270,12 @@ #define DDRSS_CTL_258_DATA 0x00320040 #define DDRSS_CTL_259_DATA 0x00020008 #define DDRSS_CTL_260_DATA 0x00400100 -#define DDRSS_CTL_261_DATA 0x0038074A +#define DDRSS_CTL_261_DATA 0x00400855 #define DDRSS_CTL_262_DATA 0x01000200 -#define DDRSS_CTL_263_DATA 0x074A0040 -#define DDRSS_CTL_264_DATA 0x00000038 -#define DDRSS_CTL_265_DATA 0x005E0003 -#define DDRSS_CTL_266_DATA 0x0100005E +#define DDRSS_CTL_263_DATA 0x08550040 +#define DDRSS_CTL_264_DATA 0x00000040 +#define DDRSS_CTL_265_DATA 0x006B0003 +#define DDRSS_CTL_266_DATA 0x0100006B #define DDRSS_CTL_267_DATA 0x00000000 #define DDRSS_CTL_268_DATA 0x01010000 #define DDRSS_CTL_269_DATA 0x00000202 @@ -327,15 +327,15 @@ #define DDRSS_CTL_315_DATA 0x01000101 #define DDRSS_CTL_316_DATA 0x01010001 #define DDRSS_CTL_317_DATA 0x00010101 -#define DDRSS_CTL_318_DATA 0x05090903 -#define DDRSS_CTL_319_DATA 0x0E081B1B -#define DDRSS_CTL_320_DATA 0x0009030E -#define DDRSS_CTL_321_DATA 0x0A0D030F -#define DDRSS_CTL_322_DATA 0x0A0D0306 -#define DDRSS_CTL_323_DATA 0x0D090006 -#define DDRSS_CTL_324_DATA 0x0100000D -#define DDRSS_CTL_325_DATA 0x07030701 -#define DDRSS_CTL_326_DATA 0x00000003 +#define DDRSS_CTL_318_DATA 0x050A0A03 +#define DDRSS_CTL_319_DATA 0x10081F1F +#define DDRSS_CTL_320_DATA 0x00090310 +#define DDRSS_CTL_321_DATA 0x0B0C030F +#define DDRSS_CTL_322_DATA 0x0B0C0306 +#define DDRSS_CTL_323_DATA 0x0C090006 +#define DDRSS_CTL_324_DATA 0x0100000C +#define DDRSS_CTL_325_DATA 0x08040801 +#define DDRSS_CTL_326_DATA 0x00000004 #define DDRSS_CTL_327_DATA 0x00000000 #define DDRSS_CTL_328_DATA 0x00010000 #define DDRSS_CTL_329_DATA 0x00280D00 @@ -396,7 +396,7 @@ #define DDRSS_CTL_384_DATA 0x00000000 #define DDRSS_CTL_385_DATA 0x00000000 #define DDRSS_CTL_386_DATA 0x00000000 -#define DDRSS_CTL_387_DATA 0x37371B00 +#define DDRSS_CTL_387_DATA 0x3A3A1B00 #define DDRSS_CTL_388_DATA 0x000A0000 #define DDRSS_CTL_389_DATA 0x00000176 #define DDRSS_CTL_390_DATA 0x00000200 @@ -406,22 +406,22 @@ #define DDRSS_CTL_394_DATA 0x00000462 #define DDRSS_CTL_395_DATA 0x00000E9C #define DDRSS_CTL_396_DATA 0x00000204 -#define DDRSS_CTL_397_DATA 0x000038C8 +#define DDRSS_CTL_397_DATA 0x000040E6 #define DDRSS_CTL_398_DATA 0x00000200 #define DDRSS_CTL_399_DATA 0x00000200 #define DDRSS_CTL_400_DATA 0x00000200 #define DDRSS_CTL_401_DATA 0x00000200 -#define DDRSS_CTL_402_DATA 0x0000AA58 -#define DDRSS_CTL_403_DATA 0x000237D0 -#define DDRSS_CTL_404_DATA 0x00000C12 -#define DDRSS_CTL_405_DATA 0x000038C8 +#define DDRSS_CTL_402_DATA 0x0000C2B2 +#define DDRSS_CTL_403_DATA 0x000288FC +#define DDRSS_CTL_404_DATA 0x00000E15 +#define DDRSS_CTL_405_DATA 0x000040E6 #define DDRSS_CTL_406_DATA 0x00000200 #define DDRSS_CTL_407_DATA 0x00000200 #define DDRSS_CTL_408_DATA 0x00000200 #define DDRSS_CTL_409_DATA 0x00000200 -#define DDRSS_CTL_410_DATA 0x0000AA58 -#define DDRSS_CTL_411_DATA 0x000237D0 -#define DDRSS_CTL_412_DATA 0x02020C12 +#define DDRSS_CTL_410_DATA 0x0000C2B2 +#define DDRSS_CTL_411_DATA 0x000288FC +#define DDRSS_CTL_412_DATA 0x02020E15 #define DDRSS_CTL_413_DATA 0x03030202 #define DDRSS_CTL_414_DATA 0x00000022 #define DDRSS_CTL_415_DATA 0x00000000 @@ -432,13 +432,13 @@ #define DDRSS_CTL_420_DATA 0x00000000 #define DDRSS_CTL_421_DATA 0x00030000 #define DDRSS_CTL_422_DATA 0x0006001E -#define DDRSS_CTL_423_DATA 0x00190031 -#define DDRSS_CTL_424_DATA 0x00190031 +#define DDRSS_CTL_423_DATA 0x001B0033 +#define DDRSS_CTL_424_DATA 0x001B0033 #define DDRSS_CTL_425_DATA 0x00000000 #define DDRSS_CTL_426_DATA 0x00000000 #define DDRSS_CTL_427_DATA 0x02000000 #define DDRSS_CTL_428_DATA 0x01000404 -#define DDRSS_CTL_429_DATA 0x091A091A +#define DDRSS_CTL_429_DATA 0x0B1E0B1E #define DDRSS_CTL_430_DATA 0x00000105 #define DDRSS_CTL_431_DATA 0x00010101 #define DDRSS_CTL_432_DATA 0x00010101 @@ -447,8 +447,8 @@ #define DDRSS_CTL_435_DATA 0x02000201 #define DDRSS_CTL_436_DATA 0x02010000 #define DDRSS_CTL_437_DATA 0x00000200 -#define DDRSS_CTL_438_DATA 0x22060000 -#define DDRSS_CTL_439_DATA 0x00000122 +#define DDRSS_CTL_438_DATA 0x28060000 +#define DDRSS_CTL_439_DATA 0x00000128 #define DDRSS_CTL_440_DATA 0xFFFFFFFF #define DDRSS_CTL_441_DATA 0xFFFFFFFF #define DDRSS_CTL_442_DATA 0x00000000 @@ -515,7 +515,7 @@ #define DDRSS_PI_43_DATA 0x00000000 #define DDRSS_PI_44_DATA 0x00000000 #define DDRSS_PI_45_DATA 0x000F0F00 -#define DDRSS_PI_46_DATA 0x00000019 +#define DDRSS_PI_46_DATA 0x0000001B #define DDRSS_PI_47_DATA 0x000007D0 #define DDRSS_PI_48_DATA 0x00000300 #define DDRSS_PI_49_DATA 0x00000000 @@ -535,13 +535,13 @@ #define DDRSS_PI_63_DATA 0x01000404 #define DDRSS_PI_64_DATA 0x00000000 #define DDRSS_PI_65_DATA 0x00000000 -#define DDRSS_PI_66_DATA 0x00000101 +#define DDRSS_PI_66_DATA 0x00000100 #define DDRSS_PI_67_DATA 0x0001010F #define DDRSS_PI_68_DATA 0x00340000 #define DDRSS_PI_69_DATA 0x00000000 #define DDRSS_PI_70_DATA 0x00000000 -#define DDRSS_PI_71_DATA 0x00000000 -#define DDRSS_PI_72_DATA 0x01000000 +#define DDRSS_PI_71_DATA 0x0000FFFF +#define DDRSS_PI_72_DATA 0x00000000 #define DDRSS_PI_73_DATA 0x00080100 #define DDRSS_PI_74_DATA 0x02000200 #define DDRSS_PI_75_DATA 0x01000100 @@ -632,18 +632,18 @@ #define DDRSS_PI_160_DATA 0x00000000 #define DDRSS_PI_161_DATA 0x00010000 #define DDRSS_PI_162_DATA 0x00000000 -#define DDRSS_PI_163_DATA 0x26260100 +#define DDRSS_PI_163_DATA 0x2B2B0100 #define DDRSS_PI_164_DATA 0x00000034 -#define DDRSS_PI_165_DATA 0x0000005E -#define DDRSS_PI_166_DATA 0x0002005E +#define DDRSS_PI_165_DATA 0x00000064 +#define DDRSS_PI_166_DATA 0x00020064 #define DDRSS_PI_167_DATA 0x02000200 -#define DDRSS_PI_168_DATA 0x40100C04 -#define DDRSS_PI_169_DATA 0x000E4010 +#define DDRSS_PI_168_DATA 0x48120C04 +#define DDRSS_PI_169_DATA 0x000E4812 #define DDRSS_PI_170_DATA 0x000000BB -#define DDRSS_PI_171_DATA 0x0000020B -#define DDRSS_PI_172_DATA 0x00001C64 -#define DDRSS_PI_173_DATA 0x0000020B -#define DDRSS_PI_174_DATA 0x04001C64 +#define DDRSS_PI_171_DATA 0x00000256 +#define DDRSS_PI_172_DATA 0x00002073 +#define DDRSS_PI_173_DATA 0x00000256 +#define DDRSS_PI_174_DATA 0x04002073 #define DDRSS_PI_175_DATA 0x01010404 #define DDRSS_PI_176_DATA 0x00001501 #define DDRSS_PI_177_DATA 0x00150015 @@ -654,80 +654,80 @@ #define DDRSS_PI_182_DATA 0x00000101 #define DDRSS_PI_183_DATA 0x00000000 #define DDRSS_PI_184_DATA 0x00000000 -#define DDRSS_PI_185_DATA 0x12040000 -#define DDRSS_PI_186_DATA 0x0C0C0212 +#define DDRSS_PI_185_DATA 0x15040000 +#define DDRSS_PI_186_DATA 0x0E0E0215 #define DDRSS_PI_187_DATA 0x00040402 #define DDRSS_PI_188_DATA 0x000C8034 -#define DDRSS_PI_189_DATA 0x001F0047 -#define DDRSS_PI_190_DATA 0x001F0047 +#define DDRSS_PI_189_DATA 0x00218049 +#define DDRSS_PI_190_DATA 0x00218049 #define DDRSS_PI_191_DATA 0x01010101 -#define DDRSS_PI_192_DATA 0x0003000D -#define DDRSS_PI_193_DATA 0x000301D3 -#define DDRSS_PI_194_DATA 0x010001D3 +#define DDRSS_PI_192_DATA 0x0004000D +#define DDRSS_PI_193_DATA 0x00040216 +#define DDRSS_PI_194_DATA 0x01000216 #define DDRSS_PI_195_DATA 0x000E000E -#define DDRSS_PI_196_DATA 0x01D40100 -#define DDRSS_PI_197_DATA 0x010001D4 -#define DDRSS_PI_198_DATA 0x01D401D4 +#define DDRSS_PI_196_DATA 0x02170100 +#define DDRSS_PI_197_DATA 0x01000217 +#define DDRSS_PI_198_DATA 0x02170217 #define DDRSS_PI_199_DATA 0x32103200 #define DDRSS_PI_200_DATA 0x01013210 #define DDRSS_PI_201_DATA 0x0A070601 -#define DDRSS_PI_202_DATA 0x1C11090D -#define DDRSS_PI_203_DATA 0x1C110913 -#define DDRSS_PI_204_DATA 0x0000C013 +#define DDRSS_PI_202_DATA 0x1F130A0D +#define DDRSS_PI_203_DATA 0x1F130A14 +#define DDRSS_PI_204_DATA 0x0000C014 #define DDRSS_PI_205_DATA 0x00C01000 #define DDRSS_PI_206_DATA 0x00C01000 #define DDRSS_PI_207_DATA 0x00021000 -#define DDRSS_PI_208_DATA 0x0021000D -#define DDRSS_PI_209_DATA 0x002101D3 -#define DDRSS_PI_210_DATA 0x001101D3 +#define DDRSS_PI_208_DATA 0x0024000D +#define DDRSS_PI_209_DATA 0x00240216 +#define DDRSS_PI_210_DATA 0x00110216 #define DDRSS_PI_211_DATA 0x32000056 -#define DDRSS_PI_212_DATA 0x00000101 -#define DDRSS_PI_213_DATA 0x005A0035 -#define DDRSS_PI_214_DATA 0x01013212 -#define DDRSS_PI_215_DATA 0x00003500 -#define DDRSS_PI_216_DATA 0x3212005A -#define DDRSS_PI_217_DATA 0x09000101 +#define DDRSS_PI_212_DATA 0x00000301 +#define DDRSS_PI_213_DATA 0x005B003A +#define DDRSS_PI_214_DATA 0x03013212 +#define DDRSS_PI_215_DATA 0x00003A00 +#define DDRSS_PI_216_DATA 0x3212005B +#define DDRSS_PI_217_DATA 0x09000301 #define DDRSS_PI_218_DATA 0x04010504 #define DDRSS_PI_219_DATA 0x0400062B #define DDRSS_PI_220_DATA 0x0A032001 -#define DDRSS_PI_221_DATA 0x262B0F0A -#define DDRSS_PI_222_DATA 0x00002819 -#define DDRSS_PI_223_DATA 0x5400E638 -#define DDRSS_PI_224_DATA 0x1B1C2007 -#define DDRSS_PI_225_DATA 0x262B0F13 -#define DDRSS_PI_226_DATA 0x00002819 -#define DDRSS_PI_227_DATA 0x5400E638 -#define DDRSS_PI_228_DATA 0x1B1C2007 -#define DDRSS_PI_229_DATA 0x00017613 +#define DDRSS_PI_221_DATA 0x2C31110A +#define DDRSS_PI_222_DATA 0x00002D1C +#define DDRSS_PI_223_DATA 0x6001071C +#define DDRSS_PI_224_DATA 0x1E202008 +#define DDRSS_PI_225_DATA 0x2C311116 +#define DDRSS_PI_226_DATA 0x00002D1C +#define DDRSS_PI_227_DATA 0x6001071C +#define DDRSS_PI_228_DATA 0x1E202008 +#define DDRSS_PI_229_DATA 0x00017616 #define DDRSS_PI_230_DATA 0x00000E9C -#define DDRSS_PI_231_DATA 0x000038C8 -#define DDRSS_PI_232_DATA 0x000237D0 -#define DDRSS_PI_233_DATA 0x000038C8 -#define DDRSS_PI_234_DATA 0x000237D0 -#define DDRSS_PI_235_DATA 0x0219000F -#define DDRSS_PI_236_DATA 0x03030219 +#define DDRSS_PI_231_DATA 0x000040E6 +#define DDRSS_PI_232_DATA 0x000288FC +#define DDRSS_PI_233_DATA 0x000040E6 +#define DDRSS_PI_234_DATA 0x000288FC +#define DDRSS_PI_235_DATA 0x0266000F +#define DDRSS_PI_236_DATA 0x03030266 #define DDRSS_PI_237_DATA 0x00271003 #define DDRSS_PI_238_DATA 0x000186A0 #define DDRSS_PI_239_DATA 0x00000005 #define DDRSS_PI_240_DATA 0x00000064 #define DDRSS_PI_241_DATA 0x0000000F -#define DDRSS_PI_242_DATA 0x0005B18F +#define DDRSS_PI_242_DATA 0x000681C8 #define DDRSS_PI_243_DATA 0x000186A0 #define DDRSS_PI_244_DATA 0x00000005 -#define DDRSS_PI_245_DATA 0x00000E94 -#define DDRSS_PI_246_DATA 0x00000219 -#define DDRSS_PI_247_DATA 0x0005B18F +#define DDRSS_PI_245_DATA 0x000010A9 +#define DDRSS_PI_246_DATA 0x00000266 +#define DDRSS_PI_247_DATA 0x000681C8 #define DDRSS_PI_248_DATA 0x000186A0 #define DDRSS_PI_249_DATA 0x00000005 -#define DDRSS_PI_250_DATA 0x00000E94 -#define DDRSS_PI_251_DATA 0x01000219 +#define DDRSS_PI_250_DATA 0x000010A9 +#define DDRSS_PI_251_DATA 0x01000266 #define DDRSS_PI_252_DATA 0x00320040 #define DDRSS_PI_253_DATA 0x00010008 -#define DDRSS_PI_254_DATA 0x074A0040 -#define DDRSS_PI_255_DATA 0x00010038 -#define DDRSS_PI_256_DATA 0x074A0040 -#define DDRSS_PI_257_DATA 0x00000338 -#define DDRSS_PI_258_DATA 0x005E005E +#define DDRSS_PI_254_DATA 0x08550040 +#define DDRSS_PI_255_DATA 0x00010040 +#define DDRSS_PI_256_DATA 0x08550040 +#define DDRSS_PI_257_DATA 0x00000340 +#define DDRSS_PI_258_DATA 0x006B006B #define DDRSS_PI_259_DATA 0x00040404 #define DDRSS_PI_260_DATA 0x00000055 #define DDRSS_PI_261_DATA 0x55003C5A @@ -746,27 +746,27 @@ #define DDRSS_PI_274_DATA 0x00000000 #define DDRSS_PI_275_DATA 0x00330084 #define DDRSS_PI_276_DATA 0x00160000 -#define DDRSS_PI_277_DATA 0x563336E4 +#define DDRSS_PI_277_DATA 0x56333FF4 #define DDRSS_PI_278_DATA 0x00160F27 -#define DDRSS_PI_279_DATA 0x563336E4 +#define DDRSS_PI_279_DATA 0x56333FF4 #define DDRSS_PI_280_DATA 0x00160F27 #define DDRSS_PI_281_DATA 0x00330084 #define DDRSS_PI_282_DATA 0x00160000 -#define DDRSS_PI_283_DATA 0x563336E4 +#define DDRSS_PI_283_DATA 0x56333FF4 #define DDRSS_PI_284_DATA 0x00160F27 -#define DDRSS_PI_285_DATA 0x563336E4 +#define DDRSS_PI_285_DATA 0x56333FF4 #define DDRSS_PI_286_DATA 0x00160F27 #define DDRSS_PI_287_DATA 0x00330084 #define DDRSS_PI_288_DATA 0x00160000 -#define DDRSS_PI_289_DATA 0x563336E4 +#define DDRSS_PI_289_DATA 0x56333FF4 #define DDRSS_PI_290_DATA 0x00160F27 -#define DDRSS_PI_291_DATA 0x563336E4 +#define DDRSS_PI_291_DATA 0x56333FF4 #define DDRSS_PI_292_DATA 0x00160F27 #define DDRSS_PI_293_DATA 0x00330084 #define DDRSS_PI_294_DATA 0x00160000 -#define DDRSS_PI_295_DATA 0x563336E4 +#define DDRSS_PI_295_DATA 0x56333FF4 #define DDRSS_PI_296_DATA 0x00160F27 -#define DDRSS_PI_297_DATA 0x563336E4 +#define DDRSS_PI_297_DATA 0x56333FF4 #define DDRSS_PI_298_DATA 0x00160F27 #define DDRSS_PI_299_DATA 0x00000000 @@ -787,7 +787,7 @@ #define DDRSS_PHY_14_DATA 0x060100CC #define DDRSS_PHY_15_DATA 0x00030066 #define DDRSS_PHY_16_DATA 0x00000000 -#define DDRSS_PHY_17_DATA 0x00000001 +#define DDRSS_PHY_17_DATA 0x00000301 #define DDRSS_PHY_18_DATA 0x0000AAAA #define DDRSS_PHY_19_DATA 0x00005555 #define DDRSS_PHY_20_DATA 0x0000B5B5 @@ -803,7 +803,7 @@ #define DDRSS_PHY_30_DATA 0x0F000000 #define DDRSS_PHY_31_DATA 0x00000F0F #define DDRSS_PHY_32_DATA 0x10200000 -#define DDRSS_PHY_33_DATA 0x0C002004 +#define DDRSS_PHY_33_DATA 0x0C002007 #define DDRSS_PHY_34_DATA 0x00000000 #define DDRSS_PHY_35_DATA 0x00000000 #define DDRSS_PHY_36_DATA 0x55555555 @@ -855,35 +855,35 @@ #define DDRSS_PHY_82_DATA 0x00000000 #define DDRSS_PHY_83_DATA 0x00000100 #define DDRSS_PHY_84_DATA 0x01CC0C01 -#define DDRSS_PHY_85_DATA 0x0003CC0C +#define DDRSS_PHY_85_DATA 0x1003CC0C #define DDRSS_PHY_86_DATA 0x20000140 #define DDRSS_PHY_87_DATA 0x07FF0200 #define DDRSS_PHY_88_DATA 0x0000DD01 #define DDRSS_PHY_89_DATA 0x10100303 #define DDRSS_PHY_90_DATA 0x10101010 #define DDRSS_PHY_91_DATA 0x10101010 -#define DDRSS_PHY_92_DATA 0x00041010 +#define DDRSS_PHY_92_DATA 0x00021010 #define DDRSS_PHY_93_DATA 0x00100010 #define DDRSS_PHY_94_DATA 0x00100010 #define DDRSS_PHY_95_DATA 0x00100010 #define DDRSS_PHY_96_DATA 0x00100010 #define DDRSS_PHY_97_DATA 0x00050010 #define DDRSS_PHY_98_DATA 0x51517041 -#define DDRSS_PHY_99_DATA 0x31C06000 +#define DDRSS_PHY_99_DATA 0x31C06001 #define DDRSS_PHY_100_DATA 0x07AB0340 #define DDRSS_PHY_101_DATA 0x00C0C001 -#define DDRSS_PHY_102_DATA 0x0D0C0001 +#define DDRSS_PHY_102_DATA 0x0E0D0001 #define DDRSS_PHY_103_DATA 0x10001000 -#define DDRSS_PHY_104_DATA 0x0C063E42 -#define DDRSS_PHY_105_DATA 0x0F0C3201 +#define DDRSS_PHY_104_DATA 0x0C083E42 +#define DDRSS_PHY_105_DATA 0x0F0C3701 #define DDRSS_PHY_106_DATA 0x01000140 #define DDRSS_PHY_107_DATA 0x0C000420 -#define DDRSS_PHY_108_DATA 0x000002DD +#define DDRSS_PHY_108_DATA 0x00000322 #define DDRSS_PHY_109_DATA 0x0A0000D0 #define DDRSS_PHY_110_DATA 0x00030200 #define DDRSS_PHY_111_DATA 0x02800000 #define DDRSS_PHY_112_DATA 0x80800000 -#define DDRSS_PHY_113_DATA 0x000D2010 +#define DDRSS_PHY_113_DATA 0x000E2010 #define DDRSS_PHY_114_DATA 0x76543210 #define DDRSS_PHY_115_DATA 0x00000008 #define DDRSS_PHY_116_DATA 0x02800280 @@ -900,13 +900,13 @@ #define DDRSS_PHY_127_DATA 0x00A000A0 #define DDRSS_PHY_128_DATA 0x00A000A0 #define DDRSS_PHY_129_DATA 0x00A000A0 -#define DDRSS_PHY_130_DATA 0x006D00A0 +#define DDRSS_PHY_130_DATA 0x01C200A0 #define DDRSS_PHY_131_DATA 0x01A00005 #define DDRSS_PHY_132_DATA 0x00000000 #define DDRSS_PHY_133_DATA 0x00000000 #define DDRSS_PHY_134_DATA 0x00080200 #define DDRSS_PHY_135_DATA 0x00000000 -#define DDRSS_PHY_136_DATA 0x20202020 +#define DDRSS_PHY_136_DATA 0x20202000 #define DDRSS_PHY_137_DATA 0x20202020 #define DDRSS_PHY_138_DATA 0xF0F02020 #define DDRSS_PHY_139_DATA 0x00000000 @@ -1043,7 +1043,7 @@ #define DDRSS_PHY_270_DATA 0x060100CC #define DDRSS_PHY_271_DATA 0x00030066 #define DDRSS_PHY_272_DATA 0x00000000 -#define DDRSS_PHY_273_DATA 0x00000001 +#define DDRSS_PHY_273_DATA 0x00000301 #define DDRSS_PHY_274_DATA 0x0000AAAA #define DDRSS_PHY_275_DATA 0x00005555 #define DDRSS_PHY_276_DATA 0x0000B5B5 @@ -1059,7 +1059,7 @@ #define DDRSS_PHY_286_DATA 0x0F000000 #define DDRSS_PHY_287_DATA 0x00000F0F #define DDRSS_PHY_288_DATA 0x10200000 -#define DDRSS_PHY_289_DATA 0x0C002004 +#define DDRSS_PHY_289_DATA 0x0C002007 #define DDRSS_PHY_290_DATA 0x00000000 #define DDRSS_PHY_291_DATA 0x00000000 #define DDRSS_PHY_292_DATA 0x55555555 @@ -1111,35 +1111,35 @@ #define DDRSS_PHY_338_DATA 0x00000000 #define DDRSS_PHY_339_DATA 0x00000100 #define DDRSS_PHY_340_DATA 0x01CC0C01 -#define DDRSS_PHY_341_DATA 0x0003CC0C +#define DDRSS_PHY_341_DATA 0x1003CC0C #define DDRSS_PHY_342_DATA 0x20000140 #define DDRSS_PHY_343_DATA 0x07FF0200 #define DDRSS_PHY_344_DATA 0x0000DD01 #define DDRSS_PHY_345_DATA 0x10100303 #define DDRSS_PHY_346_DATA 0x10101010 #define DDRSS_PHY_347_DATA 0x10101010 -#define DDRSS_PHY_348_DATA 0x00041010 +#define DDRSS_PHY_348_DATA 0x00021010 #define DDRSS_PHY_349_DATA 0x00100010 #define DDRSS_PHY_350_DATA 0x00100010 #define DDRSS_PHY_351_DATA 0x00100010 #define DDRSS_PHY_352_DATA 0x00100010 #define DDRSS_PHY_353_DATA 0x00050010 #define DDRSS_PHY_354_DATA 0x51517041 -#define DDRSS_PHY_355_DATA 0x31C06000 +#define DDRSS_PHY_355_DATA 0x31C06001 #define DDRSS_PHY_356_DATA 0x07AB0340 #define DDRSS_PHY_357_DATA 0x00C0C001 -#define DDRSS_PHY_358_DATA 0x0D0C0001 +#define DDRSS_PHY_358_DATA 0x0E0D0001 #define DDRSS_PHY_359_DATA 0x10001000 -#define DDRSS_PHY_360_DATA 0x0C063E42 -#define DDRSS_PHY_361_DATA 0x0F0C3201 +#define DDRSS_PHY_360_DATA 0x0C083E42 +#define DDRSS_PHY_361_DATA 0x0F0C3701 #define DDRSS_PHY_362_DATA 0x01000140 #define DDRSS_PHY_363_DATA 0x0C000420 -#define DDRSS_PHY_364_DATA 0x000002DD +#define DDRSS_PHY_364_DATA 0x00000322 #define DDRSS_PHY_365_DATA 0x0A0000D0 #define DDRSS_PHY_366_DATA 0x00030200 #define DDRSS_PHY_367_DATA 0x02800000 #define DDRSS_PHY_368_DATA 0x80800000 -#define DDRSS_PHY_369_DATA 0x000D2010 +#define DDRSS_PHY_369_DATA 0x000E2010 #define DDRSS_PHY_370_DATA 0x76543210 #define DDRSS_PHY_371_DATA 0x00000008 #define DDRSS_PHY_372_DATA 0x02800280 @@ -1156,13 +1156,13 @@ #define DDRSS_PHY_383_DATA 0x00A000A0 #define DDRSS_PHY_384_DATA 0x00A000A0 #define DDRSS_PHY_385_DATA 0x00A000A0 -#define DDRSS_PHY_386_DATA 0x006D00A0 +#define DDRSS_PHY_386_DATA 0x01C200A0 #define DDRSS_PHY_387_DATA 0x01A00005 #define DDRSS_PHY_388_DATA 0x00000000 #define DDRSS_PHY_389_DATA 0x00000000 #define DDRSS_PHY_390_DATA 0x00080200 #define DDRSS_PHY_391_DATA 0x00000000 -#define DDRSS_PHY_392_DATA 0x20202020 +#define DDRSS_PHY_392_DATA 0x20202000 #define DDRSS_PHY_393_DATA 0x20202020 #define DDRSS_PHY_394_DATA 0xF0F02020 #define DDRSS_PHY_395_DATA 0x00000000 @@ -1299,7 +1299,7 @@ #define DDRSS_PHY_526_DATA 0x060100CC #define DDRSS_PHY_527_DATA 0x00030066 #define DDRSS_PHY_528_DATA 0x00000000 -#define DDRSS_PHY_529_DATA 0x00000001 +#define DDRSS_PHY_529_DATA 0x00000301 #define DDRSS_PHY_530_DATA 0x0000AAAA #define DDRSS_PHY_531_DATA 0x00005555 #define DDRSS_PHY_532_DATA 0x0000B5B5 @@ -1315,7 +1315,7 @@ #define DDRSS_PHY_542_DATA 0x0F000000 #define DDRSS_PHY_543_DATA 0x00000F0F #define DDRSS_PHY_544_DATA 0x10200000 -#define DDRSS_PHY_545_DATA 0x0C002004 +#define DDRSS_PHY_545_DATA 0x0C002007 #define DDRSS_PHY_546_DATA 0x00000000 #define DDRSS_PHY_547_DATA 0x00000000 #define DDRSS_PHY_548_DATA 0x55555555 @@ -1367,35 +1367,35 @@ #define DDRSS_PHY_594_DATA 0x00000000 #define DDRSS_PHY_595_DATA 0x00000100 #define DDRSS_PHY_596_DATA 0x01CC0C01 -#define DDRSS_PHY_597_DATA 0x0003CC0C +#define DDRSS_PHY_597_DATA 0x1003CC0C #define DDRSS_PHY_598_DATA 0x20000140 #define DDRSS_PHY_599_DATA 0x07FF0200 #define DDRSS_PHY_600_DATA 0x0000DD01 #define DDRSS_PHY_601_DATA 0x10100303 #define DDRSS_PHY_602_DATA 0x10101010 #define DDRSS_PHY_603_DATA 0x10101010 -#define DDRSS_PHY_604_DATA 0x00041010 +#define DDRSS_PHY_604_DATA 0x00021010 #define DDRSS_PHY_605_DATA 0x00100010 #define DDRSS_PHY_606_DATA 0x00100010 #define DDRSS_PHY_607_DATA 0x00100010 #define DDRSS_PHY_608_DATA 0x00100010 #define DDRSS_PHY_609_DATA 0x00050010 #define DDRSS_PHY_610_DATA 0x51517041 -#define DDRSS_PHY_611_DATA 0x31C06000 +#define DDRSS_PHY_611_DATA 0x31C06001 #define DDRSS_PHY_612_DATA 0x07AB0340 #define DDRSS_PHY_613_DATA 0x00C0C001 -#define DDRSS_PHY_614_DATA 0x0D0C0001 +#define DDRSS_PHY_614_DATA 0x0E0D0001 #define DDRSS_PHY_615_DATA 0x10001000 -#define DDRSS_PHY_616_DATA 0x0C063E42 -#define DDRSS_PHY_617_DATA 0x0F0C3201 +#define DDRSS_PHY_616_DATA 0x0C083E42 +#define DDRSS_PHY_617_DATA 0x0F0C3701 #define DDRSS_PHY_618_DATA 0x01000140 #define DDRSS_PHY_619_DATA 0x0C000420 -#define DDRSS_PHY_620_DATA 0x000002DD +#define DDRSS_PHY_620_DATA 0x00000322 #define DDRSS_PHY_621_DATA 0x0A0000D0 #define DDRSS_PHY_622_DATA 0x00030200 #define DDRSS_PHY_623_DATA 0x02800000 #define DDRSS_PHY_624_DATA 0x80800000 -#define DDRSS_PHY_625_DATA 0x000D2010 +#define DDRSS_PHY_625_DATA 0x000E2010 #define DDRSS_PHY_626_DATA 0x76543210 #define DDRSS_PHY_627_DATA 0x00000008 #define DDRSS_PHY_628_DATA 0x02800280 @@ -1412,13 +1412,13 @@ #define DDRSS_PHY_639_DATA 0x00A000A0 #define DDRSS_PHY_640_DATA 0x00A000A0 #define DDRSS_PHY_641_DATA 0x00A000A0 -#define DDRSS_PHY_642_DATA 0x006D00A0 +#define DDRSS_PHY_642_DATA 0x01C200A0 #define DDRSS_PHY_643_DATA 0x01A00005 #define DDRSS_PHY_644_DATA 0x00000000 #define DDRSS_PHY_645_DATA 0x00000000 #define DDRSS_PHY_646_DATA 0x00080200 #define DDRSS_PHY_647_DATA 0x00000000 -#define DDRSS_PHY_648_DATA 0x20202020 +#define DDRSS_PHY_648_DATA 0x20202000 #define DDRSS_PHY_649_DATA 0x20202020 #define DDRSS_PHY_650_DATA 0xF0F02020 #define DDRSS_PHY_651_DATA 0x00000000 @@ -1555,7 +1555,7 @@ #define DDRSS_PHY_782_DATA 0x060100CC #define DDRSS_PHY_783_DATA 0x00030066 #define DDRSS_PHY_784_DATA 0x00000000 -#define DDRSS_PHY_785_DATA 0x00000001 +#define DDRSS_PHY_785_DATA 0x00000301 #define DDRSS_PHY_786_DATA 0x0000AAAA #define DDRSS_PHY_787_DATA 0x00005555 #define DDRSS_PHY_788_DATA 0x0000B5B5 @@ -1571,7 +1571,7 @@ #define DDRSS_PHY_798_DATA 0x0F000000 #define DDRSS_PHY_799_DATA 0x00000F0F #define DDRSS_PHY_800_DATA 0x10200000 -#define DDRSS_PHY_801_DATA 0x0C002004 +#define DDRSS_PHY_801_DATA 0x0C002007 #define DDRSS_PHY_802_DATA 0x00000000 #define DDRSS_PHY_803_DATA 0x00000000 #define DDRSS_PHY_804_DATA 0x55555555 @@ -1623,35 +1623,35 @@ #define DDRSS_PHY_850_DATA 0x00000000 #define DDRSS_PHY_851_DATA 0x00000100 #define DDRSS_PHY_852_DATA 0x01CC0C01 -#define DDRSS_PHY_853_DATA 0x0003CC0C +#define DDRSS_PHY_853_DATA 0x1003CC0C #define DDRSS_PHY_854_DATA 0x20000140 #define DDRSS_PHY_855_DATA 0x07FF0200 #define DDRSS_PHY_856_DATA 0x0000DD01 #define DDRSS_PHY_857_DATA 0x10100303 #define DDRSS_PHY_858_DATA 0x10101010 #define DDRSS_PHY_859_DATA 0x10101010 -#define DDRSS_PHY_860_DATA 0x00041010 +#define DDRSS_PHY_860_DATA 0x00021010 #define DDRSS_PHY_861_DATA 0x00100010 #define DDRSS_PHY_862_DATA 0x00100010 #define DDRSS_PHY_863_DATA 0x00100010 #define DDRSS_PHY_864_DATA 0x00100010 #define DDRSS_PHY_865_DATA 0x00050010 #define DDRSS_PHY_866_DATA 0x51517041 -#define DDRSS_PHY_867_DATA 0x31C06000 +#define DDRSS_PHY_867_DATA 0x31C06001 #define DDRSS_PHY_868_DATA 0x07AB0340 #define DDRSS_PHY_869_DATA 0x00C0C001 -#define DDRSS_PHY_870_DATA 0x0D0C0001 +#define DDRSS_PHY_870_DATA 0x0E0D0001 #define DDRSS_PHY_871_DATA 0x10001000 -#define DDRSS_PHY_872_DATA 0x0C063E42 -#define DDRSS_PHY_873_DATA 0x0F0C3201 +#define DDRSS_PHY_872_DATA 0x0C083E42 +#define DDRSS_PHY_873_DATA 0x0F0C3701 #define DDRSS_PHY_874_DATA 0x01000140 #define DDRSS_PHY_875_DATA 0x0C000420 -#define DDRSS_PHY_876_DATA 0x000002DD +#define DDRSS_PHY_876_DATA 0x00000322 #define DDRSS_PHY_877_DATA 0x0A0000D0 #define DDRSS_PHY_878_DATA 0x00030200 #define DDRSS_PHY_879_DATA 0x02800000 #define DDRSS_PHY_880_DATA 0x80800000 -#define DDRSS_PHY_881_DATA 0x000D2010 +#define DDRSS_PHY_881_DATA 0x000E2010 #define DDRSS_PHY_882_DATA 0x76543210 #define DDRSS_PHY_883_DATA 0x00000008 #define DDRSS_PHY_884_DATA 0x02800280 @@ -1668,13 +1668,13 @@ #define DDRSS_PHY_895_DATA 0x00A000A0 #define DDRSS_PHY_896_DATA 0x00A000A0 #define DDRSS_PHY_897_DATA 0x00A000A0 -#define DDRSS_PHY_898_DATA 0x006D00A0 +#define DDRSS_PHY_898_DATA 0x01C200A0 #define DDRSS_PHY_899_DATA 0x01A00005 #define DDRSS_PHY_900_DATA 0x00000000 #define DDRSS_PHY_901_DATA 0x00000000 #define DDRSS_PHY_902_DATA 0x00080200 #define DDRSS_PHY_903_DATA 0x00000000 -#define DDRSS_PHY_904_DATA 0x20202020 +#define DDRSS_PHY_904_DATA 0x20202000 #define DDRSS_PHY_905_DATA 0x20202020 #define DDRSS_PHY_906_DATA 0xF0F02020 #define DDRSS_PHY_907_DATA 0x00000000 @@ -1834,7 +1834,7 @@ #define DDRSS_PHY_1061_DATA 0x00000000 #define DDRSS_PHY_1062_DATA 0x00000000 #define DDRSS_PHY_1063_DATA 0x00000000 -#define DDRSS_PHY_1064_DATA 0x000505FF +#define DDRSS_PHY_1064_DATA 0x000305FF #define DDRSS_PHY_1065_DATA 0x00030000 #define DDRSS_PHY_1066_DATA 0x00000300 #define DDRSS_PHY_1067_DATA 0x00000300 @@ -2163,8 +2163,8 @@ #define DDRSS_PHY_1390_DATA 0x00000000 #define DDRSS_PHY_1391_DATA 0x00000000 #define DDRSS_PHY_1392_DATA 0x00000000 -#define DDRSS_PHY_1393_DATA 0x0001F7C5 -#define DDRSS_PHY_1394_DATA 0x00000005 +#define DDRSS_PHY_1393_DATA 0x0001F7C0 +#define DDRSS_PHY_1394_DATA 0x00000003 #define DDRSS_PHY_1395_DATA 0x00000000 #define DDRSS_PHY_1396_DATA 0x00001142 #define DDRSS_PHY_1397_DATA 0x010207AB diff --git a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts index 2dde65d968..25f2ada5a8 100644 --- a/arch/arm/dts/k3-j721e-r5-common-proc-board.dts +++ b/arch/arm/dts/k3-j721e-r5-common-proc-board.dts @@ -6,7 +6,7 @@ /dts-v1/; #include "k3-j721e-som-p0.dtsi" -#include "k3-j721e-ddr-evm-lp4-3733.dtsi" +#include "k3-j721e-ddr-evm-lp4-4266.dtsi" #include "k3-j721e-ddr.dtsi" / { @@ -28,6 +28,7 @@ power-domains = <&k3_pds 61 TI_SCI_PD_EXCLUSIVE>, <&k3_pds 202 TI_SCI_PD_EXCLUSIVE>; resets = <&k3_reset 202 0>; + clocks = <&k3_clks 61 1>; assigned-clocks = <&k3_clks 202 2>, <&k3_clks 61 1>; assigned-clock-rates = <2000000000>, <200000000>; ti,sci = <&dmsc>; diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi new file mode 100644 index 0000000000..0cb6eaf5d0 --- /dev/null +++ b/arch/arm/dts/sama7g5.dtsi @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * sama7g5.dtsi - Device Tree Include file for SAMA7G5 SoC. + * + * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries + * + * Author: Eugen Hristev <eugen.hristev@microchip.com> + * Author: Claudiu Beznea <claudiu.beznea@microchip.com> + * + */ + +#include "skeleton.dtsi" +#include <dt-bindings/clk/at91.h> + +/ { + model = "Microchip SAMA7G5 family SoC"; + compatible = "microchip,sama7g5"; + + clocks { + slow_rc_osc: slow_rc_osc { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <32000>; + }; + + main_rc: main_rc { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <12000000>; + }; + + slow_xtal: slow_xtal { + compatible = "fixed-clock"; + #clock-cells = <0>; + }; + + main_xtal: main_xtal { + compatible = "fixed-clock"; + #clock-cells = <0>; + }; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + A7_0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a7"; + clocks = <&pmc PMC_TYPE_CORE 8>, <&pmc PMC_TYPE_CORE 22>, <&main_xtal>; + clock-names = "cpu", "master", "xtal"; + }; + }; + + ahb { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + apb { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + pioA: pinctrl@e0014000 { + compatible = "atmel,sama5d2-gpio"; + reg = <0xe0014000 0x800>; + gpio-controller; + #gpio-cells = <2>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 11>; + status = "okay"; + + pinctrl: pinctrl_default { + compatible = "microchip,sama7g5-pinctrl"; + }; + }; + + pmc: pmc@e0018000 { + compatible = "microchip,sama7g5-pmc"; + reg = <0xe0018000 0x200>; + #clock-cells = <2>; + clocks = <&clk32 1>, <&clk32 0>, <&main_xtal>, <&main_rc>; + clock-names = "td_slck", "md_slck", "main_xtal", "main_rc"; + status = "okay"; + }; + + clk32: sckc@e001d050 { + compatible = "microchip,sam9x60-sckc"; + reg = <0xe001d050 0x4>; + clocks = <&slow_rc_osc>, <&slow_xtal>; + #clock-cells = <1>; + }; + + sdmmc0: sdio-host@e1204000 { + compatible = "microchip,sama7g5-sdhci"; + reg = <0xe1204000 0x300>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 80>, <&pmc PMC_TYPE_GCK 80>; + clock-names = "hclock", "multclk"; + assigned-clocks = <&pmc PMC_TYPE_GCK 80>; + assigned-clock-rates = <200000000>; + assigned-clock-parents = <&pmc PMC_TYPE_CORE 10>; /* sys pll div. */ + status = "disabled"; + }; + + sdmmc1: sdio-host@e1208000 { + compatible = "microchip,sama7g5-sdhci"; + reg = <0xe1208000 0x300>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 81>, <&pmc PMC_TYPE_GCK 81>; + clock-names = "hclock", "multclk"; + assigned-clocks = <&pmc PMC_TYPE_GCK 81>; + assigned-clock-rates = <200000000>; + assigned-clock-parents = <&pmc PMC_TYPE_CORE 10>; /* sys pll div. */ + status = "disabled"; + }; + + pit64b0: timer@e1800000 { + compatible = "microchip,sama7g5-pit64b"; + reg = <0xe1800000 0x4000>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 70>, <&pmc PMC_TYPE_GCK 70>; + clock-names = "pclk", "gclk"; + status = "okay"; + }; + + flx1: flexcom@e181c000 { + compatible = "atmel,sama5d2-flexcom"; + reg = <0xe181c000 0x200>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 39>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0xe181c000 0x800>; + status = "disabled"; + + i2c1: i2c@600 { + compatible = "atmel,sama5d2-i2c"; + reg = <0x600 0x200>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 39>; + }; + }; + + uart0: serial@e1824200 { + compatible = "atmel,at91sam9260-usart"; + reg = <0xe1824200 0x200>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 41>; + clock-names = "usart"; + status = "disabled"; + }; + + gmac0: ethernet@e2800000 { + compatible = "cdns,sama7g5-gem"; + reg = <0xe2800000 0x4000>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 51>, <&pmc PMC_TYPE_PERIPHERAL 51>, <&pmc PMC_TYPE_GCK 51>; + clock-names = "hclk", "pclk", "tx_clk"; + assigned-clocks = <&pmc PMC_TYPE_GCK 51>; + assigned-clock-parents = <&pmc PMC_TYPE_CORE 21>; /* eth pll div. */ + assigned-clock-rates = <125000000>; + status = "disabled"; + }; + + gmac1: ethernet@e2804000 { + compatible = "cdns,sama7g5-emac"; + reg = <0xe2804000 0x1000>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 52>, <&pmc PMC_TYPE_PERIPHERAL 52>; + clock-names = "pclk", "hclk"; + status = "disabled"; + }; + }; + }; +}; diff --git a/arch/arm/dts/sama7g5ek-u-boot.dtsi b/arch/arm/dts/sama7g5ek-u-boot.dtsi new file mode 100644 index 0000000000..5e1a0d53a5 --- /dev/null +++ b/arch/arm/dts/sama7g5ek-u-boot.dtsi @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * sama7g5ek-u-boot.dts - Device Tree file for SAMA7G5 SoC u-boot properties. + * + * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries + * + * Author: Eugen Hristev <eugen.hristev@microchip.com> + * Author: Claudiu Beznea <claudiu.beznea@microchip.com> + * + */ + +/ { + chosen { + u-boot,dm-pre-reloc; + }; + + ahb { + u-boot,dm-pre-reloc; + + apb { + u-boot,dm-pre-reloc; + }; + }; +}; + +&main_rc { + u-boot,dm-pre-reloc; +}; + +&main_xtal { + u-boot,dm-pre-reloc; +}; + +&pioA { + u-boot,dm-pre-reloc; + + pinctrl { + u-boot,dm-pre-reloc; + }; +}; + +&pinctrl_flx3_default { + u-boot,dm-pre-reloc; +}; + +&pit64b0 { + u-boot,dm-pre-reloc; +}; + +&pmc { + u-boot,dm-pre-reloc; +}; + +&slow_rc_osc { + u-boot,dm-pre-reloc; +}; + +&slow_xtal { + u-boot,dm-pre-reloc; +}; + +&uart0 { + u-boot,dm-pre-reloc; +}; + diff --git a/arch/arm/dts/sama7g5ek.dts b/arch/arm/dts/sama7g5ek.dts new file mode 100644 index 0000000000..ff9c9eb45c --- /dev/null +++ b/arch/arm/dts/sama7g5ek.dts @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * sama7g5ek.dts - Device Tree file for SAMA7G5 EK + * SAMA7G5 Evaluation Kit + * + * Copyright (c) 2020, Microchip Technology Inc. + * 2020, Eugen Hristev <eugen.hristev@microchip.com> + * 2020, Claudiu Beznea <claudiu.beznea@microchip.com> + */ +/dts-v1/; +#include "sama7g5.dtsi" +#include "sama7g5-pinfunc.h" + +/ { + model = "Microchip SAMA7G5 Evaluation Kit"; + compatible = "microchip,sama7g5ek", "microchip,sama7g54", "microchip,sama7g5", "microchip,sama7"; + + aliases { + serial0 = &uart0; + i2c0 = &i2c1; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + clocks { + slow_xtal: slow_xtal { + clock-frequency = <32768>; + }; + + main_xtal: main_xtal { + clock-frequency = <24000000>; + }; + }; + + ahb { + + apb { + sdmmc0: sdio-host@e1204000 { + bus-width = <8>; + non-removable; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_sdmmc0_cmd_data_default + &pinctrl_sdmmc0_ck_rstn_ds_cd_default>; + status = "okay"; + }; + + sdmmc1: sdio-host@e1208000 { + bus-width = <4>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_sdmmc1_cmd_data_default + &pinctrl_sdmmc1_ck_cd_rstn_vddsel_default>; + status = "okay"; + }; + + uart0: serial@e1824200 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_flx3_default>; + status = "okay"; + }; + }; + }; +}; + +&flx1 { + atmel,flexcom-mode = <3>; + status = "okay"; +}; + +&i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_flx1_default>; + status = "okay"; + + eeprom@52 { + compatible = "microchip,24aa02e48"; + reg = <0x52>; + pagesize = <16>; + }; + + eeprom@53 { + compatible = "microchip,24aa02e48"; + reg = <0x53>; + pagesize = <16>; + }; +}; + +&gmac0 { + #address-cells = <1>; + #size-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_gmac0_default &pinctrl_gmac0_txc_default>; + phy-mode = "rgmii-id"; + status = "okay"; + + ethernet-phy@7 { + reg = <0x7>; + }; +}; + +&gmac1 { + #address-cells = <1>; + #size-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_gmac1_default>; + phy-mode = "rmii"; + status = "okay"; + + ethernet-phy@0 { + reg = <0x0>; + }; +}; + +&pinctrl { + pinctrl_flx1_default: flx1_default { + pinmux = <PIN_PC9__FLEXCOM1_IO0>, + <PIN_PC10__FLEXCOM1_IO1>; + bias-disable; + }; + + pinctrl_flx3_default: flx3_default { + pinmux = <PIN_PD16__FLEXCOM3_IO0>, + <PIN_PD17__FLEXCOM3_IO1>; + bias-disable; + }; + + pinctrl_sdmmc0_cmd_data_default: sdmmc0_cmd_data_default { + pinmux = <PIN_PA1__SDMMC0_CMD>, + <PIN_PA3__SDMMC0_DAT0>, + <PIN_PA4__SDMMC0_DAT1>, + <PIN_PA5__SDMMC0_DAT2>, + <PIN_PA6__SDMMC0_DAT3>, + <PIN_PA7__SDMMC0_DAT4>, + <PIN_PA8__SDMMC0_DAT5>, + <PIN_PA9__SDMMC0_DAT6>, + <PIN_PA10__SDMMC0_DAT7>; + bias-pull-up; + }; + + pinctrl_sdmmc0_ck_rstn_ds_cd_default: sdmmc0_ck_rstn_ds_cd_default { + pinmux = <PIN_PA0__SDMMC0_CK>, + <PIN_PA2__SDMMC0_RSTN>, + <PIN_PA11__SDMMC0_DS>, + <PIN_PA14__SDMMC0_CD>; + bias-pull-up; + }; + + pinctrl_sdmmc1_cmd_data_default: sdmmc1_cmd_data_default { + pinmux = <PIN_PB29__SDMMC1_CMD>, + <PIN_PB31__SDMMC1_DAT0>, + <PIN_PC0__SDMMC1_DAT1>, + <PIN_PC1__SDMMC1_DAT2>, + <PIN_PC2__SDMMC1_DAT3>; + bias-pull-up; + }; + + pinctrl_sdmmc1_ck_cd_rstn_vddsel_default: sdmmc1_ck_cd_rstn_vddsel_default { + pinmux = <PIN_PB30__SDMMC1_CK>, + <PIN_PB28__SDMMC1_RSTN>, + <PIN_PC5__SDMMC1_1V8SEL>, + <PIN_PC4__SDMMC1_CD>; + bias-pull-up; + }; + + pinctrl_gmac0_default: gmac0_default { + pinmux = <PIN_PA16__G0_TX0>, + <PIN_PA17__G0_TX1>, + <PIN_PA26__G0_TX2>, + <PIN_PA27__G0_TX3>, + <PIN_PA19__G0_RX0>, + <PIN_PA20__G0_RX1>, + <PIN_PA28__G0_RX2>, + <PIN_PA29__G0_RX3>, + <PIN_PA15__G0_TXEN>, + <PIN_PA30__G0_RXCK>, + <PIN_PA18__G0_RXDV>, + <PIN_PA22__G0_MDC>, + <PIN_PA23__G0_MDIO>, + <PIN_PA25__G0_125CK>; + bias-disable; + }; + + pinctrl_gmac0_txc_default: gmac0_txc_default { + pinmux = <PIN_PA24__G0_TXCK>; + bias-pull-up; + }; + + pinctrl_gmac1_default: gmac1_default { + pinmux = <PIN_PD30__G1_TXCK>, + <PIN_PD22__G1_TX0>, + <PIN_PD23__G1_TX1>, + <PIN_PD21__G1_TXEN>, + <PIN_PD25__G1_RX0>, + <PIN_PD26__G1_RX1>, + <PIN_PD27__G1_RXER>, + <PIN_PD24__G1_RXDV>, + <PIN_PD28__G1_MDC>, + <PIN_PD29__G1_MDIO>; + bias-disable; + }; +}; diff --git a/arch/arm/dts/zynqmp-zcu1275-revB.dts b/arch/arm/dts/zynqmp-zcu1275-revB.dts index b612215f40..1de890c30f 100644 --- a/arch/arm/dts/zynqmp-zcu1275-revB.dts +++ b/arch/arm/dts/zynqmp-zcu1275-revB.dts @@ -23,6 +23,7 @@ serial1 = &dcc; spi0 = &qspi; mmc0 = &sdhci1; + ethernet0 = &gem1; }; chosen { @@ -40,6 +41,29 @@ status = "okay"; }; +&gem1 { + status = "okay"; + mdio { + #address-cells = <1>; + #size-cells = <0>; + phy1: ethernet-phy@1 { + reg = <1>; /* KSZ9031RNXIC on AES-FMC-NETW1-G */ + rxc-skew-ps = <1800>; /* Skew control of RX_CLK pad output */ + txc-skew-ps = <1800>; /* Skew control of GTX_CLK pad input */ + txen-skew-ps = <900>; /* Skew control of TX_CTL pad input */ + rxdv-skew-ps = <0>; /* Skew control of RX_CTL pad output */ + rxd0-skew-ps = <0>; /* Skew control of RXD0 pad output */ + rxd1-skew-ps = <0>; /* Skew control of RXD1 pad output */ + rxd2-skew-ps = <0>; /* Skew control of RXD2 pad output */ + rxd3-skew-ps = <0>; /* Skew control of RXD3 pad output */ + txd0-skew-ps = <900>; /* Skew control of TXD0 pad input */ + txd1-skew-ps = <900>; /* Skew control of TXD1 pad input */ + txd2-skew-ps = <900>; /* Skew control of TXD2 pad input */ + txd3-skew-ps = <900>; /* Skew control of TXD3 pad input */ + }; + }; +}; + &qspi { status = "okay"; flash@0 { diff --git a/arch/arm/dts/zynqmp-zcu1285-revA.dts b/arch/arm/dts/zynqmp-zcu1285-revA.dts index f041df83da..21d62e993a 100644 --- a/arch/arm/dts/zynqmp-zcu1285-revA.dts +++ b/arch/arm/dts/zynqmp-zcu1285-revA.dts @@ -23,6 +23,7 @@ serial1 = &dcc; spi0 = &qspi; mmc0 = &sdhci1; + ethernet0 = &gem1; /* EMIO */ i2c = &i2c0; /* EMIO */ }; @@ -222,6 +223,28 @@ }; }; +&gem1 { + mdio { + #address-cells = <1>; + #size-cells = <0>; + phy1: ethernet-phy@1 { + reg = <1>; /* KSZ9031RNXIC on AES-FMC-NETW1-G */ + rxc-skew-ps = <1800>; /* Skew control of RX_CLK pad output */ + txc-skew-ps = <1800>; /* Skew control of GTX_CLK pad input */ + txen-skew-ps = <900>; /* Skew control of TX_CTL pad input */ + rxdv-skew-ps = <0>; /* Skew control of RX_CTL pad output */ + rxd0-skew-ps = <0>; /* Skew control of RXD0 pad output */ + rxd1-skew-ps = <0>; /* Skew control of RXD1 pad output */ + rxd2-skew-ps = <0>; /* Skew control of RXD2 pad output */ + rxd3-skew-ps = <0>; /* Skew control of RXD3 pad output */ + txd0-skew-ps = <900>; /* Skew control of TXD0 pad input */ + txd1-skew-ps = <900>; /* Skew control of TXD1 pad input */ + txd2-skew-ps = <900>; /* Skew control of TXD2 pad input */ + txd3-skew-ps = <900>; /* Skew control of TXD3 pad input */ + }; + }; +}; + &qspi { status = "okay"; flash@0 { diff --git a/arch/arm/dts/zynqmp.dtsi b/arch/arm/dts/zynqmp.dtsi index 1634af0bd8..aa0ac95e12 100644 --- a/arch/arm/dts/zynqmp.dtsi +++ b/arch/arm/dts/zynqmp.dtsi @@ -115,8 +115,10 @@ <0x0 0xff9905e0 0x0 0x20>, <0x0 0xff990e80 0x0 0x20>, <0x0 0xff990ea0 0x0 0x20>; - reg-names = "local_request_region", "local_response_region", - "remote_request_region", "remote_response_region"; + reg-names = "local_request_region", + "local_response_region", + "remote_request_region", + "remote_response_region"; #mbox-cells = <1>; xlnx,ipi-id = <4>; }; @@ -145,15 +147,10 @@ firmware { zynqmp_firmware: zynqmp-firmware { compatible = "xlnx,zynqmp-firmware"; + #power-domain-cells = <1>; method = "smc"; - #power-domain-cells = <0x1>; u-boot,dm-pre-reloc; - zynqmp_pcap: pcap { - compatible = "xlnx,zynqmp-pcap-fpga"; - clock-names = "ref_clk"; - }; - zynqmp_power: zynqmp-power { u-boot,dm-pre-reloc; compatible = "xlnx,zynqmp-power"; @@ -163,6 +160,11 @@ mbox-names = "tx", "rx"; }; + zynqmp_pcap: pcap { + compatible = "xlnx,zynqmp-pcap-fpga"; + clock-names = "ref_clk"; + }; + zynqmp_reset: reset-controller { compatible = "xlnx,zynqmp-reset"; #reset-cells = <1>; @@ -206,26 +208,7 @@ }; }; - amba_apu: amba-apu@0 { - compatible = "simple-bus"; - #address-cells = <2>; - #size-cells = <1>; - ranges = <0 0 0 0 0xffffffff>; - - gic: interrupt-controller@f9010000 { - compatible = "arm,gic-400"; - #interrupt-cells = <3>; - reg = <0x0 0xf9010000 0x10000>, - <0x0 0xf9020000 0x20000>, - <0x0 0xf9040000 0x20000>, - <0x0 0xf9060000 0x20000>; - interrupt-controller; - interrupt-parent = <&gic>; - interrupts = <1 9 0xf04>; - }; - }; - - amba: amba { + amba: axi { compatible = "simple-bus"; u-boot,dm-pre-reloc; #address-cells = <2>; @@ -380,6 +363,18 @@ power-domains = <&zynqmp_firmware PD_GDMA>; }; + gic: interrupt-controller@f9010000 { + compatible = "arm,gic-400"; + #interrupt-cells = <3>; + reg = <0x0 0xf9010000 0x0 0x10000>, + <0x0 0xf9020000 0x0 0x20000>, + <0x0 0xf9040000 0x0 0x20000>, + <0x0 0xf9060000 0x0 0x20000>; + interrupt-controller; + interrupt-parent = <&gic>; + interrupts = <1 9 0xf04>; + }; + gpu: gpu@fd4b0000 { status = "disabled"; compatible = "arm,mali-400", "arm,mali-utgard"; @@ -590,7 +585,7 @@ }; i2c0: i2c@ff020000 { - compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10"; + compatible = "cdns,i2c-r1p14"; status = "disabled"; interrupt-parent = <&gic>; interrupts = <0 17 4>; @@ -601,7 +596,7 @@ }; i2c1: i2c@ff030000 { - compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10"; + compatible = "cdns,i2c-r1p14"; status = "disabled"; interrupt-parent = <&gic>; interrupts = <0 18 4>; @@ -639,8 +634,8 @@ <0x0 0xfd480000 0x0 0x1000>, <0x80 0x00000000 0x0 0x1000000>; reg-names = "breg", "pcireg", "cfg"; - ranges = <0x02000000 0x00000000 0xe0000000 0x00000000 0xe0000000 0x00000000 0x10000000 /* non-prefetchable memory */ - 0x43000000 0x00000006 0x00000000 0x00000006 0x00000000 0x00000002 0x00000000>;/* prefetchable memory */ + ranges = <0x02000000 0x00000000 0xe0000000 0x00000000 0xe0000000 0x00000000 0x10000000>,/* non-prefetchable memory */ + <0x43000000 0x00000006 0x00000000 0x00000006 0x00000000 0x00000002 0x00000000>;/* prefetchable memory */ bus-range = <0x00 0xff>; interrupt-map-mask = <0x0 0x0 0x0 0x7>; interrupt-map = <0x0 0x0 0x0 0x1 &pcie_intc 0x1>, @@ -770,7 +765,7 @@ clock-output-names = "clk_out_sd1", "clk_in_sd1"; }; - smmu: smmu@fd800000 { + smmu: iommu@fd800000 { compatible = "arm,mmu-500"; reg = <0x0 0xfd800000 0x0 0x20000>; #iommu-cells = <1>; diff --git a/arch/arm/include/asm/arch-am33xx/clock.h b/arch/arm/include/asm/arch-am33xx/clock.h index dc7a9b188d..5d775902bb 100644 --- a/arch/arm/include/asm/arch-am33xx/clock.h +++ b/arch/arm/include/asm/arch-am33xx/clock.h @@ -66,6 +66,7 @@ #define DPLL_EN_STOP 1 #define DPLL_EN_MN_BYPASS 4 #define DPLL_EN_LOW_POWER_BYPASS 5 +#define DPLL_EN_FAST_RELOCK_BYPASS 6 #define DPLL_EN_LOCK 7 /* CM_IDLEST_DPLL fields */ diff --git a/arch/arm/include/asm/arch-hi6220/gpio.h b/arch/arm/include/asm/arch-hi6220/gpio.h index c5ee359a3a..12717a96aa 100644 --- a/arch/arm/include/asm/arch-hi6220/gpio.h +++ b/arch/arm/include/asm/arch-hi6220/gpio.h @@ -18,7 +18,7 @@ struct gpio_bank { }; /* Information about a GPIO bank */ -struct hikey_gpio_platdata { +struct hikey_gpio_plat { int bank_index; ulong base; /* address of registers in physical memory */ }; diff --git a/arch/arm/include/asm/arch-imx8/power-domain.h b/arch/arm/include/asm/arch-imx8/power-domain.h index 1396008877..1db86a1209 100644 --- a/arch/arm/include/asm/arch-imx8/power-domain.h +++ b/arch/arm/include/asm/arch-imx8/power-domain.h @@ -8,7 +8,7 @@ #include <asm/arch/sci/types.h> -struct imx8_power_domain_platdata { +struct imx8_power_domain_plat { sc_rsrc_t resource_id; }; diff --git a/arch/arm/include/asm/arch-imx8m/power-domain.h b/arch/arm/include/asm/arch-imx8m/power-domain.h index 0f94945894..7a833e564b 100644 --- a/arch/arm/include/asm/arch-imx8m/power-domain.h +++ b/arch/arm/include/asm/arch-imx8m/power-domain.h @@ -6,7 +6,7 @@ #ifndef _ASM_ARCH_IMX8M_POWER_DOMAIN_H #define _ASM_ARCH_IMX8M_POWER_DOMAIN_H -struct imx8m_power_domain_platdata { +struct imx8m_power_domain_plat { int resource_id; int has_pd; struct power_domain pd; diff --git a/arch/arm/include/asm/arch-sunxi/boot0.h b/arch/arm/include/asm/arch-sunxi/boot0.h index 54c144afd8..46d0f0666c 100644 --- a/arch/arm/include/asm/arch-sunxi/boot0.h +++ b/arch/arm/include/asm/arch-sunxi/boot0.h @@ -15,6 +15,19 @@ tst x0, x0 // this is "b #0x84" in ARM b reset .space 0x7c + + .word 0xe28f0058 // add r0, pc, #88 + .word 0xe59f1054 // ldr r1, [pc, #84] + .word 0xe0800001 // add r0, r0, r1 + .word 0xe580d000 // str sp, [r0] + .word 0xe580e004 // str lr, [r0, #4] + .word 0xe10fe000 // mrs lr, CPSR + .word 0xe580e008 // str lr, [r0, #8] + .word 0xee11ef10 // mrc 15, 0, lr, cr1, cr0, {0} + .word 0xe580e00c // str lr, [r0, #12] + .word 0xee1cef10 // mrc 15, 0, lr, cr12, cr0, {0} + .word 0xe580e010 // str lr, [r0, #16] + .word 0xe59f1024 // ldr r1, [pc, #36] ; 0x170000a0 .word 0xe59f0024 // ldr r0, [pc, #36] ; CONFIG_*_TEXT_BASE .word 0xe5810000 // str r0, [r1] @@ -36,6 +49,7 @@ #else .word CONFIG_SYS_TEXT_BASE #endif + .word fel_stash - . #else /* normal execution */ b reset diff --git a/arch/arm/include/asm/arch-sunxi/spl.h b/arch/arm/include/asm/arch-sunxi/spl.h index 8c916e8c75..58cdf806d9 100644 --- a/arch/arm/include/asm/arch-sunxi/spl.h +++ b/arch/arm/include/asm/arch-sunxi/spl.h @@ -7,19 +7,7 @@ #ifndef _ASM_ARCH_SPL_H_ #define _ASM_ARCH_SPL_H_ -#define BOOT0_MAGIC "eGON.BT0" -#define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */ -#define SPL_MAJOR_BITS 3 -#define SPL_MINOR_BITS 5 -#define SPL_VERSION(maj, min) \ - ((((maj) & ((1U << SPL_MAJOR_BITS) - 1)) << SPL_MINOR_BITS) | \ - ((min) & ((1U << SPL_MINOR_BITS) - 1))) - -#define SPL_HEADER_VERSION SPL_VERSION(0, 2) - -#define SPL_ENV_HEADER_VERSION SPL_VERSION(0, 1) -#define SPL_DT_HEADER_VERSION SPL_VERSION(0, 2) -#define SPL_DRAM_HEADER_VERSION SPL_VERSION(0, 3) +#include <sunxi_image.h> #define SPL_ADDR CONFIG_SUNXI_SRAM_ADDRESS @@ -31,59 +19,7 @@ #define SUNXI_BOOTED_FROM_MMC0_HIGH 0x10 #define SUNXI_BOOTED_FROM_MMC2_HIGH 0x12 -/* boot head definition from sun4i boot code */ -struct boot_file_head { - uint32_t b_instruction; /* one intruction jumping to real code */ - uint8_t magic[8]; /* ="eGON.BT0" or "eGON.BT1", not C-style str */ - uint32_t check_sum; /* generated by PC */ - uint32_t length; /* generated by PC */ - /* - * We use a simplified header, only filling in what is needed - * by the boot ROM. To be compatible with Allwinner tools we - * would need to implement the proper fields here instead of - * padding. - * - * Actually we want the ability to recognize our "sunxi" variant - * of the SPL. To do so, let's place a special signature into the - * "pub_head_size" field. We can reasonably expect Allwinner's - * boot0 to always have the upper 16 bits of this set to 0 (after - * all the value shouldn't be larger than the limit imposed by - * SRAM size). - * If the signature is present (at 0x14), then we know it's safe - * to use the remaining 8 bytes (at 0x18) for our own purposes. - * (E.g. sunxi-tools "fel" utility can pass information there.) - */ - union { - uint32_t pub_head_size; - uint8_t spl_signature[4]; - }; - uint32_t fel_script_address; /* since v0.1, set by sunxi-fel */ - /* - * If the fel_uEnv_length member below is set to a non-zero value, - * it specifies the size (byte count) of data at fel_script_address. - * At the same time this indicates that the data is in uEnv.txt - * compatible format, ready to be imported via "env import -t". - */ - uint32_t fel_uEnv_length; /* since v0.1, set by sunxi-fel */ - /* - * Offset of an ASCIIZ string (relative to the SPL header), which - * contains the default device tree name (CONFIG_DEFAULT_DEVICE_TREE). - * This is optional and may be set to NULL. Is intended to be used - * by flash programming tools for providing nice informative messages - * to the users. - */ - uint32_t dt_name_offset; /* since v0.2, set by mksunxiboot */ - uint32_t dram_size; /* in MiB, since v0.3, set by SPL */ - uint32_t boot_media; /* written here by the boot ROM */ - /* A padding area (may be used for storing text strings) */ - uint32_t string_pool[13]; /* since v0.2, filled by mksunxiboot */ - /* The header must be a multiple of 32 bytes (for VBAR alignment) */ -}; - -/* Compile time check to assure proper alignment of structure */ -typedef char boot_file_head_not_multiple_of_32[1 - 2*(sizeof(struct boot_file_head) % 32)]; - -#define is_boot0_magic(addr) (memcmp((void *)addr, BOOT0_MAGIC, 8) == 0) +#define is_boot0_magic(addr) (memcmp((void *)(addr), BOOT0_MAGIC, 8) == 0) uint32_t sunxi_get_boot_device(void); diff --git a/arch/arm/include/asm/arch-vf610/gpio.h b/arch/arm/include/asm/arch-vf610/gpio.h index 9bfdf16873..0b9e10f51e 100644 --- a/arch/arm/include/asm/arch-vf610/gpio.h +++ b/arch/arm/include/asm/arch-vf610/gpio.h @@ -20,7 +20,7 @@ struct vybrid_gpio_regs { u32 gpio_pdir; }; -struct vybrid_gpio_platdata { +struct vybrid_gpio_plat { unsigned int chip; u32 base; const char *port_name; diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h b/arch/arm/include/asm/mach-imx/mxc_i2c.h index 81fd981444..c016aa7474 100644 --- a/arch/arm/include/asm/mach-imx/mxc_i2c.h +++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h @@ -42,7 +42,7 @@ struct mxc_i2c_bus { /* * board file can use this index to locate which i2c_pads_info is for * i2c_idle_bus. When pinmux is implement, this entry can be - * discarded. Here we do not use dev->seq, because we do not want to + * discarded. Here we do not use dev_seq(dev), because we do not want to * export device to board file. */ int index; diff --git a/arch/arm/include/asm/omap_gpio.h b/arch/arm/include/asm/omap_gpio.h index 151afa8f44..4084210021 100644 --- a/arch/arm/include/asm/omap_gpio.h +++ b/arch/arm/include/asm/omap_gpio.h @@ -25,7 +25,7 @@ #if CONFIG_IS_ENABLED(DM_GPIO) /* Information about a GPIO bank */ -struct omap_gpio_platdata { +struct omap_gpio_plat { int bank_index; ulong base; /* address of registers in physical memory */ const char *port_name; diff --git a/arch/arm/include/asm/omap_i2c.h b/arch/arm/include/asm/omap_i2c.h index a6975401da..ec7a145f17 100644 --- a/arch/arm/include/asm/omap_i2c.h +++ b/arch/arm/include/asm/omap_i2c.h @@ -6,7 +6,7 @@ #ifdef CONFIG_DM_I2C /* Information about a GPIO bank */ -struct omap_i2c_platdata { +struct omap_i2c_plat { ulong base; /* address of registers in physical memory */ int speed; int ip_rev; diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h index b40ea005be..614c93def8 100644 --- a/arch/arm/include/asm/omap_musb.h +++ b/arch/arm/include/asm/omap_musb.h @@ -23,7 +23,7 @@ struct omap_musb_board_data { enum musb_interface {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; -struct ti_musb_platdata { +struct ti_musb_plat { void *base; void *ctrl_mod_base; struct musb_hdrc_platform_data plat; diff --git a/arch/arm/lib/bootm-fdt.c b/arch/arm/lib/bootm-fdt.c index 02a49a8e10..fe46a7d7c9 100644 --- a/arch/arm/lib/bootm-fdt.c +++ b/arch/arm/lib/bootm-fdt.c @@ -63,7 +63,7 @@ int arch_fixup_fdt(void *blob) #endif #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \ - defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) + CONFIG_IS_ENABLED(SEC_FIRMWARE_ARMV8_PSCI) ret = psci_update_dt(blob); if (ret) return ret; diff --git a/arch/arm/lib/gic-v3-its.c b/arch/arm/lib/gic-v3-its.c index a1657e3853..f5a921b3d1 100644 --- a/arch/arm/lib/gic-v3-its.c +++ b/arch/arm/lib/gic-v3-its.c @@ -43,10 +43,10 @@ static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv) int ret; ret = uclass_get_device_by_driver(UCLASS_IRQ, - DM_GET_DRIVER(arm_gic_v3_its), &dev); + DM_DRIVER_GET(arm_gic_v3_its), &dev); if (ret) { pr_err("%s: failed to get %s irq device\n", __func__, - DM_GET_DRIVER(arm_gic_v3_its)->name); + DM_DRIVER_GET(arm_gic_v3_its)->name); return ret; } @@ -74,17 +74,17 @@ static int gic_v3_its_get_gic_lpi_addr(struct gic_v3_its_priv *priv) int ret; ret = uclass_get_device_by_driver(UCLASS_SYSCON, - DM_GET_DRIVER(gic_lpi_syscon), &dev); + DM_DRIVER_GET(gic_lpi_syscon), &dev); if (ret) { pr_err("%s: failed to get %s syscon device\n", __func__, - DM_GET_DRIVER(gic_lpi_syscon)->name); + DM_DRIVER_GET(gic_lpi_syscon)->name); return ret; } regmap = syscon_get_regmap(dev); if (!regmap) { pr_err("%s: failed to regmap for %s syscon device\n", __func__, - DM_GET_DRIVER(gic_lpi_syscon)->name); + DM_DRIVER_GET(gic_lpi_syscon)->name); return -ENODEV; } priv->lpi_base = regmap->ranges[0].start; diff --git a/arch/arm/lib/psci-dt.c b/arch/arm/lib/psci-dt.c index 0ed29a43f1..903b335704 100644 --- a/arch/arm/lib/psci-dt.c +++ b/arch/arm/lib/psci-dt.c @@ -10,7 +10,7 @@ #include <linux/sizes.h> #include <linux/kernel.h> #include <asm/psci.h> -#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) #include <asm/armv8/sec_firmware.h> #endif @@ -64,7 +64,7 @@ int fdt_psci(void *fdt) return nodeoff; init_psci_node: -#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) psci_ver = sec_firmware_support_psci_version(); #elif defined(CONFIG_ARMV7_PSCI_1_0) || defined(CONFIG_ARMV8_PSCI) psci_ver = ARM_PSCI_VER_1_0; @@ -85,7 +85,7 @@ init_psci_node: return tmp; } -#ifndef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#if !CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) /* * The Secure firmware framework isn't able to support PSCI version 0.1. */ diff --git a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c index 3e9f5e57ed..02bd3f67c9 100644 --- a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c +++ b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c @@ -12,7 +12,7 @@ int ast_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(aspeed_ast2500_scu), devp); + DM_DRIVER_GET(aspeed_ast2500_scu), devp); } void *ast_get_scu(void) diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index be1415f909..c78a308f48 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -265,6 +265,13 @@ config TARGET_CORVUS select SUPPORT_SPL imply CMD_DM +config TARGET_SAMA7G5EK + bool "SAMA7G5 EK board" + select SAMA7G5 + select BOARD_EARLY_INIT_F + select BOARD_LATE_INIT + + config TARGET_TAURUS bool "Support taurus" select AT91SAM9G20 @@ -327,6 +334,7 @@ source "board/atmel/at91sam9n12ek/Kconfig" source "board/atmel/at91sam9rlek/Kconfig" source "board/atmel/at91sam9x5ek/Kconfig" source "board/atmel/sam9x60ek/Kconfig" +source "board/atmel/sama7g5ek/Kconfig" source "board/atmel/sama5d2_ptc_ek/Kconfig" source "board/atmel/sama5d2_xplained/Kconfig" source "board/atmel/sama5d27_som1_ek/Kconfig" diff --git a/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c b/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c index 8122d2f98e..c10571fa28 100644 --- a/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c +++ b/arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c @@ -213,13 +213,13 @@ void at91_sdram_hw_init(void) } /* Platform data for the GPIOs */ -static const struct at91_port_platdata at91sam9260_plat[] = { +static const struct at91_port_plat at91sam9260_plat[] = { { ATMEL_BASE_PIOA, "PA" }, { ATMEL_BASE_PIOB, "PB" }, { ATMEL_BASE_PIOC, "PC" }, }; -U_BOOT_DEVICES(at91sam9260_gpios) = { +U_BOOT_DRVINFOS(at91sam9260_gpios) = { { "atmel_at91rm9200_gpio", &at91sam9260_plat[0] }, { "atmel_at91rm9200_gpio", &at91sam9260_plat[1] }, { "atmel_at91rm9200_gpio", &at91sam9260_plat[2] }, diff --git a/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c b/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c index 08ca3edd78..d517810c99 100644 --- a/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c +++ b/arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c @@ -167,7 +167,7 @@ void at91_mci_hw_init(void) #endif /* Platform data for the GPIOs */ -static const struct at91_port_platdata at91sam9260_plat[] = { +static const struct at91_port_plat at91sam9260_plat[] = { { ATMEL_BASE_PIOA, "PA" }, { ATMEL_BASE_PIOB, "PB" }, { ATMEL_BASE_PIOC, "PC" }, @@ -175,7 +175,7 @@ static const struct at91_port_platdata at91sam9260_plat[] = { { ATMEL_BASE_PIOE, "PE" }, }; -U_BOOT_DEVICES(at91sam9260_gpios) = { +U_BOOT_DRVINFOS(at91sam9260_gpios) = { { "atmel_at91rm9200_gpio", &at91sam9260_plat[0] }, { "atmel_at91rm9200_gpio", &at91sam9260_plat[1] }, { "atmel_at91rm9200_gpio", &at91sam9260_plat[2] }, diff --git a/arch/arm/mach-at91/include/mach/atmel_serial.h b/arch/arm/mach-at91/include/mach/atmel_serial.h index c53a509ff8..5d14269364 100644 --- a/arch/arm/mach-at91/include/mach/atmel_serial.h +++ b/arch/arm/mach-at91/include/mach/atmel_serial.h @@ -7,7 +7,7 @@ #define _ATMEL_SERIAL_H /* Information about a serial port */ -struct atmel_serial_platdata { +struct atmel_serial_plat { uint32_t base_addr; }; diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h index 575c6436ad..c1aef798b1 100644 --- a/arch/arm/mach-at91/include/mach/gpio.h +++ b/arch/arm/mach-at91/include/mach/gpio.h @@ -253,7 +253,7 @@ static inline unsigned at91_gpio_to_pin(unsigned gpio) } /* Platform data for each GPIO port */ -struct at91_port_platdata { +struct at91_port_plat { uint32_t base_addr; const char *bank_name; }; diff --git a/arch/arm/mach-bcm283x/include/mach/gpio.h b/arch/arm/mach-bcm283x/include/mach/gpio.h index 3263de9a35..4aeb48eeb2 100644 --- a/arch/arm/mach-bcm283x/include/mach/gpio.h +++ b/arch/arm/mach-bcm283x/include/mach/gpio.h @@ -52,11 +52,11 @@ struct bcm2835_gpio_regs { }; /** - * struct bcm2835_gpio_platdata - GPIO platform description + * struct bcm2835_gpio_plat - GPIO platform description * * @base: Base address of GPIO controller */ -struct bcm2835_gpio_platdata { +struct bcm2835_gpio_plat { unsigned long base; }; diff --git a/arch/arm/mach-davinci/da850_lowlevel.c b/arch/arm/mach-davinci/da850_lowlevel.c index 07bf19b5e4..759c93747c 100644 --- a/arch/arm/mach-davinci/da850_lowlevel.c +++ b/arch/arm/mach-davinci/da850_lowlevel.c @@ -290,8 +290,8 @@ int arch_cpu_init(void) board_gpio_init(); #if !CONFIG_IS_ENABLED(DM_SERIAL) - NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1), - CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); + ns16550_init((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), + CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); #endif /* * Fix Power and Emulation Management Register diff --git a/arch/arm/mach-davinci/spl.c b/arch/arm/mach-davinci/spl.c index 5fea935d6e..d0d7a81471 100644 --- a/arch/arm/mach-davinci/spl.c +++ b/arch/arm/mach-davinci/spl.c @@ -27,9 +27,9 @@ void puts(const char *str) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r'); + ns16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), '\r'); - NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); + ns16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), c); } #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */ diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c index f43a2460f9..bf6dddfdc9 100644 --- a/arch/arm/mach-imx/mx6/soc.c +++ b/arch/arm/mach-imx/mx6/soc.c @@ -44,9 +44,9 @@ static const struct imx_thermal_plat imx6_thermal_plat = { .fuse_word = 6, }; -U_BOOT_DEVICE(imx6_thermal) = { +U_BOOT_DRVINFO(imx6_thermal) = { .name = "imx_thermal", - .platdata = &imx6_thermal_plat, + .plat = &imx6_thermal_plat, }; #endif diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c index d0385b36e4..fda25ba66a 100644 --- a/arch/arm/mach-imx/mx7/soc.c +++ b/arch/arm/mach-imx/mx7/soc.c @@ -60,9 +60,9 @@ static const struct imx_thermal_plat imx7_thermal_plat = { .fuse_word = 3, }; -U_BOOT_DEVICE(imx7_thermal) = { +U_BOOT_DRVINFO(imx7_thermal) = { .name = "imx_thermal", - .platdata = &imx7_thermal_plat, + .plat = &imx7_thermal_plat, }; #endif diff --git a/arch/arm/mach-ipq40xx/clock-ipq4019.c b/arch/arm/mach-ipq40xx/clock-ipq4019.c index 31ae9719e8..c1d5c4ecdd 100644 --- a/arch/arm/mach-ipq40xx/clock-ipq4019.c +++ b/arch/arm/mach-ipq40xx/clock-ipq4019.c @@ -8,8 +8,8 @@ * */ -#include <common.h> #include <clk-uclass.h> +#include <common.h> #include <dm.h> #include <errno.h> @@ -25,9 +25,8 @@ ulong msm_set_rate(struct clk *clk, ulong rate) case GCC_BLSP1_UART1_APPS_CLK: /*UART1*/ /* This clock is already initialized by SBL1 */ return 0; - break; default: - return 0; + return -EINVAL; } } @@ -35,7 +34,7 @@ static int msm_clk_probe(struct udevice *dev) { struct msm_clk_priv *priv = dev_get_priv(dev); - priv->base = devfdt_get_addr(dev); + priv->base = dev_read_addr(dev); if (priv->base == FDT_ADDR_T_NONE) return -EINVAL; @@ -53,13 +52,19 @@ static int msm_enable(struct clk *clk) case GCC_BLSP1_QUP1_SPI_APPS_CLK: /*SPI1*/ /* This clock is already initialized by SBL1 */ return 0; - break; case GCC_PRNG_AHB_CLK: /*PRNG*/ /* This clock is already initialized by SBL1 */ return 0; - break; - default: + case GCC_USB3_MASTER_CLK: + case GCC_USB3_SLEEP_CLK: + case GCC_USB3_MOCK_UTMI_CLK: + case GCC_USB2_MASTER_CLK: + case GCC_USB2_SLEEP_CLK: + case GCC_USB2_MOCK_UTMI_CLK: + /* These clocks is already initialized by SBL1 */ return 0; + default: + return -EINVAL; } } @@ -78,6 +83,6 @@ U_BOOT_DRIVER(clk_msm) = { .id = UCLASS_CLK, .of_match = msm_clk_ids, .ops = &msm_clk_ops, - .priv_auto_alloc_size = sizeof(struct msm_clk_priv), + .priv_auto = sizeof(struct msm_clk_priv), .probe = msm_clk_probe, }; diff --git a/arch/arm/mach-ipq40xx/pinctrl-snapdragon.c b/arch/arm/mach-ipq40xx/pinctrl-snapdragon.c index 64b8b049fa..c51a75ee94 100644 --- a/arch/arm/mach-ipq40xx/pinctrl-snapdragon.c +++ b/arch/arm/mach-ipq40xx/pinctrl-snapdragon.c @@ -131,7 +131,7 @@ U_BOOT_DRIVER(pinctrl_snapdraon) = { .name = "pinctrl_msm", .id = UCLASS_PINCTRL, .of_match = msm_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct msm_pinctrl_priv), + .priv_auto = sizeof(struct msm_pinctrl_priv), .ops = &msm_pinctrl_ops, .probe = msm_pinctrl_probe, }; diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 603834e507..dea470c02f 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -208,7 +208,7 @@ void board_init_f(ulong dummy) * firmware (SYSFW) image for various purposes and SYSFW depends on us * to initialize its pin settings. */ - ret = uclass_find_device_by_seq(UCLASS_SERIAL, 0, true, &dev); + ret = uclass_find_device_by_seq(UCLASS_SERIAL, 0, &dev); if (!ret) pinctrl_select_state(dev, "default"); @@ -238,7 +238,7 @@ void board_init_f(ulong dummy) do_board_detect(); #if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0) - ret = uclass_get_device_by_driver(UCLASS_MISC, DM_GET_DRIVER(k3_avs), + ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(k3_avs), &dev); if (ret) printf("AVS init failed: %d\n", ret); diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 8c903f14ff..8b54e0cf52 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -33,7 +33,7 @@ struct ti_sci_handle *get_ti_sci_handle(void) int ret; ret = uclass_get_device_by_driver(UCLASS_FIRMWARE, - DM_GET_DRIVER(ti_sci), &dev); + DM_DRIVER_GET(ti_sci), &dev); if (ret) panic("Failed to get SYSFW (%d)\n", ret); diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c index a36e4ed603..1a4f796e5e 100644 --- a/arch/arm/mach-k3/j721e_init.c +++ b/arch/arm/mach-k3/j721e_init.c @@ -167,7 +167,7 @@ void board_init_f(ulong dummy) * firmware (SYSFW) image for various purposes and SYSFW depends on us * to initialize its pin settings. */ - ret = uclass_find_device_by_seq(UCLASS_SERIAL, 0, true, &dev); + ret = uclass_find_device_by_seq(UCLASS_SERIAL, 0, &dev); if (!ret) pinctrl_select_state(dev, "default"); @@ -206,7 +206,7 @@ void board_init_f(ulong dummy) do_board_detect(); #if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0) - ret = uclass_get_device_by_driver(UCLASS_MISC, DM_GET_DRIVER(k3_avs), + ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(k3_avs), &dev); if (ret) printf("AVS init failed: %d\n", ret); diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c index 78c158c63f..708d9c8508 100644 --- a/arch/arm/mach-k3/sysfw-loader.c +++ b/arch/arm/mach-k3/sysfw-loader.c @@ -223,7 +223,7 @@ static void *k3_sysfw_get_spi_addr(void) int ret; ret = uclass_find_device_by_seq(UCLASS_SPI, CONFIG_SF_DEFAULT_BUS, - true, &dev); + &dev); if (ret) return NULL; diff --git a/arch/arm/mach-keystone/init.c b/arch/arm/mach-keystone/init.c index 88e8912959..4950f14655 100644 --- a/arch/arm/mach-keystone/init.c +++ b/arch/arm/mach-keystone/init.c @@ -185,7 +185,7 @@ int arch_cpu_init(void) * driver doesn't handle this. */ #ifndef CONFIG_DM_SERIAL - NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM2), + ns16550_init((struct ns16550 *)(CONFIG_SYS_NS16550_COM2), CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); #endif diff --git a/arch/arm/mach-lpc32xx/devices.c b/arch/arm/mach-lpc32xx/devices.c index 7e7646a2e1..e1e2e0d094 100644 --- a/arch/arm/mach-lpc32xx/devices.c +++ b/arch/arm/mach-lpc32xx/devices.c @@ -43,7 +43,7 @@ void lpc32xx_uart_init(unsigned int uart_id) } #if !CONFIG_IS_ENABLED(OF_CONTROL) -static const struct ns16550_platdata lpc32xx_uart[] = { +static const struct ns16550_plat lpc32xx_uart[] = { { .base = UART3_BASE, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, }, { .base = UART4_BASE, .reg_shift = 2, @@ -55,14 +55,14 @@ static const struct ns16550_platdata lpc32xx_uart[] = { }; #if defined(CONFIG_LPC32XX_HSUART) -static const struct lpc32xx_hsuart_platdata lpc32xx_hsuart[] = { +static const struct lpc32xx_hsuart_plat lpc32xx_hsuart[] = { { HS_UART1_BASE, }, { HS_UART2_BASE, }, { HS_UART7_BASE, }, }; #endif -U_BOOT_DEVICES(lpc32xx_uarts) = { +U_BOOT_DRVINFOS(lpc32xx_uarts) = { #if defined(CONFIG_LPC32XX_HSUART) { "lpc32xx_hsuart", &lpc32xx_hsuart[0], }, { "lpc32xx_hsuart", &lpc32xx_hsuart[1], }, @@ -124,7 +124,7 @@ void lpc32xx_i2c_init(unsigned int devnum) writel(ctrl, &clk->i2cclk_ctrl); } -U_BOOT_DEVICE(lpc32xx_gpios) = { +U_BOOT_DRVINFO(lpc32xx_gpios) = { .name = "gpio_lpc32xx" }; diff --git a/arch/arm/mach-mediatek/mt7629/init.c b/arch/arm/mach-mediatek/mt7629/init.c index c260413a57..1f102dddd4 100644 --- a/arch/arm/mach-mediatek/mt7629/init.c +++ b/arch/arm/mach-mediatek/mt7629/init.c @@ -40,7 +40,7 @@ int mtk_pll_early_init(void) int ret, i; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(mtk_clk_apmixedsys), &dev); + DM_DRIVER_GET(mtk_clk_apmixedsys), &dev); if (ret) return ret; @@ -59,7 +59,7 @@ int mtk_pll_early_init(void) /* setup mcu bus */ ret = uclass_get_device_by_driver(UCLASS_SYSCON, - DM_GET_DRIVER(mtk_mcucfg), &dev); + DM_DRIVER_GET(mtk_mcucfg), &dev); if (ret) return ret; diff --git a/arch/arm/mach-mediatek/mt8516/init.c b/arch/arm/mach-mediatek/mt8516/init.c index 13be391221..2ffa5595cf 100644 --- a/arch/arm/mach-mediatek/mt8516/init.c +++ b/arch/arm/mach-mediatek/mt8516/init.c @@ -52,7 +52,7 @@ int mtk_pll_early_init(void) int ret, i; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(mtk_clk_apmixedsys), &dev); + DM_DRIVER_GET(mtk_clk_apmixedsys), &dev); if (ret) return ret; diff --git a/arch/arm/mach-nexell/include/mach/display.h b/arch/arm/mach-nexell/include/mach/display.h index b167e63a5a..b0ee912605 100644 --- a/arch/arm/mach-nexell/include/mach/display.h +++ b/arch/arm/mach-nexell/include/mach/display.h @@ -212,7 +212,7 @@ struct dp_hdmi_dev { }; /* platform data for the driver model */ -struct nx_display_platdata { +struct nx_display_plat { int module; struct dp_sync_info sync; struct dp_ctrl_info ctrl; @@ -267,7 +267,7 @@ int dp_plane_wait_vsync(int module, int layer, int fps); #if defined CONFIG_SPL_BUILD || \ (!defined(CONFIG_DM) && !defined(CONFIG_OF_CONTROL)) -int nx_display_probe(struct nx_display_platdata *plat); +int nx_display_probe(struct nx_display_plat *plat); #endif #endif diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c index 2888390d24..e17898d8fb 100644 --- a/arch/arm/mach-omap2/am33xx/board.c +++ b/arch/arm/mach-omap2/am33xx/board.c @@ -80,7 +80,7 @@ int dram_init_banksize(void) } #if !CONFIG_IS_ENABLED(OF_CONTROL) -static const struct ns16550_platdata am33xx_serial[] = { +static const struct ns16550_plat am33xx_serial[] = { { .base = CONFIG_SYS_NS16550_COM1, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, }, # ifdef CONFIG_SYS_NS16550_COM2 @@ -99,7 +99,7 @@ static const struct ns16550_platdata am33xx_serial[] = { # endif }; -U_BOOT_DEVICES(am33xx_uarts) = { +U_BOOT_DRVINFOS(am33xx_uarts) = { { "ns16550_serial", &am33xx_serial[0] }, # ifdef CONFIG_SYS_NS16550_COM2 { "ns16550_serial", &am33xx_serial[1] }, @@ -113,13 +113,13 @@ U_BOOT_DEVICES(am33xx_uarts) = { }; #ifdef CONFIG_DM_I2C -static const struct omap_i2c_platdata am33xx_i2c[] = { +static const struct omap_i2c_plat am33xx_i2c[] = { { I2C_BASE1, 100000, OMAP_I2C_REV_V2}, { I2C_BASE2, 100000, OMAP_I2C_REV_V2}, { I2C_BASE3, 100000, OMAP_I2C_REV_V2}, }; -U_BOOT_DEVICES(am33xx_i2c) = { +U_BOOT_DRVINFOS(am33xx_i2c) = { { "i2c_omap", &am33xx_i2c[0] }, { "i2c_omap", &am33xx_i2c[1] }, { "i2c_omap", &am33xx_i2c[2] }, @@ -127,7 +127,7 @@ U_BOOT_DEVICES(am33xx_i2c) = { #endif #if CONFIG_IS_ENABLED(DM_GPIO) -static const struct omap_gpio_platdata am33xx_gpio[] = { +static const struct omap_gpio_plat am33xx_gpio[] = { { 0, AM33XX_GPIO0_BASE }, { 1, AM33XX_GPIO1_BASE }, { 2, AM33XX_GPIO2_BASE }, @@ -138,7 +138,7 @@ static const struct omap_gpio_platdata am33xx_gpio[] = { #endif }; -U_BOOT_DEVICES(am33xx_gpios) = { +U_BOOT_DRVINFOS(am33xx_gpios) = { { "gpio_omap", &am33xx_gpio[0] }, { "gpio_omap", &am33xx_gpio[1] }, { "gpio_omap", &am33xx_gpio[2] }, @@ -155,9 +155,9 @@ static const struct omap3_spi_plat omap3_spi_pdata = { .pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT, }; -U_BOOT_DEVICE(am33xx_spi) = { +U_BOOT_DRVINFO(am33xx_spi) = { .name = "omap3_spi", - .platdata = &omap3_spi_pdata, + .plat = &omap3_spi_pdata, }; #endif #endif @@ -214,7 +214,7 @@ static struct musb_hdrc_config musb_config = { }; #if CONFIG_IS_ENABLED(DM_USB) && !CONFIG_IS_ENABLED(OF_CONTROL) -static struct ti_musb_platdata usb0 = { +static struct ti_musb_plat usb0 = { .base = (void *)USB0_OTG_BASE, .ctrl_mod_base = &((struct ctrl_dev *)CTRL_DEVICE_BASE)->usb_ctrl0, .plat = { @@ -224,7 +224,7 @@ static struct ti_musb_platdata usb0 = { }, }; -static struct ti_musb_platdata usb1 = { +static struct ti_musb_plat usb1 = { .base = (void *)USB1_OTG_BASE, .ctrl_mod_base = &((struct ctrl_dev *)CTRL_DEVICE_BASE)->usb_ctrl1, .plat = { @@ -234,7 +234,7 @@ static struct ti_musb_platdata usb1 = { }, }; -U_BOOT_DEVICES(am33xx_usbs) = { +U_BOOT_DRVINFOS(am33xx_usbs) = { #if CONFIG_AM335X_USB0_MODE == MUSB_PERIPHERAL { "ti-musb-peripheral", &usb0 }, #elif CONFIG_AM335X_USB0_MODE == MUSB_HOST diff --git a/arch/arm/mach-omap2/am33xx/clock.c b/arch/arm/mach-omap2/am33xx/clock.c index 8819062aaa..130ee6c6e3 100644 --- a/arch/arm/mach-omap2/am33xx/clock.c +++ b/arch/arm/mach-omap2/am33xx/clock.c @@ -194,13 +194,14 @@ void do_enable_clocks(u32 *const *clk_domains, u32 i, max = 100; /* Put the clock domains in SW_WKUP mode */ - for (i = 0; (i < max) && clk_domains[i]; i++) { + for (i = 0; (i < max) && clk_domains && clk_domains[i]; i++) { enable_clock_domain(clk_domains[i], CD_CLKCTRL_CLKTRCTRL_SW_WKUP); } /* Clock modules that need to be put in SW_EXPLICIT_EN mode */ - for (i = 0; (i < max) && clk_modules_explicit_en[i]; i++) { + for (i = 0; (i < max) && clk_modules_explicit_en && + clk_modules_explicit_en[i]; i++) { enable_clock_module(clk_modules_explicit_en[i], MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN, wait_for_enable); @@ -215,12 +216,13 @@ void do_disable_clocks(u32 *const *clk_domains, /* Clock modules that need to be put in SW_DISABLE */ - for (i = 0; (i < max) && clk_modules_disable[i]; i++) + for (i = 0; (i < max) && clk_modules_disable && clk_modules_disable[i]; + i++) disable_clock_module(clk_modules_disable[i], wait_for_disable); /* Put the clock domains in SW_SLEEP mode */ - for (i = 0; (i < max) && clk_domains[i]; i++) + for (i = 0; (i < max) && clk_domains && clk_domains[i]; i++) disable_clock_domain(clk_domains[i]); } diff --git a/arch/arm/mach-omap2/am33xx/clock_am33xx.c b/arch/arm/mach-omap2/am33xx/clock_am33xx.c index 2427933c8b..cf71192360 100644 --- a/arch/arm/mach-omap2/am33xx/clock_am33xx.c +++ b/arch/arm/mach-omap2/am33xx/clock_am33xx.c @@ -226,7 +226,7 @@ void enable_basic_clocks(void) &cmper->usb0clkctrl, &cmper->emiffwclkctrl, &cmper->emifclkctrl, -#if CONFIG_IS_ENABLED(AM335X_LCD) +#if CONFIG_IS_ENABLED(AM335X_LCD) && !CONFIG_IS_ENABLED(DM_VIDEO) &cmper->lcdclkctrl, &cmper->lcdcclkstctrl, #endif diff --git a/arch/arm/mach-omap2/omap3/board.c b/arch/arm/mach-omap2/omap3/board.c index f08c8ab43a..4da8df47cc 100644 --- a/arch/arm/mach-omap2/omap3/board.c +++ b/arch/arm/mach-omap2/omap3/board.c @@ -38,7 +38,7 @@ static void omap3_invalidate_l2_cache_secure(void); #if CONFIG_IS_ENABLED(DM_GPIO) #if !CONFIG_IS_ENABLED(OF_CONTROL) /* Manually initialize GPIO banks when OF_CONTROL doesn't */ -static const struct omap_gpio_platdata omap34xx_gpio[] = { +static const struct omap_gpio_plat omap34xx_gpio[] = { { 0, OMAP34XX_GPIO1_BASE }, { 1, OMAP34XX_GPIO2_BASE }, { 2, OMAP34XX_GPIO3_BASE }, @@ -47,7 +47,7 @@ static const struct omap_gpio_platdata omap34xx_gpio[] = { { 5, OMAP34XX_GPIO6_BASE }, }; -U_BOOT_DEVICES(omap34xx_gpios) = { +U_BOOT_DRVINFOS(omap34xx_gpios) = { { "gpio_omap", &omap34xx_gpio[0] }, { "gpio_omap", &omap34xx_gpio[1] }, { "gpio_omap", &omap34xx_gpio[2] }, diff --git a/arch/arm/mach-qemu/Kconfig b/arch/arm/mach-qemu/Kconfig index 588d2d3102..186c3582eb 100644 --- a/arch/arm/mach-qemu/Kconfig +++ b/arch/arm/mach-qemu/Kconfig @@ -16,12 +16,14 @@ choice config TARGET_QEMU_ARM_32BIT bool "ARMv7-A, 32bit" select ARCH_SUPPORT_PSCI + select BOARD_LATE_INIT select CPU_V7A select SYS_ARCH_TIMER config TARGET_QEMU_ARM_64BIT bool "ARMv8, 64bit" select ARM64 + select BOARD_LATE_INIT endchoice diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c index 28c7c7214c..87eebd9872 100644 --- a/arch/arm/mach-rockchip/misc.c +++ b/arch/arm/mach-rockchip/misc.c @@ -67,10 +67,10 @@ int rockchip_cpuid_from_efuse(const u32 cpuid_offset, /* retrieve the device */ #if CONFIG_IS_ENABLED(ROCKCHIP_EFUSE) ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(rockchip_efuse), &dev); + DM_DRIVER_GET(rockchip_efuse), &dev); #elif CONFIG_IS_ENABLED(ROCKCHIP_OTP) ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(rockchip_otp), &dev); + DM_DRIVER_GET(rockchip_otp), &dev); #endif if (ret) { debug("%s: could not find efuse device\n", __func__); diff --git a/arch/arm/mach-rockchip/px30/clk_px30.c b/arch/arm/mach-rockchip/px30/clk_px30.c index 98a1bcd224..7edf1321fe 100644 --- a/arch/arm/mach-rockchip/px30/clk_px30.c +++ b/arch/arm/mach-rockchip/px30/clk_px30.c @@ -13,7 +13,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_px30_cru), devp); + DM_DRIVER_GET(rockchip_px30_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/px30/syscon_px30.c b/arch/arm/mach-rockchip/px30/syscon_px30.c index 4672bdbf00..37e88f5ccb 100644 --- a/arch/arm/mach-rockchip/px30/syscon_px30.c +++ b/arch/arm/mach-rockchip/px30/syscon_px30.c @@ -23,7 +23,7 @@ U_BOOT_DRIVER(syscon_px30) = { }; #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int px30_syscon_bind_of_platdata(struct udevice *dev) +static int px30_syscon_bind_of_plat(struct udevice *dev) { dev->driver_data = dev->driver->of_match->data; debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data); @@ -35,20 +35,20 @@ U_BOOT_DRIVER(rockchip_px30_pmu) = { .name = "rockchip_px30_pmu", .id = UCLASS_SYSCON, .of_match = px30_syscon_ids, - .bind = px30_syscon_bind_of_platdata, + .bind = px30_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_px30_pmugrf) = { .name = "rockchip_px30_pmugrf", .id = UCLASS_SYSCON, .of_match = px30_syscon_ids + 1, - .bind = px30_syscon_bind_of_platdata, + .bind = px30_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_px30_grf) = { .name = "rockchip_px30_grf", .id = UCLASS_SYSCON, .of_match = px30_syscon_ids + 2, - .bind = px30_syscon_bind_of_platdata, + .bind = px30_syscon_bind_of_plat, }; #endif diff --git a/arch/arm/mach-rockchip/rk3036/clk_rk3036.c b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c index 5d0def3b52..116dccd7b8 100644 --- a/arch/arm/mach-rockchip/rk3036/clk_rk3036.c +++ b/arch/arm/mach-rockchip/rk3036/clk_rk3036.c @@ -14,7 +14,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3036_cru), devp); + DM_DRIVER_GET(rockchip_rk3036_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3128/clk_rk3128.c b/arch/arm/mach-rockchip/rk3128/clk_rk3128.c index f9ce1f7234..a1b038c648 100644 --- a/arch/arm/mach-rockchip/rk3128/clk_rk3128.c +++ b/arch/arm/mach-rockchip/rk3128/clk_rk3128.c @@ -13,7 +13,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3128_cru), devp); + DM_DRIVER_GET(rockchip_rk3128_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3188/clk_rk3188.c b/arch/arm/mach-rockchip/rk3188/clk_rk3188.c index a0dcac3732..94d1d23e1f 100644 --- a/arch/arm/mach-rockchip/rk3188/clk_rk3188.c +++ b/arch/arm/mach-rockchip/rk3188/clk_rk3188.c @@ -14,7 +14,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3188_cru), devp); + DM_DRIVER_GET(rockchip_rk3188_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3188/syscon_rk3188.c b/arch/arm/mach-rockchip/rk3188/syscon_rk3188.c index ea7d7b5b1a..917ff37c0f 100644 --- a/arch/arm/mach-rockchip/rk3188/syscon_rk3188.c +++ b/arch/arm/mach-rockchip/rk3188/syscon_rk3188.c @@ -24,7 +24,7 @@ U_BOOT_DRIVER(syscon_rk3188) = { }; #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int rk3188_syscon_bind_of_platdata(struct udevice *dev) +static int rk3188_syscon_bind_of_plat(struct udevice *dev) { dev->driver_data = dev->driver->of_match->data; debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data); @@ -36,20 +36,20 @@ U_BOOT_DRIVER(rockchip_rk3188_noc) = { .name = "rockchip_rk3188_noc", .id = UCLASS_SYSCON, .of_match = rk3188_syscon_ids, - .bind = rk3188_syscon_bind_of_platdata, + .bind = rk3188_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3188_grf) = { .name = "rockchip_rk3188_grf", .id = UCLASS_SYSCON, .of_match = rk3188_syscon_ids + 1, - .bind = rk3188_syscon_bind_of_platdata, + .bind = rk3188_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3188_pmu) = { .name = "rockchip_rk3188_pmu", .id = UCLASS_SYSCON, .of_match = rk3188_syscon_ids + 2, - .bind = rk3188_syscon_bind_of_platdata, + .bind = rk3188_syscon_bind_of_plat, }; #endif diff --git a/arch/arm/mach-rockchip/rk322x/clk_rk322x.c b/arch/arm/mach-rockchip/rk322x/clk_rk322x.c index fc5abd736e..2e57672b24 100644 --- a/arch/arm/mach-rockchip/rk322x/clk_rk322x.c +++ b/arch/arm/mach-rockchip/rk322x/clk_rk322x.c @@ -13,7 +13,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk322x_cru), devp); + DM_DRIVER_GET(rockchip_rk322x_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c index e05bd06a8d..fb4c0891d0 100644 --- a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c +++ b/arch/arm/mach-rockchip/rk3288/clk_rk3288.c @@ -14,7 +14,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3288_cru), devp); + DM_DRIVER_GET(rockchip_rk3288_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c b/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c index e3da0a0194..9c1ae880c7 100644 --- a/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c +++ b/arch/arm/mach-rockchip/rk3288/syscon_rk3288.c @@ -25,7 +25,7 @@ U_BOOT_DRIVER(syscon_rk3288) = { }; #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int rk3288_syscon_bind_of_platdata(struct udevice *dev) +static int rk3288_syscon_bind_of_plat(struct udevice *dev) { dev->driver_data = dev->driver->of_match->data; debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data); @@ -37,27 +37,27 @@ U_BOOT_DRIVER(rockchip_rk3288_noc) = { .name = "rockchip_rk3288_noc", .id = UCLASS_SYSCON, .of_match = rk3288_syscon_ids, - .bind = rk3288_syscon_bind_of_platdata, + .bind = rk3288_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3288_grf) = { .name = "rockchip_rk3288_grf", .id = UCLASS_SYSCON, .of_match = rk3288_syscon_ids + 1, - .bind = rk3288_syscon_bind_of_platdata, + .bind = rk3288_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3288_sgrf) = { .name = "rockchip_rk3288_sgrf", .id = UCLASS_SYSCON, .of_match = rk3288_syscon_ids + 2, - .bind = rk3288_syscon_bind_of_platdata, + .bind = rk3288_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3288_pmu) = { .name = "rockchip_rk3288_pmu", .id = UCLASS_SYSCON, .of_match = rk3288_syscon_ids + 3, - .bind = rk3288_syscon_bind_of_platdata, + .bind = rk3288_syscon_bind_of_plat, }; #endif diff --git a/arch/arm/mach-rockchip/rk3308/clk_rk3308.c b/arch/arm/mach-rockchip/rk3308/clk_rk3308.c index 1feb237224..ccda53380c 100644 --- a/arch/arm/mach-rockchip/rk3308/clk_rk3308.c +++ b/arch/arm/mach-rockchip/rk3308/clk_rk3308.c @@ -13,7 +13,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3308_cru), devp); + DM_DRIVER_GET(rockchip_rk3308_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c index e5375514de..70c0eb6f98 100644 --- a/arch/arm/mach-rockchip/rk3328/clk_rk3328.c +++ b/arch/arm/mach-rockchip/rk3328/clk_rk3328.c @@ -12,7 +12,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3328_cru), devp); + DM_DRIVER_GET(rockchip_rk3328_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3368/clk_rk3368.c b/arch/arm/mach-rockchip/rk3368/clk_rk3368.c index 9a33c67bc9..b075319720 100644 --- a/arch/arm/mach-rockchip/rk3368/clk_rk3368.c +++ b/arch/arm/mach-rockchip/rk3368/clk_rk3368.c @@ -14,7 +14,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3368_cru), devp); + DM_DRIVER_GET(rockchip_rk3368_cru), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/rk3368/syscon_rk3368.c b/arch/arm/mach-rockchip/rk3368/syscon_rk3368.c index cba0dda3e8..dc2d831dd8 100644 --- a/arch/arm/mach-rockchip/rk3368/syscon_rk3368.c +++ b/arch/arm/mach-rockchip/rk3368/syscon_rk3368.c @@ -30,7 +30,7 @@ U_BOOT_DRIVER(syscon_rk3368) = { }; #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int rk3368_syscon_bind_of_platdata(struct udevice *dev) +static int rk3368_syscon_bind_of_plat(struct udevice *dev) { dev->driver_data = dev->driver->of_match->data; debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data); @@ -42,27 +42,27 @@ U_BOOT_DRIVER(rockchip_rk3368_grf) = { .name = "rockchip_rk3368_grf", .id = UCLASS_SYSCON, .of_match = rk3368_syscon_ids, - .bind = rk3368_syscon_bind_of_platdata, + .bind = rk3368_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3368_pmugrf) = { .name = "rockchip_rk3368_pmugrf", .id = UCLASS_SYSCON, .of_match = rk3368_syscon_ids + 1, - .bind = rk3368_syscon_bind_of_platdata, + .bind = rk3368_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3368_msch) = { .name = "rockchip_rk3368_msch", .id = UCLASS_SYSCON, .of_match = rk3368_syscon_ids + 2, - .bind = rk3368_syscon_bind_of_platdata, + .bind = rk3368_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3368_sgrf) = { .name = "rockchip_rk3368_sgrf", .id = UCLASS_SYSCON, .of_match = rk3368_syscon_ids + 3, - .bind = rk3368_syscon_bind_of_platdata, + .bind = rk3368_syscon_bind_of_plat, }; #endif diff --git a/arch/arm/mach-rockchip/rk3399/clk_rk3399.c b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c index d23a5e9435..9d9a837fc7 100644 --- a/arch/arm/mach-rockchip/rk3399/clk_rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/clk_rk3399.c @@ -14,7 +14,7 @@ static int rockchip_get_cruclk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(clk_rk3399), devp); + DM_DRIVER_GET(clk_rk3399), devp); } void *rockchip_get_cru(void) @@ -35,7 +35,7 @@ void *rockchip_get_cru(void) static int rockchip_get_pmucruclk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(rockchip_rk3399_pmuclk), devp); + DM_DRIVER_GET(rockchip_rk3399_pmuclk), devp); } void *rockchip_get_pmucru(void) diff --git a/arch/arm/mach-rockchip/rk3399/syscon_rk3399.c b/arch/arm/mach-rockchip/rk3399/syscon_rk3399.c index 690cbe7f27..b360ca7dde 100644 --- a/arch/arm/mach-rockchip/rk3399/syscon_rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/syscon_rk3399.c @@ -28,7 +28,7 @@ U_BOOT_DRIVER(syscon_rk3399) = { }; #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int rk3399_syscon_bind_of_platdata(struct udevice *dev) +static int rk3399_syscon_bind_of_plat(struct udevice *dev) { dev->driver_data = dev->driver->of_match->data; debug("syscon: %s %d\n", dev->name, (uint)dev->driver_data); @@ -40,34 +40,34 @@ U_BOOT_DRIVER(rockchip_rk3399_grf) = { .name = "rockchip_rk3399_grf", .id = UCLASS_SYSCON, .of_match = rk3399_syscon_ids, - .bind = rk3399_syscon_bind_of_platdata, + .bind = rk3399_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3399_pmugrf) = { .name = "rockchip_rk3399_pmugrf", .id = UCLASS_SYSCON, .of_match = rk3399_syscon_ids + 1, - .bind = rk3399_syscon_bind_of_platdata, + .bind = rk3399_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3399_pmusgrf) = { .name = "rockchip_rk3399_pmusgrf", .id = UCLASS_SYSCON, .of_match = rk3399_syscon_ids + 2, - .bind = rk3399_syscon_bind_of_platdata, + .bind = rk3399_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3399_cic) = { .name = "rockchip_rk3399_cic", .id = UCLASS_SYSCON, .of_match = rk3399_syscon_ids + 3, - .bind = rk3399_syscon_bind_of_platdata, + .bind = rk3399_syscon_bind_of_plat, }; U_BOOT_DRIVER(rockchip_rk3399_pmu) = { .name = "rockchip_rk3399_pmu", .id = UCLASS_SYSCON, .of_match = rk3399_syscon_ids + 4, - .bind = rk3399_syscon_bind_of_platdata, + .bind = rk3399_syscon_bind_of_plat, }; #endif diff --git a/arch/arm/mach-rockchip/rv1108/clk_rv1108.c b/arch/arm/mach-rockchip/rv1108/clk_rv1108.c index b37ae1c494..44b53c407a 100644 --- a/arch/arm/mach-rockchip/rv1108/clk_rv1108.c +++ b/arch/arm/mach-rockchip/rv1108/clk_rv1108.c @@ -14,7 +14,7 @@ int rockchip_get_clk(struct udevice **devp) { return uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(clk_rv1108), devp); + DM_DRIVER_GET(clk_rv1108), devp); } void *rockchip_get_cru(void) diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c index 94673f34c9..8ccd5afb56 100644 --- a/arch/arm/mach-rockchip/spl-boot-order.c +++ b/arch/arm/mach-rockchip/spl-boot-order.c @@ -46,7 +46,7 @@ static int spl_node_to_boot_device(int node) dev; device_find_next_child(&dev)) { if (device_get_uclass_id(dev) == UCLASS_BLK) { - desc = dev_get_uclass_platdata(dev); + desc = dev_get_uclass_plat(dev); break; } } @@ -99,7 +99,7 @@ __weak const char *board_spl_was_booted_from(void) void board_boot_order(u32 *spl_boot_list) { - /* In case of no fdt (or only platdata), use spl_boot_device() */ + /* In case of no fdt (or only plat), use spl_boot_device() */ if (!CONFIG_IS_ENABLED(OF_CONTROL) || CONFIG_IS_ENABLED(OF_PLATDATA)) { spl_boot_list[0] = spl_boot_device(); return; diff --git a/arch/arm/mach-snapdragon/clock-snapdragon.c b/arch/arm/mach-snapdragon/clock-snapdragon.c index 69d65c82e3..fbe0b5212f 100644 --- a/arch/arm/mach-snapdragon/clock-snapdragon.c +++ b/arch/arm/mach-snapdragon/clock-snapdragon.c @@ -143,6 +143,6 @@ U_BOOT_DRIVER(clk_msm) = { .id = UCLASS_CLK, .of_match = msm_clk_ids, .ops = &msm_clk_ops, - .priv_auto_alloc_size = sizeof(struct msm_clk_priv), + .priv_auto = sizeof(struct msm_clk_priv), .probe = msm_clk_probe, }; diff --git a/arch/arm/mach-snapdragon/pinctrl-snapdragon.c b/arch/arm/mach-snapdragon/pinctrl-snapdragon.c index 4c2af21308..e6b87c3573 100644 --- a/arch/arm/mach-snapdragon/pinctrl-snapdragon.c +++ b/arch/arm/mach-snapdragon/pinctrl-snapdragon.c @@ -123,7 +123,7 @@ U_BOOT_DRIVER(pinctrl_snapdraon) = { .name = "pinctrl_msm", .id = UCLASS_PINCTRL, .of_match = msm_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct msm_pinctrl_priv), + .priv_auto = sizeof(struct msm_pinctrl_priv), .ops = &msm_pinctrl_ops, .probe = msm_pinctrl_probe, }; diff --git a/arch/arm/mach-socfpga/clock_manager_agilex.c b/arch/arm/mach-socfpga/clock_manager_agilex.c index 6188a8c3d2..a960176da7 100644 --- a/arch/arm/mach-socfpga/clock_manager_agilex.c +++ b/arch/arm/mach-socfpga/clock_manager_agilex.c @@ -24,7 +24,7 @@ static ulong cm_get_rate_dm(u32 id) int ret; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(socfpga_agilex_clk), + DM_DRIVER_GET(socfpga_agilex_clk), &dev); if (ret) return 0; diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c index a9b9bd0902..84e0bddcd4 100644 --- a/arch/arm/mach-stm32mp/bsec.c +++ b/arch/arm/mach-stm32mp/bsec.c @@ -280,13 +280,13 @@ static int bsec_program_otp(long base, u32 val, u32 otp) } /* BSEC MISC driver *******************************************************/ -struct stm32mp_bsec_platdata { +struct stm32mp_bsec_plat { u32 base; }; static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp) { - struct stm32mp_bsec_platdata *plat; + struct stm32mp_bsec_plat *plat; u32 tmp_data = 0; int ret; @@ -295,7 +295,7 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp) STM32_SMC_READ_OTP, otp, 0, val); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); /* read current shadow value */ ret = bsec_read_shadow(plat->base, &tmp_data, otp); @@ -319,21 +319,21 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp) static int stm32mp_bsec_read_shadow(struct udevice *dev, u32 *val, u32 otp) { - struct stm32mp_bsec_platdata *plat; + struct stm32mp_bsec_plat *plat; if (IS_ENABLED(CONFIG_TFABOOT)) return stm32_smc(STM32_SMC_BSEC, STM32_SMC_READ_SHADOW, otp, 0, val); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); return bsec_read_shadow(plat->base, val, otp); } static int stm32mp_bsec_read_lock(struct udevice *dev, u32 *val, u32 otp) { - struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev); + struct stm32mp_bsec_plat *plat = dev_get_plat(dev); /* return OTP permanent write lock status */ *val = bsec_read_lock(plat->base + BSEC_WRLOCK_OFF, otp); @@ -343,14 +343,14 @@ static int stm32mp_bsec_read_lock(struct udevice *dev, u32 *val, u32 otp) static int stm32mp_bsec_write_otp(struct udevice *dev, u32 val, u32 otp) { - struct stm32mp_bsec_platdata *plat; + struct stm32mp_bsec_plat *plat; if (IS_ENABLED(CONFIG_TFABOOT)) return stm32_smc_exec(STM32_SMC_BSEC, STM32_SMC_PROG_OTP, otp, val); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); return bsec_program_otp(plat->base, val, otp); @@ -358,14 +358,14 @@ static int stm32mp_bsec_write_otp(struct udevice *dev, u32 val, u32 otp) static int stm32mp_bsec_write_shadow(struct udevice *dev, u32 val, u32 otp) { - struct stm32mp_bsec_platdata *plat; + struct stm32mp_bsec_plat *plat; if (IS_ENABLED(CONFIG_TFABOOT)) return stm32_smc_exec(STM32_SMC_BSEC, STM32_SMC_WRITE_SHADOW, otp, val); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); return bsec_write_shadow(plat->base, val, otp); } @@ -473,9 +473,9 @@ static const struct misc_ops stm32mp_bsec_ops = { .write = stm32mp_bsec_write, }; -static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev) +static int stm32mp_bsec_of_to_plat(struct udevice *dev) { - struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev); + struct stm32mp_bsec_plat *plat = dev_get_plat(dev); plat->base = (u32)dev_read_addr_ptr(dev); @@ -485,7 +485,7 @@ static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev) static int stm32mp_bsec_probe(struct udevice *dev) { int otp; - struct stm32mp_bsec_platdata *plat; + struct stm32mp_bsec_plat *plat; /* * update unlocked shadow for OTP cleared by the rom code @@ -493,7 +493,7 @@ static int stm32mp_bsec_probe(struct udevice *dev) */ if (!IS_ENABLED(CONFIG_TFABOOT) && !IS_ENABLED(CONFIG_SPL_BUILD)) { - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); for (otp = 57; otp <= BSEC_OTP_MAX_VALUE; otp++) if (!bsec_read_SR_lock(plat->base, otp)) @@ -512,8 +512,8 @@ U_BOOT_DRIVER(stm32mp_bsec) = { .name = "stm32mp_bsec", .id = UCLASS_MISC, .of_match = stm32mp_bsec_ids, - .ofdata_to_platdata = stm32mp_bsec_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct stm32mp_bsec_platdata), + .of_to_plat = stm32mp_bsec_of_to_plat, + .plat_auto = sizeof(struct stm32mp_bsec_plat), .ops = &stm32mp_bsec_ops, .probe = stm32mp_bsec_probe, }; @@ -521,17 +521,17 @@ U_BOOT_DRIVER(stm32mp_bsec) = { bool bsec_dbgswenable(void) { struct udevice *dev; - struct stm32mp_bsec_platdata *plat; + struct stm32mp_bsec_plat *plat; int ret; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), &dev); + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret || !dev) { pr_debug("bsec driver not available\n"); return false; } - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); if (readl(plat->base + BSEC_DENABLE_OFF) & BSEC_DENABLE_DBGSWENABLE) return true; diff --git a/arch/arm/mach-stm32mp/cmd_stm32key.c b/arch/arm/mach-stm32mp/cmd_stm32key.c index f191085a12..544bab3848 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32key.c +++ b/arch/arm/mach-stm32mp/cmd_stm32key.c @@ -31,7 +31,7 @@ static void fuse_hash_value(u32 addr, bool print) int i, ret; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) { pr_err("Can't find stm32mp_bsec driver\n"); diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c index a777827c55..fc9a2af545 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c @@ -1340,7 +1340,7 @@ int stm32prog_pmic_read(struct stm32prog_data *data, u32 offset, u8 *buffer, pr_debug("%s: %x %lx\n", __func__, offset, *size); ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; @@ -1351,7 +1351,7 @@ int stm32prog_pmic_read(struct stm32prog_data *data, u32 offset, u8 *buffer, memset(data->pmic_part, 0, PMIC_SIZE); ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; @@ -1389,7 +1389,7 @@ int stm32prog_pmic_start(struct stm32prog_data *data) } ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c index 1520c6eaed..29c0d92195 100644 --- a/arch/arm/mach-stm32mp/cpu.c +++ b/arch/arm/mach-stm32mp/cpu.c @@ -318,7 +318,7 @@ static u32 get_otp(int index, int shift, int mask) u32 otp = 0; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (!ret) @@ -563,7 +563,7 @@ __weak int setup_mac_address(void) return 0; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) return ret; @@ -601,7 +601,7 @@ static int setup_serial_number(void) return 0; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) return ret; diff --git a/arch/arm/mach-stm32mp/pwr_regulator.c b/arch/arm/mach-stm32mp/pwr_regulator.c index 900dee4c38..766ed95f1a 100644 --- a/arch/arm/mach-stm32mp/pwr_regulator.c +++ b/arch/arm/mach-stm32mp/pwr_regulator.c @@ -9,6 +9,7 @@ #include <syscon.h> #include <asm/io.h> #include <dm/device_compat.h> +#include <dm/device-internal.h> #include <linux/bitops.h> #include <linux/err.h> #include <power/pmic.h> @@ -59,7 +60,7 @@ static int stm32mp_pwr_read(struct udevice *dev, uint reg, uint8_t *buff, return 0; } -static int stm32mp_pwr_ofdata_to_platdata(struct udevice *dev) +static int stm32mp_pwr_of_to_plat(struct udevice *dev) { struct stm32mp_pwr_priv *priv = dev_get_priv(dev); @@ -80,7 +81,7 @@ static int stm32mp_pwr_bind(struct udevice *dev) { int children; - children = pmic_bind_children(dev, dev->node, pwr_children_info); + children = pmic_bind_children(dev, dev_ofnode(dev), pwr_children_info); if (!children) dev_dbg(dev, "no child found\n"); @@ -103,8 +104,8 @@ U_BOOT_DRIVER(stm32mp_pwr_pmic) = { .of_match = stm32mp_pwr_ids, .bind = stm32mp_pwr_bind, .ops = &stm32mp_pwr_ops, - .ofdata_to_platdata = stm32mp_pwr_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct stm32mp_pwr_priv), + .of_to_plat = stm32mp_pwr_of_to_plat, + .priv_auto = sizeof(struct stm32mp_pwr_priv), }; static const struct stm32mp_pwr_reg_info stm32mp_pwr_reg11 = { @@ -135,9 +136,9 @@ static const struct stm32mp_pwr_reg_info *stm32mp_pwr_reg_infos[] = { static int stm32mp_pwr_regulator_probe(struct udevice *dev) { const struct stm32mp_pwr_reg_info **p = stm32mp_pwr_reg_infos; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); while (*p) { int rc; @@ -165,16 +166,16 @@ static int stm32mp_pwr_regulator_probe(struct udevice *dev) } uc_pdata->type = REGULATOR_TYPE_FIXED; - dev->priv = (void *)*p; + dev_set_priv(dev, (void *)*p); return 0; } static int stm32mp_pwr_regulator_set_value(struct udevice *dev, int uV) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; @@ -188,9 +189,9 @@ static int stm32mp_pwr_regulator_set_value(struct udevice *dev, int uV) static int stm32mp_pwr_regulator_get_value(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 49ef217f08..11e6445192 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1016,4 +1016,15 @@ config PINEPHONE_DT_SELECTION Enable this option to automatically select the device tree for the correct PinePhone hardware revision during boot. +config BLUETOOTH_DT_DEVICE_FIXUP + string "Fixup the Bluetooth controller address" + default "" + help + This option specifies the DT compatible name of the Bluetooth + controller for which to set the "local-bd-address" property. + Set this option if your device ships with the Bluetooth controller + default address. + The used address is "bdaddr" if set, and "ethaddr" with the LSB + flipped elsewise. + endif diff --git a/arch/arm/mach-sunxi/dram_sun50i_h6.c b/arch/arm/mach-sunxi/dram_sun50i_h6.c index 9e34da4747..32ec0bc4cd 100644 --- a/arch/arm/mach-sunxi/dram_sun50i_h6.c +++ b/arch/arm/mach-sunxi/dram_sun50i_h6.c @@ -37,9 +37,9 @@ static void mctl_sys_init(struct dram_para *para); static void mctl_com_init(struct dram_para *para); -static void mctl_channel_init(struct dram_para *para); +static bool mctl_channel_init(struct dram_para *para); -static void mctl_core_init(struct dram_para *para) +static bool mctl_core_init(struct dram_para *para) { mctl_sys_init(para); mctl_com_init(para); @@ -51,7 +51,7 @@ static void mctl_core_init(struct dram_para *para) default: panic("Unsupported DRAM type!"); }; - mctl_channel_init(para); + return mctl_channel_init(para); } /* PHY initialisation */ @@ -411,7 +411,7 @@ static void mctl_bit_delay_set(struct dram_para *para) } } -static void mctl_channel_init(struct dram_para *para) +static bool mctl_channel_init(struct dram_para *para) { struct sunxi_mctl_com_reg * const mctl_com = (struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE; @@ -528,46 +528,15 @@ static void mctl_channel_init(struct dram_para *para) clrbits_le32(&mctl_phy->dx[i].gcr[3], ~0x3ffff); udelay(10); - if (readl(&mctl_phy->pgsr[0]) & 0x400000) - { - /* Check for single rank and optionally half DQ. */ - if ((readl(&mctl_phy->dx[0].rsr[0]) & 0x3) == 2 && - (readl(&mctl_phy->dx[1].rsr[0]) & 0x3) == 2) { - para->ranks = 1; - - if ((readl(&mctl_phy->dx[2].rsr[0]) & 0x3) != 2 || - (readl(&mctl_phy->dx[3].rsr[0]) & 0x3) != 2) - para->bus_full_width = 0; - - /* Restart DRAM initialization from scratch. */ - mctl_core_init(para); - return; - } - - /* - * Check for dual rank and half DQ. NOTE: This combination - * is highly unlikely and was not tested. Condition is the - * same as in libdram, though. - */ - if ((readl(&mctl_phy->dx[0].rsr[0]) & 0x3) == 0 && - (readl(&mctl_phy->dx[1].rsr[0]) & 0x3) == 0) { - para->bus_full_width = 0; - - /* Restart DRAM initialization from scratch. */ - mctl_core_init(para); - return; - } - - panic("This DRAM setup is currently not supported.\n"); - } - if (readl(&mctl_phy->pgsr[0]) & 0xff00000) { /* Oops! There's something wrong! */ debug("PLL = %x\n", readl(0x3001010)); debug("DRAM PHY PGSR0 = %x\n", readl(&mctl_phy->pgsr[0])); for (i = 0; i < 4; i++) debug("DRAM PHY DX%dRSR0 = %x\n", i, readl(&mctl_phy->dx[i].rsr[0])); - panic("Error while initializing DRAM PHY!\n"); + debug("Error while initializing DRAM PHY!\n"); + + return false; } if (sunxi_dram_is_lpddr(para->type)) @@ -582,13 +551,59 @@ static void mctl_channel_init(struct dram_para *para) writel(0xffffffff, &mctl_com->maer0); writel(0x7ff, &mctl_com->maer1); writel(0xffff, &mctl_com->maer2); + + return true; +} + +static void mctl_auto_detect_rank_width(struct dram_para *para) +{ + /* this is minimum size that it's supported */ + para->cols = 8; + para->rows = 13; + + /* + * Previous versions of this driver tried to auto detect the rank + * and width by looking at controller registers. However this proved + * to be not reliable, so this approach here is the more robust + * solution. Check the git history for details. + * + * Strategy here is to test most demanding combination first and least + * demanding last, otherwise HW might not be fully utilized. For + * example, half bus width and rank = 1 combination would also work + * on HW with full bus width and rank = 2, but only 1/4 RAM would be + * visible. + */ + + debug("testing 32-bit width, rank = 2\n"); + para->bus_full_width = 1; + para->ranks = 2; + if (mctl_core_init(para)) + return; + + debug("testing 32-bit width, rank = 1\n"); + para->bus_full_width = 1; + para->ranks = 1; + if (mctl_core_init(para)) + return; + + debug("testing 16-bit width, rank = 2\n"); + para->bus_full_width = 0; + para->ranks = 2; + if (mctl_core_init(para)) + return; + + debug("testing 16-bit width, rank = 1\n"); + para->bus_full_width = 0; + para->ranks = 1; + if (mctl_core_init(para)) + return; + + panic("This DRAM setup is currently not supported.\n"); } static void mctl_auto_detect_dram_size(struct dram_para *para) { /* TODO: non-(LP)DDR3 */ - /* Detect rank number and half DQ by the code in mctl_channel_init. */ - mctl_core_init(para); /* detect row address bits */ para->cols = 8; @@ -652,10 +667,6 @@ unsigned long sunxi_dram_init(void) (struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE; struct dram_para para = { .clk = CONFIG_DRAM_CLK, - .ranks = 2, - .cols = 11, - .rows = 14, - .bus_full_width = 1, #ifdef CONFIG_SUNXI_DRAM_H6_LPDDR3 .type = SUNXI_DRAM_TYPE_LPDDR3, .dx_read_delays = SUN50I_H6_LPDDR3_DX_READ_DELAYS, @@ -673,6 +684,7 @@ unsigned long sunxi_dram_init(void) setbits_le32(0x7010310, BIT(8)); clrbits_le32(0x7010318, 0x3f); + mctl_auto_detect_rank_width(¶); mctl_auto_detect_dram_size(¶); mctl_core_init(¶); diff --git a/arch/arm/mach-tegra/board.c b/arch/arm/mach-tegra/board.c index 03faacbd57..9de9836c8d 100644 --- a/arch/arm/mach-tegra/board.c +++ b/arch/arm/mach-tegra/board.c @@ -257,14 +257,14 @@ void board_init_uart_f(void) } #if !CONFIG_IS_ENABLED(OF_CONTROL) -static struct ns16550_platdata ns16550_com1_pdata = { +static struct ns16550_plat ns16550_com1_pdata = { .base = CONFIG_SYS_NS16550_COM1, .reg_shift = 2, .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE(ns16550_com1) = { +U_BOOT_DRVINFO(ns16550_com1) = { "ns16550_serial", &ns16550_com1_pdata }; #endif diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c index 48c4f32d6f..8569ad7c6f 100644 --- a/arch/arm/mach-tegra/board2.c +++ b/arch/arm/mach-tegra/board2.c @@ -42,7 +42,7 @@ DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_SPL_BUILD /* TODO(sjg@chromium.org): Remove once SPL supports device tree */ -U_BOOT_DEVICE(tegra_gpios) = { +U_BOOT_DRVINFO(tegra_gpios) = { "gpio_tegra" }; #endif diff --git a/arch/arm/mach-uniphier/micro-support-card.c b/arch/arm/mach-uniphier/micro-support-card.c index dbd156ffce..95780f79c2 100644 --- a/arch/arm/mach-uniphier/micro-support-card.c +++ b/arch/arm/mach-uniphier/micro-support-card.c @@ -95,7 +95,7 @@ void support_card_init(void) /* The system bus must be initialized for access to the support card. */ ret = uclass_get_device_by_driver(UCLASS_SIMPLE_BUS, - DM_GET_DRIVER(uniphier_system_bus_driver), + DM_DRIVER_GET(uniphier_system_bus_driver), &dev); if (ret) return; diff --git a/arch/arm/mach-zynq/clk.c b/arch/arm/mach-zynq/clk.c index 1ace117fc8..856047613c 100644 --- a/arch/arm/mach-zynq/clk.c +++ b/arch/arm/mach-zynq/clk.c @@ -40,7 +40,7 @@ int set_cpu_clk_info(void) int i, ret; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(zynq_clk), &dev); + DM_DRIVER_GET(zynq_clk), &dev); if (ret) return ret; @@ -75,7 +75,7 @@ int soc_clk_dump(void) int i, ret; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(zynq_clk), &dev); + DM_DRIVER_GET(zynq_clk), &dev); if (ret) return ret; diff --git a/arch/arm/mach-zynq/timer.c b/arch/arm/mach-zynq/timer.c index cc0e24cbfe..37193157d9 100644 --- a/arch/arm/mach-zynq/timer.c +++ b/arch/arm/mach-zynq/timer.c @@ -68,7 +68,7 @@ int timer_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(zynq_clk), &dev); + DM_DRIVER_GET(zynq_clk), &dev); if (ret) return ret; diff --git a/arch/m68k/include/asm/spl.h b/arch/m68k/include/asm/spl.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/arch/m68k/include/asm/spl.h diff --git a/arch/mips/mach-mtmips/mt7628/init.c b/arch/mips/mach-mtmips/mt7628/init.c index 77d1f2ea0d..33538647a2 100644 --- a/arch/mips/mach-mtmips/mt7628/init.c +++ b/arch/mips/mach-mtmips/mt7628/init.c @@ -74,7 +74,7 @@ int print_cpuinfo(void) ddr ? "" : "2", chipmode & 0x01 ? 4 : 3, chipmode & 0x02 ? "XTAL" : "CPLL"); - ret = uclass_get_device_by_driver(UCLASS_CLK, DM_GET_DRIVER(mt7628_clk), + ret = uclass_get_device_by_driver(UCLASS_CLK, DM_DRIVER_GET(mt7628_clk), &clkdev); if (ret) return ret; diff --git a/arch/nds32/include/asm/spl.h b/arch/nds32/include/asm/spl.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/arch/nds32/include/asm/spl.h diff --git a/arch/nios2/include/asm/spl.h b/arch/nios2/include/asm/spl.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/arch/nios2/include/asm/spl.h diff --git a/arch/riscv/include/asm/arch-fu540/gpio.h b/arch/riscv/include/asm/arch-fu540/gpio.h index 0d16c59ca6..b87282b974 100644 --- a/arch/riscv/include/asm/arch-fu540/gpio.h +++ b/arch/riscv/include/asm/arch-fu540/gpio.h @@ -28,7 +28,7 @@ enum gpio_state { }; /* Details about a GPIO bank */ -struct sifive_gpio_platdata { +struct sifive_gpio_plat { void *base; /* address of registers in physical memory */ }; diff --git a/arch/riscv/include/asm/arch-generic/gpio.h b/arch/riscv/include/asm/arch-generic/gpio.h index dfcb753051..b1f403027d 100644 --- a/arch/riscv/include/asm/arch-generic/gpio.h +++ b/arch/riscv/include/asm/arch-generic/gpio.h @@ -28,7 +28,7 @@ enum gpio_state { }; /* Details about a GPIO bank */ -struct sifive_gpio_platdata { +struct sifive_gpio_plat { void *base; /* address of registers in physical memory */ }; diff --git a/arch/riscv/lib/sifive_clint.c b/arch/riscv/lib/sifive_clint.c index c8079dc510..cfa288a01a 100644 --- a/arch/riscv/lib/sifive_clint.c +++ b/arch/riscv/lib/sifive_clint.c @@ -25,7 +25,7 @@ int riscv_init_ipi(void) struct udevice *dev; ret = uclass_get_device_by_driver(UCLASS_TIMER, - DM_GET_DRIVER(sifive_clint), &dev); + DM_DRIVER_GET(sifive_clint), &dev); if (ret) return ret; diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 65f988e736..f83282d9d5 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -51,6 +51,15 @@ config HOST_64BIT endchoice +config SANDBOX_CRASH_RESET + bool "Reset on crash" + help + If an illegal instruction or an illegal memory access occurs, the + sandbox by default writes a crash dump and exits. If you set this + flag, the sandbox is reset instead. This may be useful when running + test suites like the UEFI self certification test which continue + with the next test after a crash. + config SANDBOX_BITS_PER_LONG int default 32 if HOST_32BIT diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index bac96447d5..de7fe7f391 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -5,7 +5,7 @@ # (C) Copyright 2000-2003 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. -obj-y := cpu.o state.o +obj-y := cache.o cpu.o state.o extra-y := start.o os.o extra-$(CONFIG_SANDBOX_SDL) += sdl.o obj-$(CONFIG_SPL_BUILD) += spl.o diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c new file mode 100644 index 0000000000..46c62c0b44 --- /dev/null +++ b/arch/sandbox/cpu/cache.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020, Heinrich Schuchardt <xypron.glpk@gmx.de> + */ + +#include <common.h> +#include <cpu_func.h> +#include <asm/state.h> + +void flush_cache(unsigned long addr, unsigned long size) +{ + /* Clang uses (char *) parameters, GCC (void *) */ + __builtin___clear_cache((void *)addr, (void *)(addr + size)); +} + +void invalidate_icache_all(void) +{ + struct sandbox_state *state = state_get_current(); + + /* Clang uses (char *) parameters, GCC (void *) */ + __builtin___clear_cache((void *)state->ram_buf, + (void *)(state->ram_buf + state->ram_size)); +} diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 0d8efd83f6..80996a91ce 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -3,6 +3,8 @@ * Copyright (c) 2011 The Chromium OS Authors. */ +#define _GNU_SOURCE + #include <dirent.h> #include <errno.h> #include <fcntl.h> @@ -15,11 +17,13 @@ #include <string.h> #include <termios.h> #include <time.h> +#include <ucontext.h> #include <unistd.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> +#include <linux/compiler_attributes.h> #include <linux/types.h> #include <asm/getopt.h> @@ -191,6 +195,42 @@ static void os_sigint_handler(int sig) raise(SIGINT); } +static void os_signal_handler(int sig, siginfo_t *info, void *con) +{ + ucontext_t __maybe_unused *context = con; + unsigned long pc; + +#if defined(__x86_64__) + pc = context->uc_mcontext.gregs[REG_RIP]; +#elif defined(__aarch64__) + pc = context->uc_mcontext.pc; +#elif defined(__riscv) + pc = context->uc_mcontext.__gregs[REG_PC]; +#else + const char msg[] = + "\nUnsupported architecture, cannot read program counter\n"; + + os_write(1, msg, sizeof(msg)); + pc = 0; +#endif + + os_signal_action(sig, pc); +} + +int os_setup_signal_handlers(void) +{ + struct sigaction act; + + act.sa_sigaction = os_signal_handler; + sigemptyset(&act.sa_mask); + act.sa_flags = SA_SIGINFO | SA_NODEFER; + if (sigaction(SIGILL, &act, NULL) || + sigaction(SIGBUS, &act, NULL) || + sigaction(SIGSEGV, &act, NULL)) + return -1; + return 0; +} + /* Put tty into raw mode so <tab> and <ctrl+c> work */ void os_tty_raw(int fd, bool allow_sigs) { @@ -750,6 +790,11 @@ int os_find_u_boot(char *fname, int maxlen) int os_spl_to_uboot(const char *fname) { + struct sandbox_state *state = state_get_current(); + + printf("%s\n", __func__); + /* U-Boot will delete ram buffer after read: "--rm_memory"*/ + state->ram_buf_rm = true; return os_jump_to_file(fname); } diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index a03e5aa0b3..8322ed7a1f 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -6,6 +6,7 @@ #include <common.h> #include <command.h> #include <dm/root.h> +#include <efi_loader.h> #include <errno.h> #include <init.h> #include <os.h> @@ -406,6 +407,15 @@ void state_show(struct sandbox_state *state) printf("\n"); } +void __efi_runtime EFIAPI efi_reset_system( + enum efi_reset_type reset_type, + efi_status_t reset_status, + unsigned long data_size, void *reset_data) +{ + os_fd_restore(); + os_relaunch(os_argv); +} + void sandbox_reset(void) { /* Do this here while it still has an effect */ @@ -447,10 +457,21 @@ int main(int argc, char *argv[]) if (os_parse_args(state, argc, argv)) return 1; + /* Remove old memory file if required */ + if (state->ram_buf_rm && state->ram_buf_fname) { + os_unlink(state->ram_buf_fname); + state->write_ram_buf = false; + state->ram_buf_fname = NULL; + } + ret = sandbox_read_state(state, state->state_fname); if (ret) goto err; + ret = os_setup_signal_handlers(); + if (ret) + goto err; + #if CONFIG_VAL(SYS_MALLOC_F_LEN) gd->malloc_base = CONFIG_MALLOC_F_ADDR; #endif diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 59f37fab0b..b2901b7a8c 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -415,10 +415,6 @@ int state_uninit(void) } } - /* Remove old memory file if required */ - if (state->ram_buf_rm && state->ram_buf_fname) - os_unlink(state->ram_buf_fname); - /* Delete this at the last moment so as not to upset gdb too much */ if (state->jumped_fname) os_unlink(state->jumped_fname); diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index 8b50a40289..a8938a3acc 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -41,7 +41,7 @@ cros_ec: cros-ec { reg = <0 0>; - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; compatible = "google,cros-ec-sandbox"; }; @@ -83,7 +83,7 @@ }; spi: spi@0 { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; #address-cells = <1>; #size-cells = <0>; reg = <0 0>; diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index 81cdc55b0d..d842f02176 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -56,7 +56,7 @@ }; gpio_a: gpios@0 { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; gpio-controller; compatible = "sandbox,gpio"; #gpio-cells = <1>; @@ -65,7 +65,7 @@ }; gpio_b: gpios@1 { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; gpio-controller; compatible = "sandbox,gpio"; #gpio-cells = <2>; @@ -120,7 +120,7 @@ }; lcd { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; compatible = "sandbox,lcd-sdl"; xres = <1366>; yres = <768>; @@ -209,7 +209,7 @@ spi@0 { firmware_storage_spi: flash@0 { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; reg = <0>; compatible = "spansion,m25p16", "jedec,spi-nor"; spi-max-frequency = <40000000>; @@ -248,11 +248,6 @@ stringarray = "one"; }; - spl-test4 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test.2"; - }; - spl-test5 { u-boot,dm-tpl; compatible = "sandbox,spl-test"; @@ -283,7 +278,6 @@ }; tpm { - u-boot,dm-pre-reloc; compatible = "google,sandbox-tpm"; }; @@ -420,6 +414,6 @@ }; keyboard-controller { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; }; }; diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index f3b766271d..f86cd0d3b2 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -33,14 +33,16 @@ testfdt6 = "/e-test"; testbus3 = "/some-bus"; testfdt0 = "/some-bus/c-test@0"; - testfdt1 = "/some-bus/c-test@1"; + testfdt12 = "/some-bus/c-test@1"; testfdt3 = "/b-test"; testfdt5 = "/some-bus/c-test@5"; testfdt8 = "/a-test"; + testfdtm1 = &testfdtm1; fdt-dummy0 = "/translation-test@8000/dev@0,0"; fdt-dummy1 = "/translation-test@8000/dev@1,100"; fdt-dummy2 = "/translation-test@8000/dev@2,200"; fdt-dummy3 = "/translation-test@8000/noxlatebus@3,300/dev@42"; + fdt-dummy4 = "/translation-test@8000/xlatebus@4,400/devs/dev@19"; usb0 = &usb_0; usb1 = &usb_1; usb2 = &usb_2; @@ -140,6 +142,52 @@ <&muxcontroller1>; mux-control-names = "mux0", "mux1", "mux2", "mux3", "mux4"; mux-syscon = <&syscon3>; + display-timings { + timing0: 240x320 { + clock-frequency = <6500000>; + hactive = <240>; + vactive = <320>; + hfront-porch = <6>; + hback-porch = <7>; + hsync-len = <1>; + vback-porch = <5>; + vfront-porch = <8>; + vsync-len = <2>; + hsync-active = <1>; + vsync-active = <0>; + de-active = <1>; + pixelclk-active = <1>; + interlaced; + doublescan; + doubleclk; + }; + timing1: 480x800 { + clock-frequency = <9000000>; + hactive = <480>; + vactive = <800>; + hfront-porch = <10>; + hback-porch = <59>; + hsync-len = <12>; + vback-porch = <15>; + vfront-porch = <17>; + vsync-len = <16>; + hsync-active = <0>; + vsync-active = <1>; + de-active = <0>; + pixelclk-active = <0>; + }; + timing2: 800x480 { + clock-frequency = <33500000>; + hactive = <800>; + vactive = <480>; + hback-porch = <89>; + hfront-porch = <164>; + vback-porch = <23>; + vfront-porch = <10>; + hsync-len = <11>; + vsync-len = <13>; + }; + }; }; junk { @@ -864,13 +912,21 @@ #size-cells = <0>; reg = <0 1>; compatible = "sandbox,spi"; - cs-gpios = <0>, <&gpio_a 0>; + cs-gpios = <0>, <0>, <&gpio_a 0>; spi.bin@0 { reg = <0>; compatible = "spansion,m25p16", "jedec,spi-nor"; spi-max-frequency = <40000000>; sandbox,filename = "spi.bin"; }; + spi.bin@1 { + reg = <1>; + compatible = "spansion,m25p16", "jedec,spi-nor"; + spi-max-frequency = <50000000>; + sandbox,filename = "spi.bin"; + spi-cpol; + spi-cpha; + }; }; syscon0: syscon@0 { @@ -917,6 +973,18 @@ idle-state = <0xabcd>; }; + testfdtm0 { + compatible = "denx,u-boot-fdtm-test"; + }; + + testfdtm1: testfdtm1 { + compatible = "denx,u-boot-fdtm-test"; + }; + + testfdtm2 { + compatible = "denx,u-boot-fdtm-test"; + }; + timer@0 { compatible = "sandbox,timer"; clock-frequency = <1000000>; @@ -1061,6 +1129,7 @@ 1 0x100 0x9000 0x1000 2 0x200 0xA000 0x1000 3 0x300 0xB000 0x1000 + 4 0x400 0xC000 0x1000 >; dma-ranges = <0 0x000 0x10000000 0x1000 @@ -1097,6 +1166,25 @@ reg = <0x42>; }; }; + + xlatebus@4,400 { + compatible = "sandbox,zero-size-cells-bus"; + reg = <4 0x400 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 4 0x400 0x1000>; + + devs { + #address-cells = <1>; + #size-cells = <0>; + + dev@19 { + compatible = "denx,u-boot-fdt-dummy"; + reg = <0x19>; + }; + }; + }; + }; osd { diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h index c184c4bffc..0294baee27 100644 --- a/arch/sandbox/include/asm/clk.h +++ b/arch/sandbox/include/asm/clk.h @@ -106,6 +106,15 @@ int sandbox_clk_test_get_bulk(struct udevice *dev); */ ulong sandbox_clk_test_get_rate(struct udevice *dev, int id); /** + * sandbox_clk_test_round_rate - Ask the sandbox clock test device to round a + * clock's rate. + * + * @dev: The sandbox clock test (client) device. + * @id: The test device's clock ID to configure. + * @return: The rounded rate of the clock. + */ +ulong sandbox_clk_test_round_rate(struct udevice *dev, int id, ulong rate); +/** * sandbox_clk_test_set_rate - Ask the sandbox clock test device to set a * clock's rate. * diff --git a/arch/sandbox/include/asm/i2c.h b/arch/sandbox/include/asm/i2c.h new file mode 100644 index 0000000000..b482be485c --- /dev/null +++ b/arch/sandbox/include/asm/i2c.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#ifndef __asn_i2c_h +#define __asn_i2c_h + +struct sandbox_i2c_priv { + bool test_mode; +}; + +#endif /* __asn_i2c_h */ diff --git a/arch/sandbox/include/asm/serial.h b/arch/sandbox/include/asm/serial.h new file mode 100644 index 0000000000..bc82aebd0e --- /dev/null +++ b/arch/sandbox/include/asm/serial.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#ifndef __asm_serial_h +#define __asm_serial_h + +#include <dt-structs.h> + +struct sandbox_serial_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_sandbox_serial dtplat; +#endif + int colour; /* Text colour to use for output, -1 for none */ +}; + +/** + * struct sandbox_serial_priv - Private data for this driver + * + * @buf: holds input characters available to be read by this driver + */ +struct sandbox_serial_priv { + struct membuff buf; + char serial_buf[16]; + bool start_of_line; +}; + +#endif /* __asm_serial_h */ diff --git a/arch/sandbox/include/asm/spi.h b/arch/sandbox/include/asm/spi.h index 98e1826e2c..e8268bbe07 100644 --- a/arch/sandbox/include/asm/spi.h +++ b/arch/sandbox/include/asm/spi.h @@ -32,14 +32,4 @@ struct sandbox_spi_emu_ops { int (*xfer)(void *priv, const u8 *rx, u8 *tx, uint bytes); }; -/* - * Extract the bus/cs from the spi spec and return the start of the spi - * client spec. If the bus/cs are invalid for the current config, then - * it returns NULL. - * - * Example: arg="0:1:foo" will set bus to 0, cs to 1, and return "foo" - */ -const char *sandbox_spi_parse_spec(const char *arg, unsigned long *bus, - unsigned long *cs); - #endif diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 7f99d07c47..05f66f700c 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -203,6 +203,22 @@ void sandbox_set_allow_beep(struct udevice *dev, bool allow); int sandbox_get_beep_frequency(struct udevice *dev); /** + * sandbox_spi_get_speed() - Get current speed setting of a sandbox spi bus + * + * @dev: Device to check + * @return current bus speed + */ +uint sandbox_spi_get_speed(struct udevice *dev); + +/** + * sandbox_spi_get_mode() - Get current mode setting of a sandbox spi bus + * + * @dev: Device to check + * @return current mode + */ +uint sandbox_spi_get_mode(struct udevice *dev); + +/** * sandbox_get_pch_spi_protect() - Get the PCI SPI protection status * * @dev: Device to check diff --git a/arch/sandbox/lib/interrupts.c b/arch/sandbox/lib/interrupts.c index 21f761ac3b..9c2c60b8c6 100644 --- a/arch/sandbox/lib/interrupts.c +++ b/arch/sandbox/lib/interrupts.c @@ -6,7 +6,13 @@ */ #include <common.h> +#include <efi_loader.h> #include <irq_func.h> +#include <os.h> +#include <asm-generic/signal.h> +#include <asm/u-boot-sandbox.h> + +DECLARE_GLOBAL_DATA_PTR; int interrupt_init(void) { @@ -21,3 +27,32 @@ int disable_interrupts(void) { return 0; } + +void os_signal_action(int sig, unsigned long pc) +{ + efi_restore_gd(); + + switch (sig) { + case SIGILL: + printf("\nIllegal instruction\n"); + break; + case SIGBUS: + printf("\nBus error\n"); + break; + case SIGSEGV: + printf("\nSegmentation violation\n"); + break; + default: + break; + } + printf("pc = 0x%lx, ", pc); + printf("pc_reloc = 0x%lx\n\n", pc - gd->reloc_off); + efi_print_image_infos((void *)pc); + + if (IS_ENABLED(CONFIG_SANDBOX_CRASH_RESET)) { + printf("resetting ...\n\n"); + sandbox_reset(); + } else { + sandbox_exit(); + } +} diff --git a/arch/sh/include/asm/spl.h b/arch/sh/include/asm/spl.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/arch/sh/include/asm/spl.h diff --git a/arch/x86/cpu/acpi_gpe.c b/arch/x86/cpu/acpi_gpe.c index 70badb15a3..83128c33c2 100644 --- a/arch/x86/cpu/acpi_gpe.c +++ b/arch/x86/cpu/acpi_gpe.c @@ -51,7 +51,7 @@ static int acpi_gpe_read_and_clear(struct irq *irq) return ret; } -static int acpi_gpe_ofdata_to_platdata(struct udevice *dev) +static int acpi_gpe_of_to_plat(struct udevice *dev) { struct acpi_gpe_priv *priv = dev_get_priv(dev); @@ -107,6 +107,6 @@ U_BOOT_DRIVER(acpi_gpe_drv) = { .id = UCLASS_IRQ, .of_match = acpi_gpe_ids, .ops = &acpi_gpe_ops, - .ofdata_to_platdata = acpi_gpe_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct acpi_gpe_priv), + .of_to_plat = acpi_gpe_of_to_plat, + .priv_auto = sizeof(struct acpi_gpe_priv), }; diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig index c6c1350f4f..f5dbd6cbd3 100644 --- a/arch/x86/cpu/apollolake/Kconfig +++ b/arch/x86/cpu/apollolake/Kconfig @@ -19,6 +19,7 @@ config INTEL_APOLLOLAKE select SMP_AP_WORK select INTEL_GMA_SWSMISCI select ACPI_GNVS_EXTERNAL + select TPL_OF_PLATDATA_PARENT imply ENABLE_MRC_CACHE imply AHCI_PCI imply SCSI diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c index d37f91d1ce..328f79255f 100644 --- a/arch/x86/cpu/apollolake/cpu.c +++ b/arch/x86/cpu/apollolake/cpu.c @@ -63,7 +63,7 @@ static int apl_get_info(const struct udevice *dev, struct cpu_info *info) static int acpi_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) { - uint core_id = dev->req_seq; + uint core_id = dev_seq(dev); int cores_per_package; int ret; diff --git a/arch/x86/cpu/apollolake/fsp_m.c b/arch/x86/cpu/apollolake/fsp_m.c index cef937573b..c6be707e4e 100644 --- a/arch/x86/cpu/apollolake/fsp_m.c +++ b/arch/x86/cpu/apollolake/fsp_m.c @@ -32,7 +32,10 @@ int fspm_update_config(struct udevice *dev, struct fspm_upd *upd) node = dev_ofnode(dev); if (!ofnode_valid(node)) - return log_msg_ret("fsp-m settings", -ENOENT); + return log_msg_ret("node", -ENOENT); + node = ofnode_find_subnode(node, "fsp-m"); + if (!ofnode_valid(node)) + return log_msg_ret("fspm", -ENOENT); ret = fsp_m_update_config_from_dtb(node, cfg); if (ret) diff --git a/arch/x86/cpu/apollolake/hostbridge.c b/arch/x86/cpu/apollolake/hostbridge.c index cafd9d65b2..9decab7aa3 100644 --- a/arch/x86/cpu/apollolake/hostbridge.c +++ b/arch/x86/cpu/apollolake/hostbridge.c @@ -24,6 +24,7 @@ #include <asm/io.h> #include <asm/pci.h> #include <asm/arch/acpi.h> +#include <asm/arch/hostbridge.h> #include <asm/arch/systemagent.h> #include <dt-bindings/sound/nhlt.h> #include <dm/acpi.h> @@ -41,25 +42,7 @@ enum { TOLUD = 0xbc, }; -/** - * struct apl_hostbridge_platdata - platform data for hostbridge - * - * @dtplat: Platform data for of-platdata - * @early_pads: Early pad data to set up, each (pad, cfg0, cfg1) - * @early_pads_count: Number of pads to process - * @pciex_region_size: BAR length in bytes - * @bdf: Bus/device/function of hostbridge - */ -struct apl_hostbridge_platdata { -#if CONFIG_IS_ENABLED(OF_PLATDATA) - struct dtd_intel_apl_hostbridge dtplat; -#endif - u32 *early_pads; - int early_pads_count; - uint pciex_region_size; - pci_dev_t bdf; -}; - +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) static const struct nhlt_format_config dmic_1ch_formats[] = { /* 48 KHz 16-bits per sample. */ { @@ -155,10 +138,11 @@ static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = { .num_formats = ARRAY_SIZE(dmic_4ch_formats), }, }; +#endif static int apl_hostbridge_early_init_pinctrl(struct udevice *dev) { - struct apl_hostbridge_platdata *plat = dev_get_platdata(dev); + struct apl_hostbridge_plat *plat = dev_get_plat(dev); struct udevice *pinctrl; int ret; @@ -172,7 +156,7 @@ static int apl_hostbridge_early_init_pinctrl(struct udevice *dev) static int apl_hostbridge_early_init(struct udevice *dev) { - struct apl_hostbridge_platdata *plat = dev_get_platdata(dev); + struct apl_hostbridge_plat *plat = dev_get_plat(dev); u32 region_size; ulong base; u32 reg; @@ -221,9 +205,9 @@ static int apl_hostbridge_early_init(struct udevice *dev) return 0; } -static int apl_hostbridge_ofdata_to_platdata(struct udevice *dev) +static int apl_hostbridge_of_to_plat(struct udevice *dev) { - struct apl_hostbridge_platdata *plat = dev_get_platdata(dev); + struct apl_hostbridge_plat *plat = dev_get_plat(dev); struct udevice *pinctrl; int ret; @@ -283,7 +267,7 @@ static int apl_acpi_hb_get_name(const struct udevice *dev, char *out_name) return acpi_copy_name(out_name, "RHUB"); } -#ifdef CONFIG_GENERATE_ACPI_TABLE +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) static int apl_acpi_hb_write_tables(const struct udevice *dev, struct acpi_ctx *ctx) { @@ -322,7 +306,6 @@ static int apl_acpi_hb_write_tables(const struct udevice *dev, return 0; } -#endif static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx) { @@ -347,6 +330,7 @@ static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx) return log_msg_ret("channels", -EINVAL); } +#endif static int apl_hostbridge_remove(struct udevice *dev) { @@ -385,25 +369,27 @@ ulong sa_get_tseg_base(struct udevice *dev) struct acpi_ops apl_hostbridge_acpi_ops = { .get_name = apl_acpi_hb_get_name, -#ifdef CONFIG_GENERATE_ACPI_TABLE +#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) .write_tables = apl_acpi_hb_write_tables, -#endif .setup_nhlt = apl_acpi_setup_nhlt, +#endif }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id apl_hostbridge_ids[] = { { .compatible = "intel,apl-hostbridge" }, { } }; +#endif U_BOOT_DRIVER(intel_apl_hostbridge) = { .name = "intel_apl_hostbridge", .id = UCLASS_NORTHBRIDGE, - .of_match = apl_hostbridge_ids, - .ofdata_to_platdata = apl_hostbridge_ofdata_to_platdata, + .of_match = of_match_ptr(apl_hostbridge_ids), + .of_to_plat = apl_hostbridge_of_to_plat, .probe = apl_hostbridge_probe, .remove = apl_hostbridge_remove, - .platdata_auto_alloc_size = sizeof(struct apl_hostbridge_platdata), + .plat_auto = sizeof(struct apl_hostbridge_plat), ACPI_OPS_PTR(&apl_hostbridge_acpi_ops) .flags = DM_FLAG_OS_PREPARE, }; diff --git a/arch/x86/cpu/apollolake/lpc.c b/arch/x86/cpu/apollolake/lpc.c index d8e05f6a8f..e085890d63 100644 --- a/arch/x86/cpu/apollolake/lpc.c +++ b/arch/x86/cpu/apollolake/lpc.c @@ -81,10 +81,11 @@ int lpc_open_pmio_window(uint base, uint size) lgir_reg_num = find_unused_pmio_window(); if (lgir_reg_num < 0) { - log_err("LPC: Cannot open IO window: %lx size %lx\n", - bridge_base, size - bridged_size); - log_err("No more IO windows\n"); - + if (spl_phase() > PHASE_TPL) { + log_err("LPC: Cannot open IO window: %lx size %lx\n", + bridge_base, size - bridged_size); + log_err("No more IO windows\n"); + } return -ENOSPC; } lgir_reg_offset = LPC_GENERIC_IO_RANGE(lgir_reg_num); @@ -127,15 +128,17 @@ struct acpi_ops apl_lpc_acpi_ops = { .inject_dsdt = southbridge_inject_dsdt, }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id apl_lpc_ids[] = { { .compatible = "intel,apl-lpc" }, { } }; +#endif /* All pads are LPC already configured by the hostbridge, so no probing here */ U_BOOT_DRIVER(intel_apl_lpc) = { .name = "intel_apl_lpc", .id = UCLASS_LPC, - .of_match = apl_lpc_ids, + .of_match = of_match_ptr(apl_lpc_ids), ACPI_OPS_PTR(&apl_lpc_acpi_ops) }; diff --git a/arch/x86/cpu/apollolake/pch.c b/arch/x86/cpu/apollolake/pch.c index d9832ff249..39d6ad5ed4 100644 --- a/arch/x86/cpu/apollolake/pch.c +++ b/arch/x86/cpu/apollolake/pch.c @@ -23,14 +23,16 @@ static const struct pch_ops apl_pch_ops = { .set_spi_protect = apl_set_spi_protect, }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id apl_pch_ids[] = { { .compatible = "intel,apl-pch" }, { } }; +#endif U_BOOT_DRIVER(intel_apl_pch) = { .name = "intel_apl_pch", .id = UCLASS_PCH, - .of_match = apl_pch_ids, + .of_match = of_match_ptr(apl_pch_ids), .ops = &apl_pch_ops, }; diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c index cacaa007e0..e23d38ea07 100644 --- a/arch/x86/cpu/apollolake/pmc.c +++ b/arch/x86/cpu/apollolake/pmc.c @@ -16,6 +16,7 @@ #include <acpi/acpi_s3.h> #include <asm/io.h> #include <asm/pci.h> +#include <asm/arch/pmc.h> #include <linux/bitops.h> #include <power/acpi_pmc.h> @@ -53,13 +54,6 @@ enum { CF9_GLB_RST = 1 << 20, }; -struct apl_pmc_platdata { -#if CONFIG_IS_ENABLED(OF_PLATDATA) - struct dtd_intel_apl_pmc dtplat; -#endif - pci_dev_t bdf; -}; - static int apl_pmc_fill_power_state(struct udevice *dev) { struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); @@ -108,10 +102,10 @@ static int apl_global_reset_set_enable(struct udevice *dev, bool enable) return 0; } -int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev) +int apl_pmc_ofdata_to_uc_plat(struct udevice *dev) { struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); - struct apl_pmc_platdata *plat = dev_get_platdata(dev); + struct apl_pmc_plat *plat = dev_get_plat(dev); #if !CONFIG_IS_ENABLED(OF_PLATDATA) u32 base[6]; @@ -144,7 +138,7 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev) if (ret) return log_msg_ret("Bad gpe0-dw", ret); - return pmc_ofdata_to_uc_platdata(dev); + return pmc_ofdata_to_uc_plat(dev); #else struct dtd_intel_apl_pmc *dtplat = &plat->dtplat; @@ -169,7 +163,7 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev) static int enable_pmcbar(struct udevice *dev) { struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); - struct apl_pmc_platdata *priv = dev_get_platdata(dev); + struct apl_pmc_plat *priv = dev_get_plat(dev); pci_dev_t pmc = priv->bdf; /* @@ -205,24 +199,26 @@ static int apl_pmc_probe(struct udevice *dev) return 0; } -static struct acpi_pmc_ops apl_pmc_ops = { +static const struct acpi_pmc_ops apl_pmc_ops = { .init = apl_pmc_fill_power_state, .prev_sleep_state = apl_prev_sleep_state, .disable_tco = apl_disable_tco, .global_reset_set_enable = apl_global_reset_set_enable, }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id apl_pmc_ids[] = { { .compatible = "intel,apl-pmc" }, { } }; +#endif U_BOOT_DRIVER(intel_apl_pmc) = { .name = "intel_apl_pmc", .id = UCLASS_ACPI_PMC, - .of_match = apl_pmc_ids, - .ofdata_to_platdata = apl_pmc_ofdata_to_uc_platdata, + .of_match = of_match_ptr(apl_pmc_ids), + .of_to_plat = apl_pmc_ofdata_to_uc_plat, .probe = apl_pmc_probe, .ops = &apl_pmc_ops, - .platdata_auto_alloc_size = sizeof(struct apl_pmc_platdata), + .plat_auto = sizeof(struct apl_pmc_plat), }; diff --git a/arch/x86/cpu/apollolake/spl.c b/arch/x86/cpu/apollolake/spl.c index 089b37c59f..8991d5e648 100644 --- a/arch/x86/cpu/apollolake/spl.c +++ b/arch/x86/cpu/apollolake/spl.c @@ -83,33 +83,6 @@ static int apl_flash_probe(struct udevice *dev) return spi_flash_std_probe(dev); } -/* - * Manually set the parent of the SPI flash to SPI, since dtoc doesn't. We also - * need to allocate the parent_platdata since by the time this function is - * called device_bind() has already gone past that step. - */ -static int apl_flash_bind(struct udevice *dev) -{ - if (CONFIG_IS_ENABLED(OF_PLATDATA) && - !CONFIG_IS_ENABLED(OF_PLATDATA_PARENT)) { - struct dm_spi_slave_platdata *plat; - struct udevice *spi; - int ret; - - ret = uclass_first_device_err(UCLASS_SPI, &spi); - if (ret) - return ret; - dev->parent = spi; - - plat = calloc(sizeof(*plat), 1); - if (!plat) - return -ENOMEM; - dev->parent_platdata = plat; - } - - return 0; -} - static const struct dm_spi_flash_ops apl_flash_ops = { .read = apl_flash_std_read, }; @@ -123,9 +96,8 @@ U_BOOT_DRIVER(winbond_w25q128fw) = { .name = "winbond_w25q128fw", .id = UCLASS_SPI_FLASH, .of_match = apl_flash_ids, - .bind = apl_flash_bind, .probe = apl_flash_probe, - .priv_auto_alloc_size = sizeof(struct spi_flash), + .priv_auto = sizeof(struct spi_nor), .ops = &apl_flash_ops, }; diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c index c522aa9780..876fa592b8 100644 --- a/arch/x86/cpu/apollolake/uart.c +++ b/arch/x86/cpu/apollolake/uart.c @@ -16,6 +16,8 @@ #include <asm/io.h> #include <asm/pci.h> #include <asm/lpss.h> +#include <dm/device-internal.h> +#include <asm/arch/uart.h> /* Low-power Subsystem (LPSS) clock register */ enum { @@ -68,48 +70,52 @@ void apl_uart_init(pci_dev_t bdf, ulong base) * This driver uses its own compatible string but almost everything else from * the standard ns16550 driver. This allows us to provide an of-platdata * implementation, since the platdata produced by of-platdata does not match - * struct ns16550_platdata. + * struct apl_ns16550_plat. * * When running with of-platdata (generally TPL), the platdata is converted to * something that ns16550 expects. When running withoutof-platdata (SPL, U-Boot - * proper), we use ns16550's ofdata_to_platdata routine. + * proper), we use ns16550's of_to_plat routine. */ static int apl_ns16550_probe(struct udevice *dev) { - struct ns16550_platdata *plat = dev_get_platdata(dev); + struct apl_ns16550_plat *plat = dev_get_plat(dev); if (!CONFIG_IS_ENABLED(PCI)) - apl_uart_init(plat->bdf, plat->base); + apl_uart_init(plat->ns16550.bdf, plat->ns16550.base); return ns16550_serial_probe(dev); } -static int apl_ns16550_ofdata_to_platdata(struct udevice *dev) +static int apl_ns16550_of_to_plat(struct udevice *dev) { #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct dtd_intel_apl_ns16550 *dtplat = dev_get_platdata(dev); - struct ns16550_platdata *plat; + struct dtd_intel_apl_ns16550 *dtplat; + struct apl_ns16550_plat *plat = dev_get_plat(dev); + struct ns16550_plat ns; /* - * Convert our platdata to the ns16550's platdata, so we can just use - * that driver + * The device's plat uses struct apl_ns16550_plat which starts with the + * dtd struct, but the ns16550 driver expects it to be struct ns16550. + * Set up what that driver expects. Note that this means that the values + * cannot be read in this driver when using of-platdata. + * + * TODO(sjg@chromium.org): Consider having a separate plat pointer for + * of-platdata so that it is not necessary to overwrite this. */ - plat = malloc(sizeof(*plat)); - if (!plat) - return -ENOMEM; - plat->base = dtplat->early_regs[0]; - plat->reg_width = 1; - plat->reg_shift = dtplat->reg_shift; - plat->reg_offset = 0; - plat->clock = dtplat->clock_frequency; - plat->fcr = UART_FCR_DEFVAL; - plat->bdf = pci_ofplat_get_devfn(dtplat->reg[0]); - dev->platdata = plat; + dtplat = &plat->dtplat; + ns.base = dtplat->early_regs[0]; + ns.reg_width = 1; + ns.reg_shift = dtplat->reg_shift; + ns.reg_offset = 0; + ns.clock = dtplat->clock_frequency; + ns.fcr = UART_FCR_DEFVAL; + ns.bdf = pci_ofplat_get_devfn(dtplat->reg[0]); + memcpy(plat, &ns, sizeof(ns)); #else int ret; - ret = ns16550_serial_ofdata_to_platdata(dev); + ret = ns16550_serial_of_to_plat(dev); if (ret) return ret; #endif /* OF_PLATDATA */ @@ -117,18 +123,20 @@ static int apl_ns16550_ofdata_to_platdata(struct udevice *dev) return 0; } +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id apl_ns16550_serial_ids[] = { { .compatible = "intel,apl-ns16550" }, { }, }; +#endif U_BOOT_DRIVER(intel_apl_ns16550) = { .name = "intel_apl_ns16550", .id = UCLASS_SERIAL, - .of_match = apl_ns16550_serial_ids, - .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), - .priv_auto_alloc_size = sizeof(struct NS16550), + .of_match = of_match_ptr(apl_ns16550_serial_ids), + .plat_auto = sizeof(struct apl_ns16550_plat), + .priv_auto = sizeof(struct ns16550), .ops = &ns16550_serial_ops, - .ofdata_to_platdata = apl_ns16550_ofdata_to_platdata, + .of_to_plat = apl_ns16550_of_to_plat, .probe = apl_ns16550_probe, }; diff --git a/arch/x86/cpu/broadwell/adsp.c b/arch/x86/cpu/broadwell/adsp.c index 41f7d5d4d1..1fa1823780 100644 --- a/arch/x86/cpu/broadwell/adsp.c +++ b/arch/x86/cpu/broadwell/adsp.c @@ -122,7 +122,7 @@ static int broadwell_adsp_probe(struct udevice *dev) return 0; } -static int broadwell_adsp_ofdata_to_platdata(struct udevice *dev) +static int broadwell_adsp_of_to_plat(struct udevice *dev) { struct broadwell_adsp_priv *priv = dev_get_priv(dev); @@ -142,7 +142,7 @@ static const struct udevice_id broadwell_adsp_ids[] = { U_BOOT_DRIVER(broadwell_adsp_drv) = { .name = "adsp", .id = UCLASS_SYSCON, - .ofdata_to_platdata = broadwell_adsp_ofdata_to_platdata, + .of_to_plat = broadwell_adsp_of_to_plat, .of_match = broadwell_adsp_ids, .bind = dm_scan_fdt_dev, .probe = broadwell_adsp_probe, diff --git a/arch/x86/cpu/broadwell/cpu_full.c b/arch/x86/cpu/broadwell/cpu_full.c index 706f68f63d..ea9e98dde6 100644 --- a/arch/x86/cpu/broadwell/cpu_full.c +++ b/arch/x86/cpu/broadwell/cpu_full.c @@ -638,7 +638,7 @@ static int broadwell_get_count(const struct udevice *dev) static int cpu_x86_broadwell_probe(struct udevice *dev) { - if (dev->seq == 0) { + if (dev_seq(dev) == 0) { cpu_core_init(dev); return broadwell_init(dev); } @@ -665,6 +665,6 @@ U_BOOT_DRIVER(cpu_x86_broadwell_drv) = { .bind = cpu_x86_bind, .probe = cpu_x86_broadwell_probe, .ops = &cpu_x86_broadwell_ops, - .priv_auto_alloc_size = sizeof(struct cpu_broadwell_priv), + .priv_auto = sizeof(struct cpu_broadwell_priv), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/arch/x86/cpu/broadwell/sata.c b/arch/x86/cpu/broadwell/sata.c index 641da515c8..ceb395ddcf 100644 --- a/arch/x86/cpu/broadwell/sata.c +++ b/arch/x86/cpu/broadwell/sata.c @@ -17,7 +17,7 @@ #include <asm/arch/pch.h> #include <linux/delay.h> -struct sata_platdata { +struct sata_plat { int port_map; uint port0_gen3_tx; uint port1_gen3_tx; @@ -41,7 +41,7 @@ struct sata_platdata { static void broadwell_sata_init(struct udevice *dev) { - struct sata_platdata *plat = dev_get_platdata(dev); + struct sata_plat *plat = dev_get_plat(dev); u32 reg32; u8 *abar; u16 reg16; @@ -211,7 +211,7 @@ static void broadwell_sata_init(struct udevice *dev) static int broadwell_sata_enable(struct udevice *dev) { - struct sata_platdata *plat = dev_get_platdata(dev); + struct sata_plat *plat = dev_get_plat(dev); struct gpio_desc desc; u16 map; int ret; @@ -232,9 +232,9 @@ static int broadwell_sata_enable(struct udevice *dev) return 0; } -static int broadwell_sata_ofdata_to_platdata(struct udevice *dev) +static int broadwell_sata_of_to_plat(struct udevice *dev) { - struct sata_platdata *plat = dev_get_platdata(dev); + struct sata_plat *plat = dev_get_plat(dev); const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); @@ -264,7 +264,7 @@ U_BOOT_DRIVER(ahci_broadwell_drv) = { .name = "ahci_broadwell", .id = UCLASS_AHCI, .of_match = broadwell_ahci_ids, - .ofdata_to_platdata = broadwell_sata_ofdata_to_platdata, + .of_to_plat = broadwell_sata_of_to_plat, .probe = broadwell_sata_probe, - .platdata_auto_alloc_size = sizeof(struct sata_platdata), + .plat_auto = sizeof(struct sata_plat), }; diff --git a/arch/x86/cpu/cpu_x86.c b/arch/x86/cpu/cpu_x86.c index 7e83051646..bfb511a510 100644 --- a/arch/x86/cpu/cpu_x86.c +++ b/arch/x86/cpu/cpu_x86.c @@ -13,7 +13,7 @@ DECLARE_GLOBAL_DATA_PTR; int cpu_x86_bind(struct udevice *dev) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); struct cpuid_result res; plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), diff --git a/arch/x86/cpu/i386/call64.S b/arch/x86/cpu/i386/call64.S index 275063c4af..0ffc1006bb 100644 --- a/arch/x86/cpu/i386/call64.S +++ b/arch/x86/cpu/i386/call64.S @@ -11,6 +11,7 @@ #include <asm/processor-flags.h> .code32 +.section .text_call64 .globl cpu_call64 cpu_call64: /* diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile index 4a5cf17e41..8b9a810f66 100644 --- a/arch/x86/cpu/intel_common/Makefile +++ b/arch/x86/cpu/intel_common/Makefile @@ -26,7 +26,7 @@ obj-y += cpu.o obj-y += fast_spi.o obj-y += lpc.o obj-y += lpss.o -obj-$(CONFIG_INTEL_GENERIC_WIFI) += generic_wifi.o +obj-$(CONFIG_$(SPL_)INTEL_GENERIC_WIFI) += generic_wifi.o ifndef CONFIG_TARGET_EFI_APP obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += microcode.o ifndef CONFIG_$(SPL_)X86_64 diff --git a/arch/x86/cpu/intel_common/itss.c b/arch/x86/cpu/intel_common/itss.c index de17b93ed4..ae4de4ca8c 100644 --- a/arch/x86/cpu/intel_common/itss.c +++ b/arch/x86/cpu/intel_common/itss.c @@ -19,25 +19,6 @@ #include <spl.h> #include <asm/itss.h> -struct itss_platdata { -#if CONFIG_IS_ENABLED(OF_PLATDATA) - /* Put this first since driver model will copy the data here */ - struct dtd_intel_itss dtplat; -#endif -}; - -/* struct pmc_route - Routing for PMC to GPIO */ -struct pmc_route { - u32 pmc; - u32 gpio; -}; - -struct itss_priv { - struct pmc_route *route; - uint route_count; - u32 irq_snapshot[NUM_IPC_REGS]; -}; - static int set_polarity(struct udevice *dev, uint irq, bool active_low) { u32 mask; @@ -178,13 +159,13 @@ static int itss_bind(struct udevice *dev) return 0; } -static int itss_ofdata_to_platdata(struct udevice *dev) +static int itss_of_to_plat(struct udevice *dev) { struct itss_priv *priv = dev_get_priv(dev); int ret; #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct itss_platdata *plat = dev_get_platdata(dev); + struct itss_plat *plat = dev_get_plat(dev); struct dtd_intel_itss *dtplat = &plat->dtplat; /* @@ -230,18 +211,20 @@ static const struct irq_ops itss_ops = { #endif }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id itss_ids[] = { { .compatible = "intel,itss", .data = X86_IRQT_ITSS }, { } }; +#endif U_BOOT_DRIVER(intel_itss) = { .name = "intel_itss", .id = UCLASS_IRQ, - .of_match = itss_ids, + .of_match = of_match_ptr(itss_ids), .ops = &itss_ops, .bind = itss_bind, - .ofdata_to_platdata = itss_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct itss_platdata), - .priv_auto_alloc_size = sizeof(struct itss_priv), + .of_to_plat = itss_of_to_plat, + .plat_auto = sizeof(struct itss_plat), + .priv_auto = sizeof(struct itss_priv), }; diff --git a/arch/x86/cpu/intel_common/p2sb.c b/arch/x86/cpu/intel_common/p2sb.c index a0a4001e03..d73ae438bb 100644 --- a/arch/x86/cpu/intel_common/p2sb.c +++ b/arch/x86/cpu/intel_common/p2sb.c @@ -13,20 +13,13 @@ #include <log.h> #include <p2sb.h> #include <spl.h> +#include <asm/p2sb.h> #include <asm/pci.h> #include <linux/bitops.h> #define PCH_P2SB_E0 0xe0 #define HIDE_BIT BIT(0) -struct p2sb_platdata { -#if CONFIG_IS_ENABLED(OF_PLATDATA) - struct dtd_intel_p2sb dtplat; -#endif - ulong mmio_base; - pci_dev_t bdf; -}; - /* PCI config space registers */ #define HPTC_OFFSET 0x60 #define HPTC_ADDR_ENABLE_BIT BIT(7) @@ -57,7 +50,7 @@ struct p2sb_platdata { */ static int p2sb_early_init(struct udevice *dev) { - struct p2sb_platdata *plat = dev_get_platdata(dev); + struct p2sb_plat *plat = dev_get_plat(dev); pci_dev_t pdev = plat->bdf; /* @@ -90,10 +83,10 @@ static int p2sb_spl_init(struct udevice *dev) return 0; } -int p2sb_ofdata_to_platdata(struct udevice *dev) +int p2sb_of_to_plat(struct udevice *dev) { struct p2sb_uc_priv *upriv = dev_get_uclass_priv(dev); - struct p2sb_platdata *plat = dev_get_platdata(dev); + struct p2sb_plat *plat = dev_get_plat(dev); #if !CONFIG_IS_ENABLED(OF_PLATDATA) int ret; @@ -167,7 +160,7 @@ static int p2sb_remove(struct udevice *dev) static int p2sb_child_post_bind(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); + struct p2sb_child_plat *pplat = dev_get_parent_plat(dev); int ret; u32 pid; @@ -180,26 +173,27 @@ static int p2sb_child_post_bind(struct udevice *dev) return 0; } -struct p2sb_ops p2sb_ops = { +static const struct p2sb_ops p2sb_ops = { .set_hide = intel_p2sb_set_hide, }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id p2sb_ids[] = { { .compatible = "intel,p2sb" }, { } }; +#endif U_BOOT_DRIVER(intel_p2sb) = { .name = "intel_p2sb", .id = UCLASS_P2SB, - .of_match = p2sb_ids, + .of_match = of_match_ptr(p2sb_ids), .probe = p2sb_probe, .remove = p2sb_remove, .ops = &p2sb_ops, - .ofdata_to_platdata = p2sb_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct p2sb_platdata), - .per_child_platdata_auto_alloc_size = - sizeof(struct p2sb_child_platdata), + .of_to_plat = p2sb_of_to_plat, + .plat_auto = sizeof(struct p2sb_plat), + .per_child_plat_auto = sizeof(struct p2sb_child_plat), .child_post_bind = p2sb_child_post_bind, .flags = DM_FLAG_OS_PREPARE, }; diff --git a/arch/x86/cpu/irq.c b/arch/x86/cpu/irq.c index 836a0e8b86..8b53b96822 100644 --- a/arch/x86/cpu/irq.c +++ b/arch/x86/cpu/irq.c @@ -362,5 +362,5 @@ U_BOOT_DRIVER(irq_router_drv) = { .id = UCLASS_IRQ, .of_match = irq_router_ids, .probe = irq_router_probe, - .priv_auto_alloc_size = sizeof(struct irq_router), + .priv_auto = sizeof(struct irq_router), }; diff --git a/arch/x86/cpu/ivybridge/model_206ax.c b/arch/x86/cpu/ivybridge/model_206ax.c index 55f7cc2b2e..598ebcdf08 100644 --- a/arch/x86/cpu/ivybridge/model_206ax.c +++ b/arch/x86/cpu/ivybridge/model_206ax.c @@ -425,7 +425,7 @@ static int model_206ax_get_count(const struct udevice *dev) static int cpu_x86_model_206ax_probe(struct udevice *dev) { - if (dev->seq == 0) + if (dev_seq(dev) == 0) model_206ax_init(dev); return 0; diff --git a/arch/x86/cpu/mp_init.c b/arch/x86/cpu/mp_init.c index d2f1ee38cf..0e61c7b5d7 100644 --- a/arch/x86/cpu/mp_init.c +++ b/arch/x86/cpu/mp_init.c @@ -87,7 +87,7 @@ DECLARE_GLOBAL_DATA_PTR; * intel,apic-id = <2>; * }; * - * Here the 'reg' property is the CPU number and then is placed in dev->req_seq + * Here the 'reg' property is the CPU number and then is placed in dev_seq(cpu) * so that we can index into ap_callbacks[] using that. The APIC ID is different * and may not be sequential (it typically is if hyperthreading is supported). * @@ -135,7 +135,7 @@ struct mp_flight_plan { * * @func: Function to run * @arg: Argument to pass to the function - * @logical_cpu_number: Either a CPU number (i.e. dev->req_seq) or a special + * @logical_cpu_number: Either a CPU number (i.e. dev_seq(cpu) or a special * value like MP_SELECT_BSP. It tells the AP whether it should process this * callback */ @@ -152,7 +152,7 @@ static struct mp_flight_plan mp_info; * ap_callbacks - Callback mailbox array * * Array of callback, one entry for each available CPU, indexed by the CPU - * number, which is dev->req_seq. The entry for the main CPU is never used. + * number, which is dev_seq(cpu). The entry for the main CPU is never used. * When this is NULL, there is no pending work for the CPU to run. When * non-NULL it points to the mp_callback structure. This is shared between all * CPUs, so should only be written by the main CPU. @@ -221,7 +221,7 @@ static int find_cpu_by_apic_id(int apic_id, struct udevice **devp) for (uclass_find_first_device(UCLASS_CPU, &dev); dev; uclass_find_next_device(&dev)) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); if (plat->cpu_id == apic_id) { *devp = dev; @@ -562,7 +562,7 @@ static int get_bsp(struct udevice **devp, int *cpu_countp) if (cpu_countp) *cpu_countp = ret; - return dev->req_seq >= 0 ? dev->req_seq : 0; + return dev_seq(dev) >= 0 ? dev_seq(dev) : 0; } /** @@ -614,7 +614,7 @@ static void store_callback(struct mp_callback **slot, struct mp_callback *val) static int run_ap_work(struct mp_callback *callback, struct udevice *bsp, int num_cpus, uint expire_ms) { - int cur_cpu = bsp->req_seq; + int cur_cpu = dev_seq(bsp); int num_aps = num_cpus - 1; /* number of non-BSPs to get this message */ int cpus_accepted; ulong start; @@ -679,7 +679,7 @@ static int ap_wait_for_instruction(struct udevice *cpu, void *unused) if (!IS_ENABLED(CONFIG_SMP_AP_WORK)) return 0; - per_cpu_slot = &ap_callbacks[cpu->req_seq]; + per_cpu_slot = &ap_callbacks[dev_seq(cpu)]; while (1) { struct mp_callback *cb = read_callback(per_cpu_slot); @@ -694,7 +694,7 @@ static int ap_wait_for_instruction(struct udevice *cpu, void *unused) mfence(); if (lcb.logical_cpu_number == MP_SELECT_ALL || lcb.logical_cpu_number == MP_SELECT_APS || - cpu->req_seq == lcb.logical_cpu_number) + dev_seq(cpu) == lcb.logical_cpu_number) lcb.func(lcb.arg); /* Indicate we are finished */ @@ -706,7 +706,7 @@ static int ap_wait_for_instruction(struct udevice *cpu, void *unused) static int mp_init_cpu(struct udevice *cpu, void *unused) { - struct cpu_platdata *plat = dev_get_parent_platdata(cpu); + struct cpu_plat *plat = dev_get_parent_plat(cpu); plat->ucode_version = microcode_read_rev(); plat->device_id = gd->arch.x86_device; @@ -839,7 +839,6 @@ int mp_init(void) int num_aps, num_cpus; atomic_t *ap_count; struct udevice *cpu; - struct uclass *uc; int ret; if (IS_ENABLED(CONFIG_QFW)) { @@ -848,14 +847,6 @@ int mp_init(void) return ret; } - /* - * Multiple APs are brought up simultaneously and they may get the same - * seq num in the uclass_resolve_seq() during device_probe(). To avoid - * this, set req_seq to the reg number in the device tree in advance. - */ - uclass_id_foreach_dev(UCLASS_CPU, cpu, uc) - cpu->req_seq = dev_read_u32_default(cpu, "reg", -1); - ret = get_bsp(&cpu, &num_cpus); if (ret < 0) { debug("Cannot init boot CPU: err=%d\n", ret); diff --git a/arch/x86/cpu/qfw_cpu.c b/arch/x86/cpu/qfw_cpu.c index 349bab1583..a35de878b5 100644 --- a/arch/x86/cpu/qfw_cpu.c +++ b/arch/x86/cpu/qfw_cpu.c @@ -18,7 +18,7 @@ int qemu_cpu_fixup(void) int cpu_num; int cpu_online; struct udevice *dev, *pdev; - struct cpu_platdata *plat; + struct cpu_plat *plat; char *cpu; /* first we need to find '/cpus' */ @@ -67,7 +67,7 @@ int qemu_cpu_fixup(void) printf("binding cpu@%d failed: %d\n", cpu_num, ret); return ret; } - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); plat->cpu_id = cpu_num; } return 0; diff --git a/arch/x86/cpu/slimbootloader/serial.c b/arch/x86/cpu/slimbootloader/serial.c index 9813f7977b..772a94c31c 100644 --- a/arch/x86/cpu/slimbootloader/serial.c +++ b/arch/x86/cpu/slimbootloader/serial.c @@ -14,11 +14,11 @@ * The serial port info hob is generated by Slim Bootloader, so eligible for * Slim Bootloader based boards only. */ -static int slimbootloader_serial_ofdata_to_platdata(struct udevice *dev) +static int slimbootloader_serial_of_to_plat(struct udevice *dev) { const efi_guid_t guid = SBL_SERIAL_PORT_INFO_GUID; struct sbl_serial_port_info *data; - struct ns16550_platdata *plat = dev->platdata; + struct ns16550_plat *plat = dev_get_plat(dev); if (!gd->arch.hob_list) panic("hob list not found!"); @@ -57,9 +57,9 @@ U_BOOT_DRIVER(serial_slimbootloader) = { .name = "serial_slimbootloader", .id = UCLASS_SERIAL, .of_match = slimbootloader_serial_ids, - .ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), - .priv_auto_alloc_size = sizeof(struct NS16550), + .of_to_plat = slimbootloader_serial_of_to_plat, + .plat_auto = sizeof(struct ns16550_plat), + .priv_auto = sizeof(struct ns16550), .probe = ns16550_serial_probe, .ops = &ns16550_serial_ops, }; diff --git a/arch/x86/cpu/tangier/pinmux.c b/arch/x86/cpu/tangier/pinmux.c index 5b0e106011..acf97e3af5 100644 --- a/arch/x86/cpu/tangier/pinmux.c +++ b/arch/x86/cpu/tangier/pinmux.c @@ -191,5 +191,5 @@ U_BOOT_DRIVER(tangier_pinctrl) = { .id = UCLASS_SYSCON, .of_match = tangier_pinctrl_match, .probe = tangier_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct mrfld_pinctrl), + .priv_auto = sizeof(struct mrfld_pinctrl), }; diff --git a/arch/x86/cpu/turbo.c b/arch/x86/cpu/turbo.c index f8d85d5a33..4a73cb240d 100644 --- a/arch/x86/cpu/turbo.c +++ b/arch/x86/cpu/turbo.c @@ -35,12 +35,15 @@ static inline void set_global_turbo_state(int state) } #endif +/* gcc 7.3 does not wwant to drop strings, so use #ifdef */ +#ifndef CONFIG_TPL_BUILD static const char *const turbo_state_desc[] = { [TURBO_UNKNOWN] = "unknown", [TURBO_UNAVAILABLE] = "unavailable", [TURBO_DISABLED] = "available but hidden", [TURBO_ENABLED] = "available and visible" }; +#endif /* * Determine the current state of Turbo and cache it for later. @@ -76,7 +79,9 @@ int turbo_get_state(void) } set_global_turbo_state(turbo_state); +#ifndef CONFIG_TPL_BUILD debug("Turbo is %s\n", turbo_state_desc[turbo_state]); +#endif return turbo_state; } diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts index d66e128ae6..a846022095 100644 --- a/arch/x86/dts/chromebook_coral.dts +++ b/arch/x86/dts/chromebook_coral.dts @@ -102,12 +102,13 @@ }; cpus { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; #address-cells = <1>; #size-cells = <0>; cpu_0: cpu@0 { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; + u-boot,dm-spl; device_type = "cpu"; compatible = "intel,apl-cpu"; reg = <0>; @@ -174,6 +175,9 @@ */ fsp_s: fsp-s { }; + fsp_m: fsp-m { + u-boot,dm-spl; + }; nhlt { intel,dmic-channels = <4>; @@ -181,12 +185,14 @@ }; punit@0,1 { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; + u-boot,dm-spl; reg = <0x00000800 0 0 0 0>; compatible = "intel,apl-punit"; }; gma@2,0 { + u-boot,dm-pre-proper; reg = <0x00001000 0 0 0 0>; compatible = "fsp-fb"; }; @@ -321,7 +327,8 @@ }; spi: fast-spi@d,2 { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; + u-boot,dm-spl; reg = <0x02006a10 0 0 0 0>; #address-cells = <1>; #size-cells = <0>; @@ -332,7 +339,8 @@ fwstore_spi: spi-flash@0 { #size-cells = <1>; #address-cells = <1>; - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; + u-boot,dm-spl; reg = <0>; compatible = "winbond,w25q128fw", "jedec,spi-nor"; @@ -574,7 +582,7 @@ #size-cells = <0>; u-boot,dm-pre-reloc; cros_ec: cros-ec { - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; compatible = "google,cros-ec-lpc"; reg = <0x204 1 0x200 1 0x880 0x80>; @@ -650,7 +658,9 @@ PAD_CFG_NF(LPC_CLKRUNB, UP_20K, DEEP, NF1) /* LPC_CLKRUN_N */ PAD_CFG_NF(LPC_FRAMEB, NATIVE, DEEP, NF1) /* LPC_FRAME_N */ >; +}; +&fsp_m { fspm,package = <PACKAGE_BGA>; fspm,profile = <PROFILE_LPDDR4_2400_24_22_22>; fspm,memory-down = <MEMORY_DOWN_YES>; diff --git a/arch/x86/dts/rtc.dtsi b/arch/x86/dts/rtc.dtsi index d0bbd84e50..942cc937dc 100644 --- a/arch/x86/dts/rtc.dtsi +++ b/arch/x86/dts/rtc.dtsi @@ -1,7 +1,7 @@ / { rtc: rtc { compatible = "motorola,mc146818"; - u-boot,dm-pre-reloc; + u-boot,dm-pre-proper; reg = <0x70 2>; }; }; diff --git a/arch/x86/include/asm/arch-apollolake/gpio.h b/arch/x86/include/asm/arch-apollolake/gpio.h index ab5860c0fd..762160da88 100644 --- a/arch/x86/include/asm/arch-apollolake/gpio.h +++ b/arch/x86/include/asm/arch-apollolake/gpio.h @@ -485,4 +485,22 @@ /* This is needed by ACPI */ #define GPIO_NUM_PAD_CFG_REGS 2 /* DW0, DW1 */ +#ifndef __ASSEMBLY__ + +#include <dt-structs.h> + +/** + * struct apl_gpio_plat - platform data for each device + * + * @dtplat: of-platdata data from C struct + */ +struct apl_gpio_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + /* Put this first since driver model will copy the data here */ + struct dtd_intel_apl_pinctrl dtplat; +#endif +}; + +#endif /* __ASSEMBLY__ */ + #endif /* _ASM_ARCH_GPIO_H_ */ diff --git a/arch/x86/include/asm/arch-apollolake/hostbridge.h b/arch/x86/include/asm/arch-apollolake/hostbridge.h new file mode 100644 index 0000000000..f4dce0d522 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/hostbridge.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + */ + +#ifndef _ASM_ARCH_HOSTBRIDGE_H_ +#define _ASM_ARCH_HOSTBRIDGE_H_ + +/** + * struct apl_hostbridge_plat - platform data for hostbridge + * + * @dtplat: Platform data for of-platdata + * @early_pads: Early pad data to set up, each (pad, cfg0, cfg1) + * @early_pads_count: Number of pads to process + * @pciex_region_size: BAR length in bytes + * @bdf: Bus/device/function of hostbridge + */ +struct apl_hostbridge_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_intel_apl_hostbridge dtplat; +#endif + u32 *early_pads; + int early_pads_count; + uint pciex_region_size; + pci_dev_t bdf; +}; + +#endif /* _ASM_ARCH_HOSTBRIDGE_H_ */ diff --git a/arch/x86/include/asm/arch-apollolake/pmc.h b/arch/x86/include/asm/arch-apollolake/pmc.h new file mode 100644 index 0000000000..23ac8fe7e2 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/pmc.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + */ + +#ifndef ASM_ARCH_PMC_H +#define ASM_ARCH_PMC_H + +struct apl_pmc_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_intel_apl_pmc dtplat; +#endif + pci_dev_t bdf; +}; + +#endif /* ASM_ARCH_PMC_H */ diff --git a/arch/x86/include/asm/arch-apollolake/uart.h b/arch/x86/include/asm/arch-apollolake/uart.h index d4fffe6525..38335b0490 100644 --- a/arch/x86/include/asm/arch-apollolake/uart.h +++ b/arch/x86/include/asm/arch-apollolake/uart.h @@ -6,6 +6,23 @@ #ifndef _ASM_ARCH_UART_H #define _ASM_ARCH_UART_H +#include <ns16550.h> + +/** + * struct apl_ns16550_plat - platform data for the APL UART + * + * Note that when of-platdata is in use, apl_ns16550_of_to_plat() actually + * copies the ns16550_plat contents to the start of this struct, meaning that + * dtplat is no-longer valid. This is done so that the ns16550 driver can use + * dev_get_plat() without any offsets or adjustments. + */ +struct apl_ns16550_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_intel_apl_ns16550 dtplat; +#endif + struct ns16550_plat ns16550; +}; + /** * apl_uart_init() - Set up the APL UART device and clock * @@ -15,6 +32,6 @@ * The UART won't actually work unless the GPIO settings are correct and the * signals actually exit the SoC. See board_debug_uart_init() for that. */ -int apl_uart_init(pci_dev_t bdf, ulong base); +void apl_uart_init(pci_dev_t bdf, ulong base); #endif diff --git a/arch/x86/include/asm/arch-broadwell/gpio.h b/arch/x86/include/asm/arch-broadwell/gpio.h index a32e2db47e..393230e52b 100644 --- a/arch/x86/include/asm/arch-broadwell/gpio.h +++ b/arch/x86/include/asm/arch-broadwell/gpio.h @@ -11,7 +11,7 @@ #define GPIO_PER_BANK 32 #define GPIO_BANKS 3 -struct broadwell_bank_platdata { +struct broadwell_bank_plat { uint16_t base_addr; const char *bank_name; int bank; diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h index 58e4d7b831..a45ae3463c 100644 --- a/arch/x86/include/asm/gpio.h +++ b/arch/x86/include/asm/gpio.h @@ -8,7 +8,7 @@ #include <asm-generic/gpio.h> -struct ich6_bank_platdata { +struct ich6_bank_plat { uint16_t base_addr; const char *bank_name; int offset; diff --git a/arch/x86/include/asm/intel_pinctrl.h b/arch/x86/include/asm/intel_pinctrl.h index 00868d1725..44eedc205c 100644 --- a/arch/x86/include/asm/intel_pinctrl.h +++ b/arch/x86/include/asm/intel_pinctrl.h @@ -162,16 +162,15 @@ extern const struct pinctrl_ops intel_pinctrl_ops; int intel_pinctrl_probe(struct udevice *dev); /** - * intel_pinctrl_ofdata_to_platdata() - Handle common platdata setup + * intel_pinctrl_of_to_plat() - Handle common plat setup * * @dev: Pinctrl device * @comm: Pad community for this device * @num_cfgs: Number of configuration words for each pad * @return 0 if OK, -EDOM if @comm is NULL, other -ve value on other error */ -int intel_pinctrl_ofdata_to_platdata(struct udevice *dev, - const struct pad_community *comm, - int num_cfgs); +int intel_pinctrl_of_to_plat(struct udevice *dev, + const struct pad_community *comm, int num_cfgs); /** * pinctrl_route_gpe() - set GPIO groups for the general-purpose-event blocks diff --git a/arch/x86/include/asm/itss.h b/arch/x86/include/asm/itss.h index f7d3240384..6d4793277e 100644 --- a/arch/x86/include/asm/itss.h +++ b/arch/x86/include/asm/itss.h @@ -11,6 +11,8 @@ #ifndef _ASM_ARCH_ITSS_H #define _ASM_ARCH_ITSS_H +#include <irq.h> + #define GPIO_IRQ_START 50 #define GPIO_IRQ_END ITSS_MAX_IRQ @@ -42,4 +44,23 @@ /* ITSS Power reduction control */ #define PCR_ITSS_ITSSPRC 0x3300 +struct itss_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + /* Put this first since driver model will copy the data here */ + struct dtd_intel_itss dtplat; +#endif +}; + +/* struct pmc_route - Routing for PMC to GPIO */ +struct pmc_route { + u32 pmc; + u32 gpio; +}; + +struct itss_priv { + struct pmc_route *route; + uint route_count; + u32 irq_snapshot[NUM_IPC_REGS]; +}; + #endif /* _ASM_ARCH_ITSS_H */ diff --git a/arch/x86/include/asm/mp.h b/arch/x86/include/asm/mp.h index 5f9b8c6564..1e4e35321d 100644 --- a/arch/x86/include/asm/mp.h +++ b/arch/x86/include/asm/mp.h @@ -114,7 +114,7 @@ typedef void (*mp_run_func)(void *arg); * Running on anything other than the boot CPU is only supported if * CONFIG_SMP_AP_WORK is enabled * - * @cpu_select: CPU to run on (its dev->req_seq value), or MP_SELECT_ALL for + * @cpu_select: CPU to run on (its dev_seq() value), or MP_SELECT_ALL for * all, or MP_SELECT_BSP for BSP * @func: Function to run * @arg: Argument to pass to the function diff --git a/arch/x86/include/asm/p2sb.h b/arch/x86/include/asm/p2sb.h new file mode 100644 index 0000000000..6f63eae8e2 --- /dev/null +++ b/arch/x86/include/asm/p2sb.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + */ + +#ifndef ASM_P2SB_H +#define ASM_P2SB_H + +/* Platform data for the P2SB */ +struct p2sb_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_intel_p2sb dtplat; +#endif + ulong mmio_base; + pci_dev_t bdf; +}; + +#endif /* ASM_P2SB_H */ diff --git a/arch/x86/include/asm/pmu.h b/arch/x86/include/asm/pmu.h index b76bdf64a3..818e80881e 100644 --- a/arch/x86/include/asm/pmu.h +++ b/arch/x86/include/asm/pmu.h @@ -2,9 +2,9 @@ /* * Copyright (c) 2017 Intel Corporation */ -#ifndef _X86_ASM_PMU_IPC_H_ -#define _X86_ASM_PMU_IPC_H_ +#ifndef _X86_ASM_PMU_H_ +#define _X86_ASM_PMU_H_ int pmu_turn_power(unsigned int lss, bool on); -#endif /* _X86_ASM_PMU_IPC_H_ */ +#endif /* _X86_ASM_PMU_H_ */ diff --git a/arch/x86/include/asm/sysreset.h b/arch/x86/include/asm/sysreset.h new file mode 100644 index 0000000000..5e586f51c0 --- /dev/null +++ b/arch/x86/include/asm/sysreset.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + */ +#ifndef _X86_ASM_SYSRESET_H_ +#define _X86_ASM_SYSRESET_H_ + +#include <dt-structs.h> + +struct x86_sysreset_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_x86_reset dtplat; +#endif + + struct udevice *pch; +}; + +#endif /* _X86_ASM_SYSRESET_H_ */ diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 4fd8dc8ad9..9a41ecb587 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -74,7 +74,7 @@ int acpi_create_madt_lapics(u32 current) for (uclass_find_first_device(UCLASS_CPU, &dev); dev; uclass_find_next_device(&dev)) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); int length; length = acpi_create_madt_lapic( diff --git a/arch/x86/lib/fsp/fsp_graphics.c b/arch/x86/lib/fsp/fsp_graphics.c index 6534b6690b..a029237d08 100644 --- a/arch/x86/lib/fsp/fsp_graphics.c +++ b/arch/x86/lib/fsp/fsp_graphics.c @@ -80,7 +80,7 @@ static int save_vesa_mode(struct vesa_mode_info *vesa) static int fsp_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct vesa_mode_info *vesa = &mode_info.vesa; int ret; @@ -124,7 +124,7 @@ err: static int fsp_video_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); /* Set the maximum supported resolution */ plat->size = 2560 * 1600 * 4; diff --git a/arch/x86/lib/mpspec.c b/arch/x86/lib/mpspec.c index 1c49c41b31..562a27c557 100644 --- a/arch/x86/lib/mpspec.c +++ b/arch/x86/lib/mpspec.c @@ -81,7 +81,7 @@ void mp_write_processor(struct mp_config_table *mc) for (uclass_find_first_device(UCLASS_CPU, &dev); dev; uclass_find_next_device(&dev)) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); u8 cpuflag = MPC_CPU_EN; if (!device_active(dev)) diff --git a/arch/x86/lib/pmu.c b/arch/x86/lib/pmu.c index 3cd7b1f536..083aec8d8d 100644 --- a/arch/x86/lib/pmu.c +++ b/arch/x86/lib/pmu.c @@ -113,5 +113,5 @@ U_BOOT_DRIVER(intel_mid_pmu) = { .id = UCLASS_SYSCON, .of_match = pmu_mid_match, .probe = pmu_mid_probe, - .priv_auto_alloc_size = sizeof(struct pmu_mid), + .priv_auto = sizeof(struct pmu_mid), }; diff --git a/arch/x86/lib/scu.c b/arch/x86/lib/scu.c index d29d701631..90ef239bcd 100644 --- a/arch/x86/lib/scu.c +++ b/arch/x86/lib/scu.c @@ -227,5 +227,5 @@ U_BOOT_DRIVER(scu_ipc) = { .id = UCLASS_SYSCON, .of_match = scu_ipc_match, .probe = scu_ipc_probe, - .priv_auto_alloc_size = sizeof(struct scu), + .priv_auto = sizeof(struct scu), }; diff --git a/arch/x86/lib/sfi.c b/arch/x86/lib/sfi.c index b48bd5d8f3..85e963b634 100644 --- a/arch/x86/lib/sfi.c +++ b/arch/x86/lib/sfi.c @@ -84,7 +84,7 @@ static int sfi_write_cpus(struct table_info *tab) for (uclass_find_first_device(UCLASS_CPU, &dev); dev; uclass_find_next_device(&dev)) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); if (!device_active(dev)) continue; diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c index 15b0212d19..04ff32277f 100644 --- a/arch/x86/lib/tpl.c +++ b/arch/x86/lib/tpl.c @@ -133,14 +133,16 @@ void spl_board_init(void) * for devices, so the TPL BARs continue to be used. Once U-Boot starts it does * the auto allocation (after relocation). */ +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id tpl_fake_pci_ids[] = { { .compatible = "pci-x86" }, { } }; +#endif U_BOOT_DRIVER(pci_x86) = { .name = "pci_x86", .id = UCLASS_SIMPLE_BUS, - .of_match = tpl_fake_pci_ids, + .of_match = of_match_ptr(tpl_fake_pci_ids), }; #endif diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 24a503d011..708025b207 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -15,6 +15,7 @@ #define LOG_CATEGORY LOGC_BOOT #include <common.h> +#include <bootm.h> #include <command.h> #include <env.h> #include <irq_func.h> @@ -330,7 +331,12 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, } if (cmd_line) { + int max_size = 0xff; + int ret; + log_debug("Setup cmdline\n"); + if (bootproto >= 0x0206) + max_size = hdr->cmdline_size; if (bootproto >= 0x0202) { hdr->cmd_line_ptr = (uintptr_t)cmd_line; } else if (bootproto >= 0x0200) { @@ -346,6 +352,14 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, strcpy(cmd_line, (char *)cmdline_force); else build_command_line(cmd_line, auto_boot); + ret = bootm_process_cmdline(cmd_line, max_size, BOOTM_CL_ALL); + if (ret) { + printf("Cmdline setup failed (err=%d)\n", ret); + return ret; + } + printf("Kernel command line: \""); + puts(cmd_line); + printf("\"\n"); } if (IS_ENABLED(CONFIG_INTEL_MID) && bootproto >= 0x0207) diff --git a/arch/xtensa/include/asm/spl.h b/arch/xtensa/include/asm/spl.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/arch/xtensa/include/asm/spl.h diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c index 0fd9532d74..4ed06a80b7 100644 --- a/board/Arcturus/ucp1020/spl.c +++ b/board/Arcturus/ucp1020/spl.c @@ -58,7 +58,7 @@ void board_init_f(ulong bootflag) bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; gd->bus_clk = bus_clk; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, bus_clk / 16 / CONFIG_BAUDRATE); #ifdef CONFIG_SPL_MMC_BOOT puts("\nSD boot...\n"); diff --git a/board/Arcturus/ucp1020/spl_minimal.c b/board/Arcturus/ucp1020/spl_minimal.c index cd0022a73e..90abec9cce 100644 --- a/board/Arcturus/ucp1020/spl_minimal.c +++ b/board/Arcturus/ucp1020/spl_minimal.c @@ -34,7 +34,7 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, gd->bus_clk / 16 / CONFIG_BAUDRATE); puts("\nNAND boot... "); @@ -55,9 +55,9 @@ void board_init_r(gd_t *gd, ulong dest_addr) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); + ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r'); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); + ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c); } void puts(const char *str) diff --git a/board/BuR/common/bur_common.h b/board/BuR/common/bur_common.h index c64ebe93b0..79c9af1466 100644 --- a/board/BuR/common/bur_common.h +++ b/board/BuR/common/bur_common.h @@ -12,7 +12,7 @@ #define _BUR_COMMON_H_ #if !CONFIG_IS_ENABLED(DM_VIDEO) -#include <../../../drivers/video/am335x-fb.h> +#include <../../../drivers/video/ti/am335x-fb.h> int load_lcdtiming(struct am335x_lcdpanel *panel); #endif diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c index 0a5104a48f..f676d7baa6 100644 --- a/board/BuR/common/common.c +++ b/board/BuR/common/common.c @@ -27,7 +27,7 @@ DECLARE_GLOBAL_DATA_PTR; #include <asm/arch/cpu.h> #include <asm/gpio.h> #include <power/tps65217.h> -#include "../../../drivers/video/am335x-fb.h" +#include "../../../drivers/video/ti/am335x-fb.h" void lcdbacklight(int on) { diff --git a/board/Synology/ds109/ds109.c b/board/Synology/ds109/ds109.c index aa2987d924..fe3b0eb554 100644 --- a/board/Synology/ds109/ds109.c +++ b/board/Synology/ds109/ds109.c @@ -106,10 +106,11 @@ void reset_misc(void) printf("Synology reset..."); udelay(50000); - b_d = ns16550_calc_divisor((NS16550_t)CONFIG_SYS_NS16550_COM2, - CONFIG_SYS_NS16550_CLK, 9600); - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM2, b_d); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM2, SOFTWARE_REBOOT); + b_d = ns16550_calc_divisor((struct ns16550 *)CONFIG_SYS_NS16550_COM2, + CONFIG_SYS_NS16550_CLK, 9600); + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM2, b_d); + ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM2, + SOFTWARE_REBOOT); } /* Support old kernels */ diff --git a/board/armltd/integrator/integrator.c b/board/armltd/integrator/integrator.c index 19871bee14..3c56fa1c01 100644 --- a/board/armltd/integrator/integrator.c +++ b/board/armltd/integrator/integrator.c @@ -32,7 +32,7 @@ DECLARE_GLOBAL_DATA_PTR; -static const struct pl01x_serial_platdata serial_platdata = { +static const struct pl01x_serial_plat serial_plat = { .base = 0x16000000, #ifdef CONFIG_ARCH_CINTEGRATOR .type = TYPE_PL011, @@ -43,9 +43,9 @@ static const struct pl01x_serial_platdata serial_platdata = { #endif }; -U_BOOT_DEVICE(integrator_serials) = { +U_BOOT_DRVINFO(integrator_serials) = { .name = "serial_pl01x", - .platdata = &serial_platdata, + .plat = &serial_plat, }; void peripheral_power_enable (void); diff --git a/board/armltd/total_compute/total_compute.c b/board/armltd/total_compute/total_compute.c index 0be6435fe3..da24b32333 100644 --- a/board/armltd/total_compute/total_compute.c +++ b/board/armltd/total_compute/total_compute.c @@ -9,15 +9,15 @@ #include <dm/platform_data/serial_pl01x.h> #include <asm/armv8/mmu.h> -static const struct pl01x_serial_platdata serial_platdata = { +static const struct pl01x_serial_plat serial_plat = { .base = UART0_BASE, .type = TYPE_PL011, .clock = CONFIG_PL011_CLOCK, }; -U_BOOT_DEVICE(total_compute_serials) = { +U_BOOT_DRVINFO(total_compute_serials) = { .name = "serial_pl01x", - .platdata = &serial_platdata, + .plat = &serial_plat, }; static struct mm_region total_compute_mem_map[] = { diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c index 52ada0f6bc..bd66d52cb7 100644 --- a/board/armltd/vexpress64/vexpress64.c +++ b/board/armltd/vexpress64/vexpress64.c @@ -20,15 +20,15 @@ DECLARE_GLOBAL_DATA_PTR; -static const struct pl01x_serial_platdata serial_platdata = { +static const struct pl01x_serial_plat serial_plat = { .base = V2M_UART0, .type = TYPE_PL011, .clock = CONFIG_PL011_CLOCK, }; -U_BOOT_DEVICE(vexpress_serials) = { +U_BOOT_DRVINFO(vexpress_serials) = { .name = "serial_pl01x", - .platdata = &serial_platdata, + .plat = &serial_plat, }; static struct mm_region vexpress64_mem_map[] = { diff --git a/board/atmel/sama7g5ek/Kconfig b/board/atmel/sama7g5ek/Kconfig new file mode 100644 index 0000000000..a89db8d8a8 --- /dev/null +++ b/board/atmel/sama7g5ek/Kconfig @@ -0,0 +1,15 @@ +if TARGET_SAMA7G5EK + +config SYS_BOARD + default "sama7g5ek" + +config SYS_VENDOR + default "atmel" + +config SYS_SOC + default "at91" + +config SYS_CONFIG_NAME + default "sama7g5ek" + +endif diff --git a/board/atmel/sama7g5ek/MAINTAINERS b/board/atmel/sama7g5ek/MAINTAINERS new file mode 100644 index 0000000000..eac972968d --- /dev/null +++ b/board/atmel/sama7g5ek/MAINTAINERS @@ -0,0 +1,8 @@ +SAMA7G5 EK BOARD +M: Eugen Hristev <eugen.hristev@microchip.com> +S: Maintained +F: board/atmel/sama7g5ek.c +F: include/configs/sama7g5ek.h +F: configs/sama7g5ek_mmc1_defconfig +F: configs/sama7g5ek_mmc_defconfig + diff --git a/board/atmel/sama7g5ek/Makefile b/board/atmel/sama7g5ek/Makefile new file mode 100644 index 0000000000..a6eedd10fa --- /dev/null +++ b/board/atmel/sama7g5ek/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Microchip Technology Inc. +# Eugen Hristev <eugen.hristev@microchip.com> +# + +obj-y += sama7g5ek.o diff --git a/board/atmel/sama7g5ek/sama7g5ek.c b/board/atmel/sama7g5ek/sama7g5ek.c new file mode 100644 index 0000000000..b5cece08ac --- /dev/null +++ b/board/atmel/sama7g5ek/sama7g5ek.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Microchip Technology, Inc. + * Eugen Hristev <eugen.hristev@microchip.com> + */ + +#include <common.h> +#include <debug_uart.h> +#include <init.h> +#include <asm/io.h> +#include <asm/arch/at91_common.h> +#include <asm/arch/atmel_pio4.h> +#include <asm/arch/clk.h> +#include <asm/arch/gpio.h> +#include <asm/arch/sama7g5.h> + +DECLARE_GLOBAL_DATA_PTR; + +int board_late_init(void) +{ + return 0; +} + +#if (IS_ENABLED(CONFIG_DEBUG_UART_BOARD_INIT)) +static void board_uart0_hw_init(void) +{ + /* FLEXCOM3 IO0 */ + atmel_pio4_set_f_periph(AT91_PIO_PORTD, 17, ATMEL_PIO_PUEN_MASK); + /* FLEXCOM3 IO1 */ + atmel_pio4_set_f_periph(AT91_PIO_PORTD, 16, 0); + + at91_periph_clk_enable(ATMEL_ID_FLEXCOM3); +} + +void board_debug_uart_init(void) +{ + board_uart0_hw_init(); +} +#endif + +int board_early_init_f(void) +{ +#if (IS_ENABLED(CONFIG_DEBUG_UART)) + debug_uart_init(); +#endif + return 0; +} + +#define MAC24AA_MAC_OFFSET 0xfa + +#if (IS_ENABLED(CONFIG_MISC_INIT_R)) +int misc_init_r(void) +{ +#if (IS_ENABLED(CONFIG_I2C_EEPROM)) + at91_set_ethaddr(MAC24AA_MAC_OFFSET); + at91_set_eth1addr(MAC24AA_MAC_OFFSET); +#endif + return 0; +} +#endif + +int board_init(void) +{ + /* address of boot parameters */ + gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; + + return 0; +} + +int dram_init(void) +{ + gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, + CONFIG_SYS_SDRAM_SIZE); + return 0; +} + diff --git a/board/bluewater/gurnard/gurnard.c b/board/bluewater/gurnard/gurnard.c index dc9871d446..17ecdb679e 100644 --- a/board/bluewater/gurnard/gurnard.c +++ b/board/bluewater/gurnard/gurnard.c @@ -348,7 +348,7 @@ int board_init(void) uclass_find_first_device(UCLASS_VIDEO, &dev); if (dev) { - struct atmel_lcd_platdata *plat = dev_get_platdata(dev); + struct atmel_lcd_plat *plat = dev_get_plat(dev); plat->timing_index = 1; } @@ -416,11 +416,11 @@ void reset_phy(void) { } -static struct atmel_serial_platdata at91sam9260_serial_plat = { +static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE(at91sam9260_serial) = { +U_BOOT_DRVINFO(at91sam9260_serial) = { .name = "serial_atmel", - .platdata = &at91sam9260_serial_plat, + .plat = &at91sam9260_serial_plat, }; diff --git a/board/bluewater/snapper9260/snapper9260.c b/board/bluewater/snapper9260/snapper9260.c index 9b0a75ac5d..58fab15c11 100644 --- a/board/bluewater/snapper9260/snapper9260.c +++ b/board/bluewater/snapper9260/snapper9260.c @@ -143,11 +143,11 @@ void reset_phy(void) { } -static struct atmel_serial_platdata at91sam9260_serial_plat = { +static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE(at91sam9260_serial) = { +U_BOOT_DRVINFO(at91sam9260_serial) = { .name = "serial_atmel", - .platdata = &at91sam9260_serial_plat, + .plat = &at91sam9260_serial_plat, }; diff --git a/board/cadence/xtfpga/xtfpga.c b/board/cadence/xtfpga/xtfpga.c index 5811c43142..c26793d76c 100644 --- a/board/cadence/xtfpga/xtfpga.c +++ b/board/cadence/xtfpga/xtfpga.c @@ -93,7 +93,7 @@ int misc_init_r(void) return 0; } -U_BOOT_DEVICE(sysreset) = { +U_BOOT_DRVINFO(sysreset) = { .name = "xtfpga_sysreset", }; @@ -104,7 +104,7 @@ static struct ethoc_eth_pdata ethoc_pdata = { .packet_base = CONFIG_SYS_ETHOC_BUFFER_ADDR, }; -U_BOOT_DEVICE(ethoc) = { +U_BOOT_DRVINFO(ethoc) = { .name = "ethoc", - .platdata = ðoc_pdata, + .plat = ðoc_pdata, }; diff --git a/board/cavium/thunderx/thunderx.c b/board/cavium/thunderx/thunderx.c index f8c2913eac..fd23472898 100644 --- a/board/cavium/thunderx/thunderx.c +++ b/board/cavium/thunderx/thunderx.c @@ -18,28 +18,28 @@ #if !CONFIG_IS_ENABLED(OF_CONTROL) #include <dm/platform_data/serial_pl01x.h> -static const struct pl01x_serial_platdata serial0 = { +static const struct pl01x_serial_plat serial0 = { .base = CONFIG_SYS_SERIAL0, .type = TYPE_PL011, .clock = 0, .skip_init = true, }; -U_BOOT_DEVICE(thunderx_serial0) = { +U_BOOT_DRVINFO(thunderx_serial0) = { .name = "serial_pl01x", - .platdata = &serial0, + .plat = &serial0, }; -static const struct pl01x_serial_platdata serial1 = { +static const struct pl01x_serial_plat serial1 = { .base = CONFIG_SYS_SERIAL1, .type = TYPE_PL011, .clock = 0, .skip_init = true, }; -U_BOOT_DEVICE(thunderx_serial1) = { +U_BOOT_DRVINFO(thunderx_serial1) = { .name = "serial_pl01x", - .platdata = &serial1, + .plat = &serial1, }; #endif diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index e2712680f9..7520e96e07 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -724,13 +724,13 @@ u32 get_board_rev(void) return cl_eeprom_get_board_rev(CONFIG_SYS_I2C_EEPROM_BUS); } -static struct mxc_serial_platdata cm_fx6_mxc_serial_plat = { +static struct mxc_serial_plat cm_fx6_mxc_serial_plat = { .reg = (struct mxc_uart *)UART4_BASE, }; -U_BOOT_DEVICE(cm_fx6_serial) = { +U_BOOT_DRVINFO(cm_fx6_serial) = { .name = "serial_mxc", - .platdata = &cm_fx6_mxc_serial_plat, + .plat = &cm_fx6_mxc_serial_plat, }; #if CONFIG_IS_ENABLED(AHCI) diff --git a/board/davinci/da8xxevm/omapl138_lcdk.c b/board/davinci/da8xxevm/omapl138_lcdk.c index 6bab7b18d4..a08858550d 100644 --- a/board/davinci/da8xxevm/omapl138_lcdk.c +++ b/board/davinci/da8xxevm/omapl138_lcdk.c @@ -356,19 +356,19 @@ int board_mmc_init(struct bd_info *bis) #endif #ifdef CONFIG_SPL_BUILD -static const struct ns16550_platdata serial_pdata = { +static const struct ns16550_plat serial_pdata = { .base = DAVINCI_UART2_BASE, .reg_shift = 2, .clock = 228000000, .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE(omapl138_uart) = { +U_BOOT_DRVINFO(omapl138_uart) = { .name = "ns16550_serial", - .platdata = &serial_pdata, + .plat = &serial_pdata, }; -static const struct davinci_mmc_plat mmc_platdata = { +static const struct davinci_mmc_plat mmc_plat = { .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE, .cfg = { .f_min = 200000, @@ -379,9 +379,9 @@ static const struct davinci_mmc_plat mmc_platdata = { .name = "da830-mmc", }, }; -U_BOOT_DEVICE(omapl138_mmc) = { +U_BOOT_DRVINFO(omapl138_mmc) = { .name = "ti_da830_mmc", - .platdata = &mmc_platdata, + .plat = &mmc_plat, }; void spl_board_init(void) diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index f42d395098..35669c252b 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -343,7 +343,7 @@ int g_dnl_board_usb_cable_connected(void) int ret; ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC, - DM_GET_DRIVER(dwc2_udc_otg), + DM_DRIVER_GET(dwc2_udc_otg), &dwc2_udc_otg); if (!ret) debug("dwc2_udc_otg init failed\n"); @@ -475,11 +475,11 @@ static void sysconf_init(void) * but this value need to be consistent with board design */ ret = uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(stm32mp_pwr_pmic), + DM_DRIVER_GET(stm32mp_pwr_pmic), &pwr_dev); if (!ret) { ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) { pr_err("Can't find stm32mp_bsec driver\n"); diff --git a/board/emulation/common/Kconfig b/board/emulation/common/Kconfig new file mode 100644 index 0000000000..4c15c8bcb8 --- /dev/null +++ b/board/emulation/common/Kconfig @@ -0,0 +1,15 @@ +config MTDPARTS_NOR0 + string "mtd boot partition for nor0" + default "64m(u-boot)" if TARGET_QEMU_ARM_64BIT && !TFABOOT + depends on SYS_MTDPARTS_RUNTIME + help + This define the partition of nor0 used to build mtparts dynamically + for boot from nor0. + +config MTDPARTS_NOR1 + string "mtd u-boot env partition for nor1" + default "64m(u-boot-env)" if TARGET_QEMU_ARM_64BIT && !TFABOOT + depends on SYS_MTDPARTS_RUNTIME + help + This define the partition of nor1 used to build mtparts dynamically + for the u-boot env stored on nor1. diff --git a/board/emulation/common/Makefile b/board/emulation/common/Makefile new file mode 100644 index 0000000000..7ed447a69d --- /dev/null +++ b/board/emulation/common/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += qemu_mtdparts.o +obj-$(CONFIG_SET_DFU_ALT_INFO) += qemu_dfu.o +obj-$(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) += qemu_capsule.o diff --git a/board/emulation/common/qemu_capsule.c b/board/emulation/common/qemu_capsule.c new file mode 100644 index 0000000000..f1d403501a --- /dev/null +++ b/board/emulation/common/qemu_capsule.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Linaro Limited + */ + +#include <common.h> +#include <efi_api.h> +#include <efi_loader.h> +#include <env.h> +#include <fdtdec.h> + +DECLARE_GLOBAL_DATA_PTR; + +int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len) +{ + const void *fdt_blob = gd->fdt_blob; + const void *blob; + const char *cnode_name = "capsule-key"; + const char *snode_name = "signature"; + int sig_node; + int len; + + sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name); + if (sig_node < 0) { + EFI_PRINT("Unable to get signature node offset\n"); + return -FDT_ERR_NOTFOUND; + } + + blob = fdt_getprop(fdt_blob, sig_node, cnode_name, &len); + + if (!blob || len < 0) { + EFI_PRINT("Unable to get capsule-key value\n"); + *pkey = NULL; + *pkey_len = 0; + return -FDT_ERR_NOTFOUND; + } + + *pkey = (void *)blob; + *pkey_len = len; + + return 0; +} + +bool efi_capsule_auth_enabled(void) +{ + return env_get("capsule_authentication_enabled") != NULL ? + true : false; +} diff --git a/board/emulation/common/qemu_dfu.c b/board/emulation/common/qemu_dfu.c new file mode 100644 index 0000000000..62234a7647 --- /dev/null +++ b/board/emulation/common/qemu_dfu.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Linaro Limited + */ + +#include <common.h> +#include <dfu.h> +#include <env.h> +#include <memalign.h> +#include <mtd.h> + +#define DFU_ALT_BUF_LEN SZ_1K + +static void board_get_alt_info(struct mtd_info *mtd, char *buf) +{ + struct mtd_info *part; + bool first = true; + const char *name; + int len, partnum = 0; + + name = mtd->name; + len = strlen(buf); + + if (buf[0] != '\0') + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, "&"); + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "mtd %s=", name); + + list_for_each_entry(part, &mtd->partitions, node) { + partnum++; + if (!first) + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";"); + first = false; + + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s part %d", + part->name, partnum); + } +} + +void set_dfu_alt_info(char *interface, char *devstr) +{ + struct mtd_info *mtd; + + ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); + + if (env_get("dfu_alt_info")) + return; + + memset(buf, 0, sizeof(buf)); + + /* + * Currently dfu_alt_info is needed on Qemu ARM64 for + * capsule updates + */ + if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) && + IS_ENABLED(CONFIG_TARGET_QEMU_ARM_64BIT)) { + /* probe all MTD devices */ + mtd_probe_devices(); + + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) + board_get_alt_info(mtd, buf); + } + + env_set("dfu_alt_info", buf); + printf("dfu_alt_info set\n"); +} diff --git a/board/emulation/common/qemu_mtdparts.c b/board/emulation/common/qemu_mtdparts.c new file mode 100644 index 0000000000..60212e97ac --- /dev/null +++ b/board/emulation/common/qemu_mtdparts.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Linaro Limited + */ + +#include <common.h> +#include <dm.h> +#include <mtd.h> + +#include <linux/string.h> + +#define MTDPARTS_LEN 256 +#define MTDIDS_LEN 128 + +static void board_get_mtdparts(const char *dev, const char *partition, + char *mtdids, char *mtdparts) +{ + /* mtdids: "<dev>=<dev>, ...." */ + if (mtdids[0] != '\0') + strcat(mtdids, ","); + strcat(mtdids, dev); + strcat(mtdids, "="); + strcat(mtdids, dev); + + /* mtdparts: "mtdparts=<dev>:<mtdparts_<dev>>;..." */ + if (mtdparts[0] != '\0') + strncat(mtdparts, ";", MTDPARTS_LEN); + else + strcat(mtdparts, "mtdparts="); + + strncat(mtdparts, dev, MTDPARTS_LEN); + strncat(mtdparts, ":", MTDPARTS_LEN); + strncat(mtdparts, partition, MTDPARTS_LEN); +} + +void board_mtdparts_default(const char **mtdids, const char **mtdparts) +{ + struct mtd_info *mtd; + struct udevice *dev; + const char *mtd_partition; + static char parts[3 * MTDPARTS_LEN + 1]; + static char ids[MTDIDS_LEN + 1]; + static bool mtd_initialized; + + if (mtd_initialized) { + *mtdids = ids; + *mtdparts = parts; + return; + } + + memset(parts, 0, sizeof(parts)); + memset(ids, 0, sizeof(ids)); + + /* Currently mtdparts is needed on Qemu ARM64 for capsule updates */ + if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) && + IS_ENABLED(CONFIG_TARGET_QEMU_ARM_64BIT)) { + /* probe all MTD devices */ + for (uclass_first_device(UCLASS_MTD, &dev); dev; + uclass_next_device(&dev)) { + debug("mtd device = %s\n", dev->name); + } + + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) { + mtd_partition = CONFIG_MTDPARTS_NOR0; + board_get_mtdparts("nor0", mtd_partition, ids, parts); + put_mtd_device(mtd); + } + + mtd = get_mtd_device_nm("nor1"); + if (!IS_ERR_OR_NULL(mtd)) { + mtd_partition = CONFIG_MTDPARTS_NOR1; + board_get_mtdparts("nor1", mtd_partition, ids, parts); + put_mtd_device(mtd); + } + } + + mtd_initialized = true; + *mtdids = ids; + *mtdparts = parts; + debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts); +} diff --git a/board/emulation/qemu-arm/Kconfig b/board/emulation/qemu-arm/Kconfig index 02ae4d9884..fb8d38f5b8 100644 --- a/board/emulation/qemu-arm/Kconfig +++ b/board/emulation/qemu-arm/Kconfig @@ -11,3 +11,11 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIRTIO_BLK endif + +if TARGET_QEMU_ARM_64BIT && !TFABOOT +config BOARD_SPECIFIC_OPTIONS + imply SYS_MTDPARTS_RUNTIME + imply SET_DFU_ALT_INFO + +source "board/emulation/common/Kconfig" +endif diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index f18f2ed7da..aa68bef469 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -65,6 +65,11 @@ struct mm_region *mem_map = qemu_arm64_mem_map; int board_init(void) { + return 0; +} + +int board_late_init(void) +{ /* * Make sure virtio bus is enumerated so that peripherals * on the virtio bus can be discovered by their drivers diff --git a/board/freescale/ls1012afrdm/eth.c b/board/freescale/ls1012afrdm/eth.c index eaea1c46e4..d2df9351ea 100644 --- a/board/freescale/ls1012afrdm/eth.c +++ b/board/freescale/ls1012afrdm/eth.c @@ -114,12 +114,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE(ls1012a_pfe0) = { +U_BOOT_DRVINFO(ls1012a_pfe0) = { .name = "pfe_eth", - .platdata = &pfe_pdata0, + .plat = &pfe_pdata0, }; -U_BOOT_DEVICE(ls1012a_pfe1) = { +U_BOOT_DRVINFO(ls1012a_pfe1) = { .name = "pfe_eth", - .platdata = &pfe_pdata1, + .plat = &pfe_pdata1, }; diff --git a/board/freescale/ls1012aqds/eth.c b/board/freescale/ls1012aqds/eth.c index b4ef60738e..8189f41bec 100644 --- a/board/freescale/ls1012aqds/eth.c +++ b/board/freescale/ls1012aqds/eth.c @@ -298,12 +298,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE(ls1012a_pfe0) = { +U_BOOT_DRVINFO(ls1012a_pfe0) = { .name = "pfe_eth", - .platdata = &pfe_pdata0, + .plat = &pfe_pdata0, }; -U_BOOT_DEVICE(ls1012a_pfe1) = { +U_BOOT_DRVINFO(ls1012a_pfe1) = { .name = "pfe_eth", - .platdata = &pfe_pdata1, + .plat = &pfe_pdata1, }; diff --git a/board/freescale/ls1012ardb/eth.c b/board/freescale/ls1012ardb/eth.c index a65ff4dc9c..2241d061dd 100644 --- a/board/freescale/ls1012ardb/eth.c +++ b/board/freescale/ls1012ardb/eth.c @@ -160,12 +160,12 @@ static struct pfe_eth_pdata pfe_pdata1 = { }, }; -U_BOOT_DEVICE(ls1012a_pfe0) = { +U_BOOT_DRVINFO(ls1012a_pfe0) = { .name = "pfe_eth", - .platdata = &pfe_pdata0, + .plat = &pfe_pdata0, }; -U_BOOT_DEVICE(ls1012a_pfe1) = { +U_BOOT_DRVINFO(ls1012a_pfe1) = { .name = "pfe_eth", - .platdata = &pfe_pdata1, + .plat = &pfe_pdata1, }; diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c index 222906fdff..ea027bec56 100644 --- a/board/freescale/lx2160a/lx2160a.c +++ b/board/freescale/lx2160a/lx2160a.c @@ -52,7 +52,7 @@ DECLARE_GLOBAL_DATA_PTR; -static struct pl01x_serial_platdata serial0 = { +static struct pl01x_serial_plat serial0 = { #if CONFIG_CONS_INDEX == 0 .base = CONFIG_SYS_SERIAL0, #elif CONFIG_CONS_INDEX == 1 @@ -63,19 +63,19 @@ static struct pl01x_serial_platdata serial0 = { .type = TYPE_PL011, }; -U_BOOT_DEVICE(nxp_serial0) = { +U_BOOT_DRVINFO(nxp_serial0) = { .name = "serial_pl01x", - .platdata = &serial0, + .plat = &serial0, }; -static struct pl01x_serial_platdata serial1 = { +static struct pl01x_serial_plat serial1 = { .base = CONFIG_SYS_SERIAL1, .type = TYPE_PL011, }; -U_BOOT_DEVICE(nxp_serial1) = { +U_BOOT_DRVINFO(nxp_serial1) = { .name = "serial_pl01x", - .platdata = &serial1, + .plat = &serial1, }; int select_i2c_ch_pca9547(u8 ch) diff --git a/board/freescale/mpc8313erdb/mpc8313erdb.c b/board/freescale/mpc8313erdb/mpc8313erdb.c index 65a10c345a..7e1a31f265 100644 --- a/board/freescale/mpc8313erdb/mpc8313erdb.c +++ b/board/freescale/mpc8313erdb/mpc8313erdb.c @@ -132,7 +132,7 @@ int ft_board_setup(void *blob, struct bd_info *bd) void board_init_f(ulong bootflag) { board_early_init_f(); - NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), + ns16550_init((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); puts("NAND boot... "); timer_init(); @@ -152,8 +152,8 @@ void putc(char c) return; if (c == '\n') - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r'); + ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), '\r'); - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c); + ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), c); } #endif diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c index f8e4599f13..05b983a3f2 100644 --- a/board/freescale/mpc8315erdb/mpc8315erdb.c +++ b/board/freescale/mpc8315erdb/mpc8315erdb.c @@ -220,7 +220,7 @@ int checkboard(void) void board_init_f(ulong bootflag) { board_early_init_f(); - NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), + ns16550_init((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); puts("NAND boot... "); timer_init(); @@ -240,9 +240,9 @@ void putc(char c) return; if (c == '\n') - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r'); + ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), '\r'); - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c); + ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), c); } #endif /* CONFIG_NAND_SPL */ diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c index fbaa6a6514..35b95e0838 100644 --- a/board/freescale/p1010rdb/spl.c +++ b/board/freescale/p1010rdb/spl.c @@ -44,7 +44,7 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, gd->bus_clk / 16 / CONFIG_BAUDRATE); #ifdef CONFIG_SPL_MMC_BOOT diff --git a/board/freescale/p1010rdb/spl_minimal.c b/board/freescale/p1010rdb/spl_minimal.c index 0bb2c83872..989c5b139a 100644 --- a/board/freescale/p1010rdb/spl_minimal.c +++ b/board/freescale/p1010rdb/spl_minimal.c @@ -31,8 +31,8 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, - gd->bus_clk / 16 / CONFIG_BAUDRATE); + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, + gd->bus_clk / 16 / CONFIG_BAUDRATE); puts("\nNAND boot... "); @@ -53,9 +53,9 @@ void board_init_r(gd_t *gd, ulong dest_addr) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); + ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r'); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); + ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c); } void puts(const char *str) diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c index 8aceceb56a..b16f701ae1 100644 --- a/board/freescale/p1_p2_rdb_pc/spl.c +++ b/board/freescale/p1_p2_rdb_pc/spl.c @@ -50,7 +50,7 @@ void board_init_f(ulong bootflag) bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; gd->bus_clk = bus_clk; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, bus_clk / 16 / CONFIG_BAUDRATE); #ifdef CONFIG_SPL_MMC_BOOT puts("\nSD boot...\n"); diff --git a/board/freescale/p1_p2_rdb_pc/spl_minimal.c b/board/freescale/p1_p2_rdb_pc/spl_minimal.c index ced5f3c3b5..eb3f2c83fa 100644 --- a/board/freescale/p1_p2_rdb_pc/spl_minimal.c +++ b/board/freescale/p1_p2_rdb_pc/spl_minimal.c @@ -30,8 +30,8 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, - gd->bus_clk / 16 / CONFIG_BAUDRATE); + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, + gd->bus_clk / 16 / CONFIG_BAUDRATE); puts("\nNAND boot... "); @@ -51,9 +51,9 @@ void board_init_r(gd_t *gd, ulong dest_addr) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); + ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r'); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); + ns16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c); } void puts(const char *str) diff --git a/board/freescale/t102xrdb/spl.c b/board/freescale/t102xrdb/spl.c index 09dd88ac4e..66d2f3bda7 100644 --- a/board/freescale/t102xrdb/spl.c +++ b/board/freescale/t102xrdb/spl.c @@ -82,7 +82,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); #if defined(CONFIG_SPL_MMC_BOOT) diff --git a/board/freescale/t104xrdb/spl.c b/board/freescale/t104xrdb/spl.c index e7922954de..28ac12a1fd 100644 --- a/board/freescale/t104xrdb/spl.c +++ b/board/freescale/t104xrdb/spl.c @@ -81,7 +81,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; uart_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, uart_clk / 16 / CONFIG_BAUDRATE); relocate_code(CONFIG_SPL_RELOC_STACK, (gd_t *)CONFIG_SPL_GD_ADDR, 0x0); diff --git a/board/freescale/t208xqds/spl.c b/board/freescale/t208xqds/spl.c index d8c2bbe28d..13e61f083f 100644 --- a/board/freescale/t208xqds/spl.c +++ b/board/freescale/t208xqds/spl.c @@ -81,7 +81,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); #if defined(CONFIG_SPL_MMC_BOOT) diff --git a/board/freescale/t208xrdb/spl.c b/board/freescale/t208xrdb/spl.c index c64bd87115..2bba94da7b 100644 --- a/board/freescale/t208xrdb/spl.c +++ b/board/freescale/t208xrdb/spl.c @@ -51,7 +51,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); #if defined(CONFIG_SPL_MMC_BOOT) diff --git a/board/freescale/t4rdb/spl.c b/board/freescale/t4rdb/spl.c index 9aa0a9b052..fc624efbe6 100644 --- a/board/freescale/t4rdb/spl.c +++ b/board/freescale/t4rdb/spl.c @@ -60,7 +60,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); puts("\nSD boot...\n"); diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index 9f043d815a..048f624c35 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -1371,11 +1371,11 @@ int ft_board_setup(void *blob, struct bd_info *bd) } #endif /* CONFIG_OF_BOARD_SETUP */ -static struct mxc_serial_platdata ventana_mxc_serial_plat = { +static struct mxc_serial_plat ventana_mxc_serial_plat = { .reg = (struct mxc_uart *)UART2_BASE, }; -U_BOOT_DEVICE(ventana_serial) = { +U_BOOT_DRVINFO(ventana_serial) = { .name = "serial_mxc", - .platdata = &ventana_mxc_serial_plat, + .plat = &ventana_mxc_serial_plat, }; diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c index b8b923c139..34b2c2ac5d 100644 --- a/board/google/chromebook_coral/coral.c +++ b/board/google/chromebook_coral/coral.c @@ -143,14 +143,16 @@ struct acpi_ops coral_acpi_ops = { .inject_dsdt = chromeos_acpi_gpio_generate, }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id coral_ids[] = { { .compatible = "google,coral" }, { } }; +#endif U_BOOT_DRIVER(coral_drv) = { .name = "coral", .id = UCLASS_SYSINFO, - .of_match = coral_ids, + .of_match = of_match_ptr(coral_ids), ACPI_OPS_PTR(&coral_acpi_ops) }; diff --git a/board/google/gru/gru.c b/board/google/gru/gru.c index 441a1a376a..23080c1798 100644 --- a/board/google/gru/gru.c +++ b/board/google/gru/gru.c @@ -45,7 +45,7 @@ int board_early_init_r(void) * setting up. */ ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(clk_rk3399), &clk); + DM_DRIVER_GET(clk_rk3399), &clk); if (ret) { debug("%s: CLK init failed: %d\n", __func__, ret); return ret; diff --git a/board/hisilicon/hikey/hikey.c b/board/hisilicon/hikey/hikey.c index e89ff1a43d..65a8179adb 100644 --- a/board/hisilicon/hikey/hikey.c +++ b/board/hisilicon/hikey/hikey.c @@ -26,7 +26,7 @@ #include <asm/armv8/mmu.h> /*TODO drop this table in favour of device tree */ -static const struct hikey_gpio_platdata hi6220_gpio[] = { +static const struct hikey_gpio_plat hi6220_gpio[] = { { 0, HI6220_GPIO_BASE(0)}, { 1, HI6220_GPIO_BASE(1)}, { 2, HI6220_GPIO_BASE(2)}, @@ -50,7 +50,7 @@ static const struct hikey_gpio_platdata hi6220_gpio[] = { }; -U_BOOT_DEVICES(hi6220_gpios) = { +U_BOOT_DRVINFOS(hi6220_gpios) = { { "gpio_hi6220", &hi6220_gpio[0] }, { "gpio_hi6220", &hi6220_gpio[1] }, { "gpio_hi6220", &hi6220_gpio[2] }, @@ -77,7 +77,7 @@ DECLARE_GLOBAL_DATA_PTR; #if !CONFIG_IS_ENABLED(OF_CONTROL) -static const struct pl01x_serial_platdata serial_platdata = { +static const struct pl01x_serial_plat serial_plat = { #if CONFIG_CONS_INDEX == 1 .base = HI6220_UART0_BASE, #elif CONFIG_CONS_INDEX == 4 @@ -89,9 +89,9 @@ static const struct pl01x_serial_platdata serial_platdata = { .clock = 19200000 }; -U_BOOT_DEVICE(hikey_seriala) = { +U_BOOT_DRVINFO(hikey_seriala) = { .name = "serial_pl01x", - .platdata = &serial_platdata, + .plat = &serial_plat, }; #endif diff --git a/board/hisilicon/hikey960/hikey960.c b/board/hisilicon/hikey960/hikey960.c index db485db10a..3fe4c60d02 100644 --- a/board/hisilicon/hikey960/hikey960.c +++ b/board/hisilicon/hikey960/hikey960.c @@ -26,15 +26,15 @@ DECLARE_GLOBAL_DATA_PTR; #if !CONFIG_IS_ENABLED(OF_CONTROL) #include <dm/platform_data/serial_pl01x.h> -static const struct pl01x_serial_platdata serial_platdata = { +static const struct pl01x_serial_plat serial_plat = { .base = HI3660_UART6_BASE, .type = TYPE_PL011, .clock = 19200000 }; -U_BOOT_DEVICE(hikey960_serial0) = { +U_BOOT_DRVINFO(hikey960_serial0) = { .name = "serial_pl01x", - .platdata = &serial_platdata, + .plat = &serial_plat, }; #endif diff --git a/board/hisilicon/poplar/poplar.c b/board/hisilicon/poplar/poplar.c index 371c3c33fc..bfb2c66a17 100644 --- a/board/hisilicon/poplar/poplar.c +++ b/board/hisilicon/poplar/poplar.c @@ -40,15 +40,15 @@ static struct mm_region poplar_mem_map[] = { struct mm_region *mem_map = poplar_mem_map; #if !CONFIG_IS_ENABLED(OF_CONTROL) -static const struct pl01x_serial_platdata serial_platdata = { +static const struct pl01x_serial_plat serial_plat = { .base = REG_BASE_UART0, .type = TYPE_PL010, .clock = 75000000, }; -U_BOOT_DEVICE(poplar_serial) = { +U_BOOT_DRVINFO(poplar_serial) = { .name = "serial_pl01x", - .platdata = &serial_platdata, + .plat = &serial_plat, }; #endif diff --git a/board/intel/galileo/galileo.c b/board/intel/galileo/galileo.c index 720350d0f7..341b627a65 100644 --- a/board/intel/galileo/galileo.c +++ b/board/intel/galileo/galileo.c @@ -12,7 +12,7 @@ * Intel Galileo gen2 board uses GPIO Resume Well bank pin0 as the PERST# pin. * * We cannot use any public GPIO APIs in <asm-generic/gpio.h> to control this - * pin, as these APIs will eventually call into gpio_ich6_ofdata_to_platdata() + * pin, as these APIs will eventually call into gpio_ich6_of_to_plat() * in the Intel ICH6 GPIO driver where it calls PCI configuration space access * APIs which will trigger PCI enumeration process. * diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c index e0ca3c2588..0932f62b9b 100644 --- a/board/isee/igep00x0/igep00x0.c +++ b/board/isee/igep00x0/igep00x0.c @@ -29,14 +29,14 @@ #include <fdt_support.h> #include "igep00x0.h" -static const struct ns16550_platdata igep_serial = { +static const struct ns16550_plat igep_serial = { .base = OMAP34XX_UART3, .reg_shift = 2, .clock = V_NS16550_CLK, .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE(igep_uart) = { +U_BOOT_DRVINFO(igep_uart) = { "ns16550_serial", &igep_serial }; diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 03c7ce9da7..df507e2790 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -56,7 +56,7 @@ int set_km_env(void) /* try to read rootfssize (ram image) from environment */ p = env_get("rootfssize"); - if (p != NULL) + if (p) strict_strtoul(p, 16, &rootfssize); pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM + CONFIG_KM_PNVRAM) / 0x400; @@ -165,7 +165,7 @@ static int do_setboardid(struct cmd_tbl *cmdtp, int flag, int argc, char *p; p = get_local_var("IVM_BoardId"); - if (p == NULL) { + if (!p) { printf("can't get the IVM_Boardid\n"); return 1; } @@ -174,7 +174,7 @@ static int do_setboardid(struct cmd_tbl *cmdtp, int flag, int argc, printf("set boardid=%s\n", buf); p = get_local_var("IVM_HWKey"); - if (p == NULL) { + if (!p) { printf("can't get the IVM_HWKey\n"); return 1; } @@ -186,8 +186,8 @@ static int do_setboardid(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } -U_BOOT_CMD(km_setboardid, 1, 0, do_setboardid, "setboardid", "read out bid and " - "hwkey from IVM and set in environment"); +U_BOOT_CMD(km_setboardid, 1, 0, do_setboardid, "setboardid", + "read out bid and hwkey from IVM and set in environment"); /* * command km_checkbidhwk @@ -218,14 +218,14 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, * already stored in the local hush variables */ p = get_local_var("IVM_BoardId"); - if (p == NULL) { + if (!p) { printf("can't get the IVM_Boardid\n"); return 1; } rc = strict_strtoul(p, 16, &ivmbid); p = get_local_var("IVM_HWKey"); - if (p == NULL) { + if (!p) { printf("can't get the IVM_HWKey\n"); return 1; } @@ -238,10 +238,10 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, /* now try to read values from environment if available */ p = env_get("boardid"); - if (p != NULL) + if (p) rc = strict_strtoul(p, 16, &envbid); p = env_get("hwkey"); - if (p != NULL) + if (p) rc = strict_strtoul(p, 16, &envhwkey); if (rc != 0) { @@ -263,9 +263,8 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, if (verbose) { printf("IVM_BoardId: %ld, IVM_HWKey=%ld\n", - ivmbid, ivmhwkey); - printf("boardIdHwKeyList: %s\n", - bidhwklist); + ivmbid, ivmhwkey); + printf("boardIdHwKeyList: %s\n", bidhwklist); } while (!found) { /* loop over each bid/hwkey pair in the list */ @@ -291,13 +290,13 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, while (*rest && !isxdigit(*rest)) rest++; } - if ((!bid) || (!hwkey)) { + if (!bid || !hwkey) { /* end of list */ break; } if (verbose) { printf("trying bid=0x%lX, hwkey=%ld\n", - bid, hwkey); + bid, hwkey); } /* * Compare the values of the found entry in the @@ -305,7 +304,7 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, * in the inventory eeprom. If they are equal * set the values in environment variables. */ - if ((bid == ivmbid) && (hwkey == ivmhwkey)) { + if (bid == ivmbid && hwkey == ivmhwkey) { char buf[10]; found = 1; @@ -321,12 +320,12 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, } /* compare now the values */ - if ((ivmbid == envbid) && (ivmhwkey == envhwkey)) { + if (ivmbid == envbid && ivmhwkey == envhwkey) { printf("boardid=0x%3lX, hwkey=%ld\n", envbid, envhwkey); rc = 0; /* match */ } else { printf("Error: env boardid=0x%3lX, hwkey=%ld\n", envbid, - envhwkey); + envhwkey); printf(" IVM bId=0x%3lX, hwKey=%ld\n", ivmbid, ivmhwkey); rc = 1; /* don't match */ } @@ -334,10 +333,8 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int flag, int argc, } U_BOOT_CMD(km_checkbidhwk, 2, 0, do_checkboardidhwk, - "check boardid and hwkey", - "[v]\n - check environment parameter "\ - "\"boardIdListHex\" against stored boardid and hwkey "\ - "from the IVM\n v: verbose output" + "check boardid and hwkey", + "[v]\n - check environment parameter \"boardIdListHex\" against stored boardid and hwkey from the IVM\n v: verbose output" ); /* @@ -356,6 +353,7 @@ static int do_checktestboot(struct cmd_tbl *cmdtp, int flag, int argc, #if defined(CONFIG_POST) testpin = post_hotkeys_pressed(); #endif + s = env_get("test_bank"); /* when test_bank is not set, act as if testpin is not asserted */ testboot = (testpin != 0) && (s); @@ -370,6 +368,6 @@ static int do_checktestboot(struct cmd_tbl *cmdtp, int flag, int argc, } U_BOOT_CMD(km_checktestboot, 2, 0, do_checktestboot, - "check if testpin is asserted", - "[v]\n v - verbose output" + "check if testpin is asserted", + "[v]\n v - verbose output" ); diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c index 60b89fe348..e989bf609f 100644 --- a/board/keymile/common/ivm.c +++ b/board/keymile/common/ivm.c @@ -46,28 +46,27 @@ static int ivm_set_value(char *name, char *value) { char tempbuf[256]; - if (value != NULL) { + if (value) { sprintf(tempbuf, "%s=%s", name, value); return set_local_var(tempbuf, 0); - } else { - unset_local_var(name); } + unset_local_var(name); return 0; } static int ivm_get_value(unsigned char *buf, int len, char *name, int off, - int check) + int check) { unsigned short val; unsigned char valbuf[30]; - if ((buf[off + 0] != buf[off + 2]) && - (buf[off + 2] != buf[off + 4])) { + if (buf[off + 0] != buf[off + 2] && + buf[off + 2] != buf[off + 4]) { printf("%s Error corrupted %s\n", __func__, name); val = -1; } else { val = buf[off + 0] + (buf[off + 1] << 8); - if ((val == 0) && (check == 1)) + if (val == 0 && check == 1) val = -1; } sprintf((char *)valbuf, "%x", val); @@ -98,9 +97,9 @@ static char convert_char(char c) } static int ivm_findinventorystring(int type, - unsigned char *const string, - unsigned long maxlen, - unsigned char *buf) + unsigned char *const string, + unsigned long maxlen, + unsigned char *buf) { int xcode = 0; unsigned long cr = 0; @@ -133,12 +132,12 @@ static int ivm_findinventorystring(int type, */ if (addr < INVENTORYDATASIZE) { /* Copy the IVM string in the corresponding string */ - for (; (buf[addr] != '\r') && - ((buf[addr] != ';') || (!stop)) && - (size < (maxlen - 1) && - (addr < INVENTORYDATASIZE)); addr++) { + for (; (buf[addr] != '\r') && + ((buf[addr] != ';') || (!stop)) && + (size < (maxlen - 1) && + (addr < INVENTORYDATASIZE)); addr++) { size += sprintf((char *)string + size, "%c", - convert_char (buf[addr])); + convert_char (buf[addr])); } /* @@ -176,12 +175,12 @@ static int ivm_check_crc(unsigned char *buf, int block) unsigned long crceeprom; crc = ivm_calc_crc(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2); - crceeprom = (buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 1] + \ + crceeprom = (buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 1] + buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2] * 256); if (crc != crceeprom) { if (block == 0) - printf("Error CRC Block: %d EEprom: calculated: \ - %lx EEprom: %lx\n", block, crc, crceeprom); + printf("Error CRC Block: %d EEprom: calculated: %lx EEprom: %lx\n", + block, crc, crceeprom); return -1; } return 0; @@ -189,7 +188,7 @@ static int ivm_check_crc(unsigned char *buf, int block) /* take care of the possible MAC address offset and the IVM content offset */ static int process_mac(unsigned char *valbuf, unsigned char *buf, - int offset, bool unique) + int offset, bool unique) { unsigned char mac[6]; unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; @@ -197,9 +196,9 @@ static int process_mac(unsigned char *valbuf, unsigned char *buf, /* use an intermediate buffer, to not change IVM content * MAC address is at offset 1 */ - memcpy(mac, buf+1, 6); + memcpy(mac, buf + 1, 6); - /* MAC adress can be set to locally administred, this is only allowed + /* MAC address can be set to locally administred, this is only allowed * for interfaces which have now connection to the outside. For these * addresses we need to set the second bit in the first byte. */ @@ -222,7 +221,7 @@ static int ivm_analyze_block2(unsigned char *buf, int len) unsigned char valbuf[MAC_STR_SZ]; unsigned long count; - /* IVM_MAC Adress begins at offset 1 */ + /* IVM_MAC Address begins at offset 1 */ sprintf((char *)valbuf, "%pM", buf + 1); ivm_set_value("IVM_MacAddress", (char *)valbuf); /* IVM_MacCount */ @@ -247,9 +246,9 @@ int ivm_analyze_eeprom(unsigned char *buf, int len) return -1; ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, - "IVM_BoardId", 0, 1); + "IVM_BoardId", 0, 1); val = ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, - "IVM_HWKey", 6, 1); + "IVM_HWKey", 6, 1); if (val != 0xffff) { sprintf((char *)valbuf, "%x", ((val / 100) % 10)); ivm_set_value("IVM_HWVariant", (char *)valbuf); @@ -257,7 +256,7 @@ int ivm_analyze_eeprom(unsigned char *buf, int len) ivm_set_value("IVM_HWVersion", (char *)valbuf); } ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, - "IVM_Functions", 12, 0); + "IVM_Functions", 12, 0); GET_STRING("IVM_Symbol", IVM_POS_SYMBOL_ONLY, 8) GET_STRING("IVM_DeviceName", IVM_POS_SHORT_TEXT, 64) @@ -269,7 +268,7 @@ int ivm_analyze_eeprom(unsigned char *buf, int len) while (i < len) { if (tmp[i] == ';') { ivm_set_value("IVM_ShortText", - (char *)&tmp[i + 1]); + (char *)&tmp[i + 1]); break; } i++; @@ -292,7 +291,7 @@ int ivm_analyze_eeprom(unsigned char *buf, int len) if (ivm_check_crc(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], 2) != 0) return 0; ivm_analyze_block2(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], - CONFIG_SYS_IVM_EEPROM_PAGE_LEN); + CONFIG_SYS_IVM_EEPROM_PAGE_LEN); return 0; } @@ -305,22 +304,23 @@ static int ivm_populate_env(unsigned char *buf, int len, int mac_address_offset) /* do we have the page 2 filled ? if not return */ if (ivm_check_crc(buf, 2)) return 0; - page2 = &buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN*2]; + page2 = &buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2]; -#ifndef CONFIG_KMTEGR1 - /* if an offset is defined, add it */ - process_mac(valbuf, page2, mac_address_offset, true); - env_set((char *)"ethaddr", (char *)valbuf); -#else -/* KMTEGR1 has a special setup. eth0 has no connection to the outside and - * gets an locally administred MAC address, eth1 is the debug interface and - * gets the official MAC address from the IVM - */ - process_mac(valbuf, page2, mac_address_offset, false); - env_set((char *)"ethaddr", (char *)valbuf); - process_mac(valbuf, page2, mac_address_offset, true); - env_set((char *)"eth1addr", (char *)valbuf); -#endif + if (!IS_ENABLED(CONFIG_KMTEGR1)) { + /* if an offset is defined, add it */ + process_mac(valbuf, page2, mac_address_offset, true); + env_set((char *)"ethaddr", (char *)valbuf); + } else { + /* KMTEGR1 has a special setup. eth0 has no connection to the + * outside and gets an locally administred MAC address, eth1 is + * the debug interface and gets the official MAC address from + * the IVM + */ + process_mac(valbuf, page2, mac_address_offset, false); + env_set((char *)"ethaddr", (char *)valbuf); + process_mac(valbuf, page2, mac_address_offset, true); + env_set((char *)"eth1addr", (char *)valbuf); + } return 0; } diff --git a/board/keymile/km_arm/fpga_config.c b/board/keymile/km_arm/fpga_config.c index abb5b7d60d..839b162eea 100644 --- a/board/keymile/km_arm/fpga_config.c +++ b/board/keymile/km_arm/fpga_config.c @@ -40,14 +40,14 @@ static int boco_clear_bits(u8 reg, u8 flags) ret = i2c_read(BOCO_ADDR, reg, 1, ®val, 1); if (ret) { printf("%s: error reading the BOCO @%#x !!\n", - __func__, reg); + __func__, reg); return ret; } regval &= ~flags; ret = i2c_write(BOCO_ADDR, reg, 1, ®val, 1); if (ret) { printf("%s: error writing the BOCO @%#x !!\n", - __func__, reg); + __func__, reg); return ret; } @@ -63,14 +63,14 @@ static int boco_set_bits(u8 reg, u8 flags) ret = i2c_read(BOCO_ADDR, reg, 1, ®val, 1); if (ret) { printf("%s: error reading the BOCO @%#x !!\n", - __func__, reg); + __func__, reg); return ret; } regval |= flags; ret = i2c_write(BOCO_ADDR, reg, 1, ®val, 1); if (ret) { printf("%s: error writing the BOCO @%#x !!\n", - __func__, reg); + __func__, reg); return ret; } @@ -113,7 +113,8 @@ int trigger_fpga_config(void) skip = 0; #ifndef CONFIG_KM_FPGA_FORCE_CONFIG /* if the FPGA is already configured, we do not want to - * reconfigure it */ + * reconfigure it + */ skip = 0; if (fpga_done()) { printf("PCIe FPGA config: skipped\n"); @@ -179,7 +180,7 @@ int wait_for_fpga_config(void) ret = i2c_read(BOCO_ADDR, SPI_REG, 1, &spictrl, 1); if (ret) { printf("%s: error reading the BOCO spictrl !!\n", - __func__); + __func__); return ret; } if (timeout-- == 0) { @@ -235,7 +236,8 @@ int fpga_reset(void) #endif /* the FPGA was configured, we configure the BOCO2 so that the EEPROM - * is available from the Bobcat SPI bus */ + * is available from the Bobcat SPI bus + */ int toggle_eeprom_spi_bus(void) { int ret = 0; diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c index 7d191ab860..60187bd8d2 100644 --- a/board/keymile/km_arm/km_arm.c +++ b/board/keymile/km_arm/km_arm.c @@ -53,9 +53,9 @@ DECLARE_GLOBAL_DATA_PTR; #define PHY_MARVELL_88E1118R_LED_CTRL_REG 0x0010 #define PHY_MARVELL_88E1118R_LED_CTRL_RESERVED 0x1000 -#define PHY_MARVELL_88E1118R_LED_CTRL_LED0_1000MB (0x7<<0) -#define PHY_MARVELL_88E1118R_LED_CTRL_LED1_ACT (0x3<<4) -#define PHY_MARVELL_88E1118R_LED_CTRL_LED2_LINK (0x0<<8) +#define PHY_MARVELL_88E1118R_LED_CTRL_LED0_1000MB (0x7 << 0) +#define PHY_MARVELL_88E1118R_LED_CTRL_LED1_ACT (0x3 << 4) +#define PHY_MARVELL_88E1118R_LED_CTRL_LED2_LINK (0x0 << 8) /* I/O pin to erase flash RGPP09 = MPP43 */ #define KM_FLASH_ERASE_ENABLE 43 @@ -169,6 +169,7 @@ static void set_bootcount_addr(void) { uchar buf[32]; unsigned int bootcountaddr; + bootcountaddr = gd->ram_size - BOOTCOUNT_ADDR; sprintf((char *)buf, "0x%x", bootcountaddr); env_set("bootcountaddr", (char *)buf); @@ -192,7 +193,7 @@ int board_early_init_f(void) /* set the 2 bitbang i2c pins as output gpios */ tmp = readl(MVEBU_GPIO0_BASE + 4); - writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , MVEBU_GPIO0_BASE + 4); + writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS), MVEBU_GPIO0_BASE + 4); #endif /* adjust SDRAM size for bank 0 */ mvebu_sdram_size_adjust(0); @@ -292,11 +293,11 @@ int mvebu_board_spi_release_bus(struct udevice *dev) #define PHY_LED_SEL_REG 0x18 #define PHY_LED0_LINK (0x5) -#define PHY_LED1_ACT (0x8<<4) -#define PHY_LED2_INT (0xe<<8) +#define PHY_LED1_ACT (0x8 << 4) +#define PHY_LED2_INT (0xe << 8) #define PHY_SPEC_CTRL_REG 0x1c -#define PHY_RGMII_CLK_STABLE (0x1<<10) -#define PHY_CLSA (0x1<<1) +#define PHY_RGMII_CLK_STABLE (0x1 << 10) +#define PHY_CLSA (0x1 << 1) /* Configure and enable MV88E3018 PHY */ void reset_phy(void) @@ -407,8 +408,8 @@ void reset_phy(void) return; /* check for Marvell 88E1118R Gigabit PHY (PIGGY3) */ - if ((oui == PHY_MARVELL_OUI) && - (model == PHY_MARVELL_88E1118R_MODEL)) { + if (oui == PHY_MARVELL_OUI && + model == PHY_MARVELL_88E1118R_MODEL) { /* set page register to 3 */ if (miiphy_write(name, CONFIG_PHY_BASE_ADR, PHY_MARVELL_PAGE_REG, @@ -438,7 +439,6 @@ void reset_phy(void) } #endif - #if defined(CONFIG_HUSH_INIT_VAR) int hush_init_var(void) { @@ -478,22 +478,23 @@ int get_scl(void) int post_hotkeys_pressed(void) { -#if defined(CONFIG_KM_COGE5UN) - return kw_gpio_get_value(KM_POST_EN_L); -#else - return !kw_gpio_get_value(KM_POST_EN_L); -#endif + if (IS_ENABLED(CONFIG_KM_COGE5UN)) + return kw_gpio_get_value(KM_POST_EN_L); + else + return !kw_gpio_get_value(KM_POST_EN_L); } ulong post_word_load(void) { - void* addr = (void *) (gd->ram_size - BOOTCOUNT_ADDR + POST_WORD_OFF); + void *addr = (void *)(gd->ram_size - BOOTCOUNT_ADDR + POST_WORD_OFF); + return in_le32(addr); } void post_word_store(ulong value) { - void* addr = (void *) (gd->ram_size - BOOTCOUNT_ADDR + POST_WORD_OFF); + void *addr = (void *)(gd->ram_size - BOOTCOUNT_ADDR + POST_WORD_OFF); + out_le32(addr, value); } @@ -502,14 +503,14 @@ int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset) *vstart = CONFIG_SYS_SDRAM_BASE; /* we go up to relocation plus a 1 MB margin */ - *size = CONFIG_SYS_TEXT_BASE - (1<<20); + *size = CONFIG_SYS_TEXT_BASE - (1 << 20); return 0; } #endif #if defined(CONFIG_SYS_EEPROM_WREN) -int eeprom_write_enable(unsigned dev_addr, int state) +int eeprom_write_enable(unsigned int dev_addr, int state) { kw_gpio_set_value(KM_KIRKWOOD_ENV_WP, !state); diff --git a/board/kontron/sl28/Kconfig b/board/kontron/sl28/Kconfig index cdec39be01..4078ef186b 100644 --- a/board/kontron/sl28/Kconfig +++ b/board/kontron/sl28/Kconfig @@ -15,4 +15,37 @@ config SYS_CONFIG_NAME config SYS_TEXT_BASE default 0x96000000 +config SL28_SPL_LOADS_ATF_BL31 + bool "SPL loads BL31 of the ARM Trusted Firmware" + select SPL_ATF + select SPL_ATF_LOAD_IMAGE_V2 + select ARMV8_SEC_FIRMWARE_SUPPORT + select SEC_FIRMWARE_ARMV8_PSCI + help + Enable this to load a BL31 image by the SPL. You have to + provde a bl31.bin in u-boot's root directory. + +if SL28_SPL_LOADS_ATF_BL31 + +config SL28_BL31_ENTRY_ADDR + hex "Entry point of the BL31 image" + default 0xfbe00000 + +endif + +config SL28_SPL_LOADS_OPTEE_BL32 + bool "SPL loads OP-TEE Trusted OS as BL32" + depends on SL28_SPL_LOADS_ATF_BL31 + help + Enable this to load a BL32 image by the SPL. You have to + provde a tee.bin in u-boot's root directory. + +if SL28_SPL_LOADS_OPTEE_BL32 + +config SL28_BL32_ENTRY_ADDR + hex "Entry point of the BL32 image" + default 0xfc000000 + +endif + endif diff --git a/board/kontron/sl28/Makefile b/board/kontron/sl28/Makefile index 74d8012f0f..5d220f0744 100644 --- a/board/kontron/sl28/Makefile +++ b/board/kontron/sl28/Makefile @@ -5,4 +5,8 @@ obj-y += sl28.o cmds.o endif obj-y += common.o ddr.o -obj-$(CONFIG_SPL_BUILD) += spl.o + +ifdef CONFIG_SPL_BUILD +obj-y += spl.o +obj-$(CONFIG_SPL_ATF) += spl_atf.o +endif diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index b18127c4d1..34f17b486b 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -50,6 +50,7 @@ int ft_board_setup(void *blob, struct bd_info *bd) u64 base[CONFIG_NR_DRAM_BANKS]; u64 size[CONFIG_NR_DRAM_BANKS]; int nbanks = CONFIG_NR_DRAM_BANKS; + int node; int i; ft_cpu_setup(blob, bd); @@ -64,5 +65,11 @@ int ft_board_setup(void *blob, struct bd_info *bd) fdt_fixup_icid(blob); + if (CONFIG_IS_ENABLED(SL28_SPL_LOADS_OPTEE_BL32)) { + node = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz"); + if (node) + fdt_set_node_status(blob, node, FDT_STATUS_OKAY, 0); + } + return 0; } diff --git a/board/kontron/sl28/spl_atf.c b/board/kontron/sl28/spl_atf.c new file mode 100644 index 0000000000..5438b5239c --- /dev/null +++ b/board/kontron/sl28/spl_atf.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * LS1028A TF-A calling support + * + * Copyright (c) 2020 Michael Walle <michael@walle.cc> + */ + +#include <common.h> +#include <asm/io.h> +#include <atf_common.h> +#include <spl.h> + +DECLARE_GLOBAL_DATA_PTR; + +struct region_info { + u64 addr; + u64 size; +}; + +struct dram_regions_info { + u64 num_dram_regions; + u64 total_dram_size; + struct region_info region[CONFIG_NR_DRAM_BANKS]; +}; + +struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr) +{ + static struct dram_regions_info dram_regions_info = { 0 }; + struct bl_params *bl_params; + struct bl_params_node *node; + void *dcfg_ccsr = (void *)DCFG_BASE; + int i; + + dram_regions_info.num_dram_regions = CONFIG_NR_DRAM_BANKS; + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + dram_regions_info.region[i].addr = gd->bd->bi_dram[i].start; + dram_regions_info.region[i].size = gd->bd->bi_dram[i].size; + dram_regions_info.total_dram_size += gd->bd->bi_dram[i].size; + } + + bl_params = bl2_plat_get_bl31_params_v2_default(bl32_entry, bl33_entry, + fdt_addr); + + for_each_bl_params_node(bl_params, node) { + if (node->image_id == ATF_BL31_IMAGE_ID) { + node->ep_info->args.arg3 = (uintptr_t)&dram_regions_info; + node->ep_info->args.arg4 = in_le32(dcfg_ccsr + DCFG_PORSR1); + } + } + + return bl_params; +} diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c index dff159025b..118ab269d6 100644 --- a/board/lg/sniper/sniper.c +++ b/board/lg/sniper/sniper.c @@ -30,16 +30,16 @@ const omap3_sysinfo sysinfo = { .nand_string = "MMC" }; -static const struct ns16550_platdata serial_omap_platdata = { +static const struct ns16550_plat serial_omap_plat = { .base = OMAP34XX_UART3, .reg_shift = 2, .clock = V_NS16550_CLK, .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE(sniper_serial) = { +U_BOOT_DRVINFO(sniper_serial) = { .name = "ns16550_serial", - .platdata = &serial_omap_platdata + .plat = &serial_omap_plat }; static struct musb_hdrc_config musb_config = { diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c index 2dd41604c9..ceb4317901 100644 --- a/board/nokia/rx51/rx51.c +++ b/board/nokia/rx51/rx51.c @@ -703,13 +703,13 @@ void board_mmc_power_init(void) twl4030_power_mmc_init(1); } -static const struct omap_i2c_platdata rx51_i2c[] = { +static const struct omap_i2c_plat rx51_i2c[] = { { I2C_BASE1, 100000, OMAP_I2C_REV_V1 }, { I2C_BASE2, 100000, OMAP_I2C_REV_V1 }, { I2C_BASE3, 100000, OMAP_I2C_REV_V1 }, }; -U_BOOT_DEVICES(rx51_i2c) = { +U_BOOT_DRVINFOS(rx51_i2c) = { { "i2c_omap", &rx51_i2c[0] }, { "i2c_omap", &rx51_i2c[1] }, { "i2c_omap", &rx51_i2c[2] }, diff --git a/board/nvidia/jetson-tk1/jetson-tk1.c b/board/nvidia/jetson-tk1/jetson-tk1.c index 9eccdc4a83..d349531261 100644 --- a/board/nvidia/jetson-tk1/jetson-tk1.c +++ b/board/nvidia/jetson-tk1/jetson-tk1.c @@ -60,7 +60,7 @@ int tegra_pcie_board_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(pmic_as3722), &dev); + DM_DRIVER_GET(pmic_as3722), &dev); if (ret) { debug("%s: Failed to find PMIC\n", __func__); return ret; diff --git a/board/nvidia/nyan-big/nyan-big.c b/board/nvidia/nyan-big/nyan-big.c index 71c71ed6ec..06a36f8ed3 100644 --- a/board/nvidia/nyan-big/nyan-big.c +++ b/board/nvidia/nyan-big/nyan-big.c @@ -52,7 +52,7 @@ int tegra_lcd_pmic_init(int board_id) int ret; ret = uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(pmic_as3722), &dev); + DM_DRIVER_GET(pmic_as3722), &dev); if (ret) { debug("%s: Failed to find PMIC\n", __func__); return ret; diff --git a/board/renesas/ulcb/cpld.c b/board/renesas/ulcb/cpld.c index a20a34a92a..ebb2d6f742 100644 --- a/board/renesas/ulcb/cpld.c +++ b/board/renesas/ulcb/cpld.c @@ -91,7 +91,7 @@ static int do_cpld(struct cmd_tbl *cmdtp, int flag, int argc, int ret; ret = uclass_get_device_by_driver(UCLASS_SYSRESET, - DM_GET_DRIVER(sysreset_renesas_ulcb), + DM_DRIVER_GET(sysreset_renesas_ulcb), &dev); if (ret) return ret; @@ -188,5 +188,5 @@ U_BOOT_DRIVER(sysreset_renesas_ulcb) = { .ops = &renesas_ulcb_sysreset, .probe = renesas_ulcb_sysreset_probe, .of_match = renesas_ulcb_sysreset_ids, - .priv_auto_alloc_size = sizeof(struct renesas_ulcb_sysreset_priv), + .priv_auto = sizeof(struct renesas_ulcb_sysreset_priv), }; diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 18a605de02..d152703b15 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -23,15 +23,11 @@ gd_t *gd; #if !CONFIG_IS_ENABLED(OF_PLATDATA) /* Add a simple GPIO device */ -U_BOOT_DEVICE(gpio_sandbox) = { +U_BOOT_DRVINFO(gpio_sandbox) = { .name = "sandbox_gpio", }; #endif -void flush_cache(unsigned long start, unsigned long size) -{ -} - #ifndef CONFIG_TIMER /* system timer offset in ms */ static unsigned long sandbox_timer_offset; diff --git a/board/siemens/corvus/board.c b/board/siemens/corvus/board.c index eed055aedb..25d85a8f17 100644 --- a/board/siemens/corvus/board.c +++ b/board/siemens/corvus/board.c @@ -314,11 +314,11 @@ void spi_cs_deactivate(struct spi_slave *slave) } } -static struct atmel_serial_platdata at91sam9260_serial_plat = { +static struct atmel_serial_plat at91sam9260_serial_plat = { .base_addr = ATMEL_BASE_DBGU, }; -U_BOOT_DEVICE(at91sam9260_serial) = { +U_BOOT_DRVINFO(at91sam9260_serial) = { .name = "serial_atmel", - .platdata = &at91sam9260_serial_plat, + .plat = &at91sam9260_serial_plat, }; diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c index 54e5a4c167..a4e78220cb 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -58,7 +58,7 @@ static u32 fu540_read_serialnum(void) /* init OTP */ ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(sifive_otp), &dev); + DM_DRIVER_GET(sifive_otp), &dev); if (ret) { debug("%s: could not find otp device\n", __func__); diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c index e1038619f0..2fba383168 100644 --- a/board/st/common/cmd_stboard.c +++ b/board/st/common/cmd_stboard.c @@ -85,7 +85,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); ret = misc_read(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD), diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c index aab7d741ac..9c3d115dce 100644 --- a/board/st/common/stm32mp_dfu.c +++ b/board/st/common/stm32mp_dfu.c @@ -163,7 +163,7 @@ static int dfu_otp_read(u64 offset, u8 *buffer, long *size) int ret; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) return ret; @@ -184,7 +184,7 @@ static int dfu_pmic_read(u64 offset, u8 *buffer, long *size) struct udevice *dev; ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; diff --git a/board/st/common/stpmic1.c b/board/st/common/stpmic1.c index 3aa379e8a5..a313b817c5 100644 --- a/board/st/common/stpmic1.c +++ b/board/st/common/stpmic1.c @@ -20,7 +20,7 @@ int board_ddr_power_init(enum ddr_type ddr_type) u32 buck2; ret = uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(pmic_stpmic1), &dev); + DM_DRIVER_GET(pmic_stpmic1), &dev); if (ret) /* No PMIC on board */ return 0; @@ -187,7 +187,7 @@ void stpmic1_init(u32 voltage_mv) struct udevice *dev; if (uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(pmic_stpmic1), &dev)) + DM_DRIVER_GET(pmic_stpmic1), &dev)) return; /* update VDDCORE = BUCK1 */ diff --git a/board/st/common/stusb160x.c b/board/st/common/stusb160x.c index f1197f9faa..e0a2b76353 100644 --- a/board/st/common/stusb160x.c +++ b/board/st/common/stusb160x.c @@ -22,7 +22,7 @@ int stusb160x_cable_connected(void) int ret; ret = uclass_get_device_by_driver(UCLASS_I2C_GENERIC, - DM_GET_DRIVER(stusb160x), + DM_DRIVER_GET(stusb160x), &dev); if (ret < 0) return ret; diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index d3cffdd770..df353cb5ec 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -116,7 +116,7 @@ int checkboard(void) /* display the STMicroelectronics board identification */ if (CONFIG_IS_ENABLED(CMD_STBOARD)) { ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (!ret) ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), @@ -196,7 +196,7 @@ int g_dnl_board_usb_cable_connected(void) return ret; ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC, - DM_GET_DRIVER(dwc2_udc_otg), + DM_DRIVER_GET(dwc2_udc_otg), &dwc2_udc_otg); if (!ret) debug("dwc2_udc_otg init failed\n"); @@ -464,11 +464,11 @@ static void sysconf_init(void) * but this value need to be consistent with board design */ ret = uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(stm32mp_pwr_pmic), + DM_DRIVER_GET(stm32mp_pwr_pmic), &pwr_dev); if (!ret && IS_ENABLED(CONFIG_DM_REGULATOR)) { ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) { pr_err("Can't find stm32mp_bsec driver\n"); @@ -618,7 +618,7 @@ static void board_ev1_init(void) struct udevice *dev; /* configure IRQ line on EV1 for touchscreen before LCD reset */ - uclass_get_device_by_driver(UCLASS_NOP, DM_GET_DRIVER(goodix), &dev); + uclass_get_device_by_driver(UCLASS_NOP, DM_DRIVER_GET(goodix), &dev); } /* board dependent setup after realloc */ @@ -680,7 +680,7 @@ int board_late_init(void) } } ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (!ret) diff --git a/board/st/stv0991/stv0991.c b/board/st/stv0991/stv0991.c index 8c827adc2e..95e203ff0e 100644 --- a/board/st/stv0991/stv0991.c +++ b/board/st/stv0991/stv0991.c @@ -24,15 +24,15 @@ struct gpio_regs *const gpioa_regs = (struct gpio_regs *) GPIOA_BASE_ADDR; #ifndef CONFIG_OF_CONTROL -static const struct pl01x_serial_platdata serial_platdata = { +static const struct pl01x_serial_plat serial_plat = { .base = 0x80406000, .type = TYPE_PL011, .clock = 2700 * 1000, }; -U_BOOT_DEVICE(stv09911_serials) = { +U_BOOT_DRVINFO(stv09911_serials) = { .name = "serial_pl01x", - .platdata = &serial_platdata, + .plat = &serial_plat, }; #endif diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS index d3755ae41a..735801ae1d 100644 --- a/board/sunxi/MAINTAINERS +++ b/board/sunxi/MAINTAINERS @@ -440,6 +440,11 @@ M: Vasily Khoruzhick <anarsoul@gmail.com> S: Maintained F: configs/pinebook_defconfig +PINECUBE BOARD: +M: Icenowy Zheng <icenowy@aosc.io> +S: Maintained +F: configs/pinecube_defconfig + PINE64 BOARDS M: Andre Przywara <andre.przywara@arm.com> S: Maintained diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 708a27ed78..4f058952b5 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -39,6 +39,7 @@ #include <u-boot/crc.h> #include <env_internal.h> #include <linux/libfdt.h> +#include <fdt_support.h> #include <nand.h> #include <net.h> #include <spl.h> @@ -789,6 +790,38 @@ static void parse_spl_header(const uint32_t spl_addr) env_set_hex("fel_scriptaddr", spl->fel_script_address); } +static bool get_unique_sid(unsigned int *sid) +{ + if (sunxi_get_sid(sid) != 0) + return false; + + if (!sid[0]) + return false; + + /* + * The single words 1 - 3 of the SID have quite a few bits + * which are the same on many models, so we take a crc32 + * of all 3 words, to get a more unique value. + * + * Note we only do this on newer SoCs as we cannot change + * the algorithm on older SoCs since those have been using + * fixed mac-addresses based on only using word 3 for a + * long time and changing a fixed mac-address with an + * u-boot update is not good. + */ +#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \ + !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \ + !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33) + sid[3] = crc32(0, (unsigned char *)&sid[1], 12); +#endif + + /* Ensure the NIC specific bytes of the mac are not all 0 */ + if ((sid[3] & 0xffffff) == 0) + sid[3] |= 0x800000; + + return true; +} + /* * Note this function gets called multiple times. * It must not make any changes to env variables which already exist. @@ -799,61 +832,40 @@ static void setup_environment(const void *fdt) unsigned int sid[4]; uint8_t mac_addr[6]; char ethaddr[16]; - int i, ret; - - ret = sunxi_get_sid(sid); - if (ret == 0 && sid[0] != 0) { - /* - * The single words 1 - 3 of the SID have quite a few bits - * which are the same on many models, so we take a crc32 - * of all 3 words, to get a more unique value. - * - * Note we only do this on newer SoCs as we cannot change - * the algorithm on older SoCs since those have been using - * fixed mac-addresses based on only using word 3 for a - * long time and changing a fixed mac-address with an - * u-boot update is not good. - */ -#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \ - !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \ - !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33) - sid[3] = crc32(0, (unsigned char *)&sid[1], 12); -#endif + int i; - /* Ensure the NIC specific bytes of the mac are not all 0 */ - if ((sid[3] & 0xffffff) == 0) - sid[3] |= 0x800000; + if (!get_unique_sid(sid)) + return; - for (i = 0; i < 4; i++) { - sprintf(ethaddr, "ethernet%d", i); - if (!fdt_get_alias(fdt, ethaddr)) - continue; + for (i = 0; i < 4; i++) { + sprintf(ethaddr, "ethernet%d", i); + if (!fdt_get_alias(fdt, ethaddr)) + continue; - if (i == 0) - strcpy(ethaddr, "ethaddr"); - else - sprintf(ethaddr, "eth%daddr", i); + if (i == 0) + strcpy(ethaddr, "ethaddr"); + else + sprintf(ethaddr, "eth%daddr", i); - if (env_get(ethaddr)) - continue; + if (env_get(ethaddr)) + continue; - /* Non OUI / registered MAC address */ - mac_addr[0] = (i << 4) | 0x02; - mac_addr[1] = (sid[0] >> 0) & 0xff; - mac_addr[2] = (sid[3] >> 24) & 0xff; - mac_addr[3] = (sid[3] >> 16) & 0xff; - mac_addr[4] = (sid[3] >> 8) & 0xff; - mac_addr[5] = (sid[3] >> 0) & 0xff; + /* Non OUI / registered MAC address */ + mac_addr[0] = (i << 4) | 0x02; + mac_addr[1] = (sid[0] >> 0) & 0xff; + mac_addr[2] = (sid[3] >> 24) & 0xff; + mac_addr[3] = (sid[3] >> 16) & 0xff; + mac_addr[4] = (sid[3] >> 8) & 0xff; + mac_addr[5] = (sid[3] >> 0) & 0xff; - eth_env_set_enetaddr(ethaddr, mac_addr); - } + eth_env_set_enetaddr(ethaddr, mac_addr); + } - if (!env_get("serial#")) { - snprintf(serial_string, sizeof(serial_string), - "%08x%08x", sid[0], sid[3]); + if (!env_get("serial#")) { + snprintf(serial_string, sizeof(serial_string), + "%08x%08x", sid[0], sid[3]); - env_set("serial#", serial_string); - } + env_set("serial#", serial_string); } } @@ -890,6 +902,11 @@ int misc_init_r(void) setup_environment(gd->fdt_blob); + return 0; +} + +int board_late_init(void) +{ #ifdef CONFIG_USB_ETHER usb_ether_init(); #endif @@ -897,6 +914,38 @@ int misc_init_r(void) return 0; } +static void bluetooth_dt_fixup(void *blob) +{ + /* Some devices ship with a Bluetooth controller default address. + * Set a valid address through the device tree. + */ + uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN]; + unsigned int sid[4]; + int i; + + if (!CONFIG_BLUETOOTH_DT_DEVICE_FIXUP[0]) + return; + + if (eth_env_get_enetaddr("bdaddr", tmp)) { + /* Convert between the binary formats of the corresponding stacks */ + for (i = 0; i < ETH_ALEN; ++i) + bdaddr[i] = tmp[ETH_ALEN - i - 1]; + } else { + if (!get_unique_sid(sid)) + return; + + bdaddr[0] = ((sid[3] >> 0) & 0xff) ^ 1; + bdaddr[1] = (sid[3] >> 8) & 0xff; + bdaddr[2] = (sid[3] >> 16) & 0xff; + bdaddr[3] = (sid[3] >> 24) & 0xff; + bdaddr[4] = (sid[0] >> 0) & 0xff; + bdaddr[5] = 0x02; + } + + do_fixup_by_compat(blob, CONFIG_BLUETOOTH_DT_DEVICE_FIXUP, + "local-bd-address", bdaddr, ETH_ALEN, 1); +} + int ft_board_setup(void *blob, struct bd_info *bd) { int __maybe_unused r; @@ -907,6 +956,8 @@ int ft_board_setup(void *blob, struct bd_info *bd) */ setup_environment(blob); + bluetooth_dt_fixup(blob); + #ifdef CONFIG_VIDEO_DT_SIMPLEFB r = sunxi_simplefb_setup(blob); if (r) diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c index 1c74bfb93a..bd43179fc7 100644 --- a/board/synopsys/hsdk/clk-lib.c +++ b/board/synopsys/hsdk/clk-lib.c @@ -23,8 +23,8 @@ int soc_clk_ctl(const char *name, ulong *rate, enum clk_ctl_ops ctl) /* Dummy fmeas device, just to be able to use standard clk_* api */ struct udevice fmeas = { .name = "clk-fmeas", - .node = ofnode_path("/clk-fmeas"), }; + dev_set_ofnode(&fmeas, ofnode_path("/clk-fmeas")); ret = clk_get_by_name(&fmeas, name, &clk); if (ret) { diff --git a/board/sysam/amcore/amcore.c b/board/sysam/amcore/amcore.c index 4502005941..65fc60e2b4 100644 --- a/board/sysam/amcore/amcore.c +++ b/board/sysam/amcore/amcore.c @@ -107,13 +107,13 @@ int dram_init(void) return 0; } -static struct coldfire_serial_platdata mcf5307_serial_plat = { +static struct coldfire_serial_plat mcf5307_serial_plat = { .base = CONFIG_SYS_UART_BASE, .port = 0, .baudrate = CONFIG_BAUDRATE, }; -U_BOOT_DEVICE(coldfire_serial) = { +U_BOOT_DRVINFO(coldfire_serial) = { .name = "serial_coldfire", - .platdata = &mcf5307_serial_plat, + .plat = &mcf5307_serial_plat, }; diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index 984cc5e3ba..3cc0e4b91c 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -879,13 +879,13 @@ int board_late_init(void) } /* Just probe the potentially supported cdce913 device */ - uclass_get_device(UCLASS_CLK, 0, &dev); + uclass_get_device_by_name(UCLASS_CLK, "cdce913@65", &dev); return 0; } #endif -/* CPSW platdata */ +/* CPSW plat */ #if !CONFIG_IS_ENABLED(OF_CONTROL) struct cpsw_slave_data slave_data[] = { { @@ -927,9 +927,9 @@ struct eth_pdata cpsw_pdata = { .priv_pdata = &am335_eth_data, }; -U_BOOT_DEVICE(am335x_eth) = { +U_BOOT_DRVINFO(am335x_eth) = { .name = "eth_cpsw", - .platdata = &cpsw_pdata, + .plat = &cpsw_pdata, }; #endif @@ -963,7 +963,7 @@ void board_fit_image_post_process(void **p_image, size_t *p_size) #endif #if !CONFIG_IS_ENABLED(OF_CONTROL) -static const struct omap_hsmmc_plat am335x_mmc0_platdata = { +static const struct omap_hsmmc_plat am335x_mmc0_plat = { .base_addr = (struct hsmmc *)OMAP_HSMMC1_BASE, .cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_4BIT, .cfg.f_min = 400000, @@ -972,12 +972,12 @@ static const struct omap_hsmmc_plat am335x_mmc0_platdata = { .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, }; -U_BOOT_DEVICE(am335x_mmc0) = { +U_BOOT_DRVINFO(am335x_mmc0) = { .name = "omap_hsmmc", - .platdata = &am335x_mmc0_platdata, + .plat = &am335x_mmc0_plat, }; -static const struct omap_hsmmc_plat am335x_mmc1_platdata = { +static const struct omap_hsmmc_plat am335x_mmc1_plat = { .base_addr = (struct hsmmc *)OMAP_HSMMC2_BASE, .cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_8BIT, .cfg.f_min = 400000, @@ -986,8 +986,8 @@ static const struct omap_hsmmc_plat am335x_mmc1_platdata = { .cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, }; -U_BOOT_DEVICE(am335x_mmc1) = { +U_BOOT_DRVINFO(am335x_mmc1) = { .name = "omap_hsmmc", - .platdata = &am335x_mmc1_platdata, + .plat = &am335x_mmc1_plat, }; #endif diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c index de49590031..62ed37cb48 100644 --- a/board/ti/am43xx/board.c +++ b/board/ti/am43xx/board.c @@ -744,7 +744,7 @@ int board_late_init(void) #endif /* Just probe the potentially supported cdce913 device */ - uclass_get_device(UCLASS_CLK, 0, &dev); + uclass_get_device_by_name(UCLASS_CLK, "cdce913@65", &dev); return 0; } diff --git a/board/ti/am65x/evm.c b/board/ti/am65x/evm.c index 36063b1138..4438f14e4f 100644 --- a/board/ti/am65x/evm.c +++ b/board/ti/am65x/evm.c @@ -38,6 +38,10 @@ enum { /* Max number of MAC addresses that are parsed/processed per daughter card */ #define DAUGHTER_CARD_NO_OF_MAC_ADDR 8 +/* Regiter that controls the SERDES0 lane and clock assignment */ +#define CTRLMMR_SERDES0_CTRL 0x00104080 +#define PCIE_LANE0 0x1 + DECLARE_GLOBAL_DATA_PTR; int board_init(void) @@ -312,6 +316,18 @@ static int probe_daughtercards(void) (uchar *)mac_addr[j]); } + /* + * It has been observed that setting SERDES0 lane mux to USB prevents USB + * 2.0 operation on USB0. Setting SERDES0 lane mux to non-USB when USB0 is + * used in USB 2.0 only mode solves this issue. For USB3.0+2.0 operation + * this issue is not present. + * + * Implement this workaround by writing 1 to LANE_FUNC_SEL field in + * CTRLMMR_SERDES0_CTRL register. + */ + if (!strncmp(ep.name, "SER-PCIE2LEVM", sizeof(ep.name))) + writel(PCIE_LANE0, CTRLMMR_SERDES0_CTRL); + /* Skip if no overlays are to be added */ if (!strlen(cards[i].dtbo_name)) continue; diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c index d8711eb900..44969e80b4 100644 --- a/board/ti/j721e/evm.c +++ b/board/ti/j721e/evm.c @@ -411,7 +411,7 @@ void spl_board_init(void) #ifdef CONFIG_ESM_K3 if (board_ti_k3_is("J721EX-PM2-SOM")) { ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(k3_esm), &dev); + DM_DRIVER_GET(k3_esm), &dev); if (ret) printf("ESM init failed: %d\n", ret); } @@ -420,7 +420,7 @@ void spl_board_init(void) #ifdef CONFIG_ESM_PMIC if (board_ti_k3_is("J721EX-PM2-SOM")) { ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(pmic_esm), + DM_DRIVER_GET(pmic_esm), &dev); if (ret) printf("ESM PMIC init failed: %d\n", ret); diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c index c7be540028..53bc12791d 100644 --- a/board/ti/ks2_evm/board.c +++ b/board/ti/ks2_evm/board.c @@ -48,11 +48,11 @@ int dram_init(void) gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, CONFIG_MAX_RAM_BANK_SIZE); #if defined(CONFIG_TI_AEMIF) - if (!board_is_k2g_ice()) + if (!(board_is_k2g_ice() || board_is_k2g_i1())) aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs); #endif - if (!board_is_k2g_ice()) { + if (!(board_is_k2g_ice() || board_is_k2g_i1())) { if (ddr3_size) ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, ddr3_size); else diff --git a/board/ti/ks2_evm/board.h b/board/ti/ks2_evm/board.h index d0cfbf5a75..93fc3887f4 100644 --- a/board/ti/ks2_evm/board.h +++ b/board/ti/ks2_evm/board.h @@ -25,6 +25,10 @@ static inline int board_is_k2g_ice(void) { return board_ti_is("66AK2GIC"); } +static inline int board_is_k2g_i1(void) +{ + return board_ti_is("66AK2GI1"); +} #else static inline int board_is_k2g_gp(void) { @@ -34,6 +38,10 @@ static inline int board_is_k2g_ice(void) { return false; } +static inline int board_is_k2g_i1(void) +{ + return false; +} #endif void spl_init_keystone_plls(void); diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c index a71024bcbc..2be86d6d26 100644 --- a/board/ti/ks2_evm/board_k2g.c +++ b/board/ti/ks2_evm/board_k2g.c @@ -248,7 +248,8 @@ int board_fit_config_name_match(const char *name) else if (!strcmp(name, "keystone-k2g-evm") && (board_ti_is("66AK2GGP") || board_ti_is("66AK2GG1"))) return 0; - else if (!strcmp(name, "keystone-k2g-ice") && board_ti_is("66AK2GIC")) + else if (!strcmp(name, "keystone-k2g-ice") && + (board_ti_is("66AK2GIC") || board_is_k2g_i1())) return 0; else return -1; @@ -322,7 +323,7 @@ int embedded_dtb_select(void) BIT(9)); setbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_SETDATA_OFFSET, BIT(9)); - } else if (board_is_k2g_ice()) { + } else if (board_is_k2g_ice() || board_is_k2g_i1()) { /* GBE Phy workaround. For Phy to latch the input * configuration, a GPIO reset is asserted at the * Phy reset pin to latch configuration correctly after SoC @@ -364,6 +365,8 @@ int board_late_init(void) env_set("board_name", "66AK2GG1\0"); else if (board_is_k2g_ice()) env_set("board_name", "66AK2GIC\0"); + else if (board_is_k2g_i1()) + env_set("board_name", "66AK2GI1\0"); #endif return 0; } diff --git a/board/ti/ks2_evm/ddr3_k2g.c b/board/ti/ks2_evm/ddr3_k2g.c index 563c5e9950..3000d7245e 100644 --- a/board/ti/ks2_evm/ddr3_k2g.c +++ b/board/ti/ks2_evm/ddr3_k2g.c @@ -174,7 +174,7 @@ u32 ddr3_init(void) } else if (board_is_k2g_gp()) { ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_2g); ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_2g); - } else if (board_is_k2g_ice()) { + } else if (board_is_k2g_ice() || board_is_k2g_i1()) { ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_512mb); ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_512mb); } diff --git a/board/ti/ks2_evm/mux-k2g.h b/board/ti/ks2_evm/mux-k2g.h index 3ecf571c5c..fa6c92cbdf 100644 --- a/board/ti/ks2_evm/mux-k2g.h +++ b/board/ti/ks2_evm/mux-k2g.h @@ -377,7 +377,7 @@ void k2g_mux_config(void) configure_pin_mux(k2g_generic_pin_cfg); } else if (board_is_k2g_gp() || board_is_k2g_g1()) { configure_pin_mux(k2g_evm_pin_cfg); - } else if (board_is_k2g_ice()) { + } else if (board_is_k2g_ice() || board_is_k2g_i1()) { configure_pin_mux(k2g_ice_evm_pin_cfg); } else { puts("Unknown board, cannot configure pinmux."); diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c index 2420c28974..0731fb7645 100644 --- a/board/timll/devkit8000/devkit8000.c +++ b/board/timll/devkit8000/devkit8000.c @@ -47,14 +47,14 @@ static u32 gpmc_net_config[GPMC_MAX_REG] = { 0 }; -static const struct ns16550_platdata devkit8000_serial = { +static const struct ns16550_plat devkit8000_serial = { .base = OMAP34XX_UART3, .reg_shift = 2, .clock = V_NS16550_CLK, .fcr = UART_FCR_DEFVAL, }; -U_BOOT_DEVICE(devkit8000_uart) = { +U_BOOT_DRVINFO(devkit8000_uart) = { "ns16550_serial", &devkit8000_serial }; diff --git a/board/toradex/apalis-tk1/apalis-tk1.c b/board/toradex/apalis-tk1/apalis-tk1.c index e7a2186c2c..b97617cfca 100644 --- a/board/toradex/apalis-tk1/apalis-tk1.c +++ b/board/toradex/apalis-tk1/apalis-tk1.c @@ -155,7 +155,7 @@ int tegra_pcie_board_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(pmic_as3722), &dev); + DM_DRIVER_GET(pmic_as3722), &dev); if (ret) { pr_err("failed to find AS3722 PMIC: %d\n", ret); return ret; @@ -194,7 +194,7 @@ void tegra_pcie_board_port_reset(struct tegra_pcie_port *port) int ret; ret = uclass_get_device_by_driver(UCLASS_PMIC, - DM_GET_DRIVER(pmic_as3722), + DM_DRIVER_GET(pmic_as3722), &dev); if (ret) { debug("%s: Failed to find PMIC\n", __func__); diff --git a/board/toradex/apalis_imx6/apalis_imx6.c b/board/toradex/apalis_imx6/apalis_imx6.c index 3961c4df9e..5ae5274584 100644 --- a/board/toradex/apalis_imx6/apalis_imx6.c +++ b/board/toradex/apalis_imx6/apalis_imx6.c @@ -1144,12 +1144,12 @@ void reset_cpu(ulong addr) #endif /* CONFIG_SPL_BUILD */ -static struct mxc_serial_platdata mxc_serial_plat = { +static struct mxc_serial_plat mxc_serial_plat = { .reg = (struct mxc_uart *)UART1_BASE, .use_dte = true, }; -U_BOOT_DEVICE(mxc_serial) = { +U_BOOT_DRVINFO(mxc_serial) = { .name = "serial_mxc", - .platdata = &mxc_serial_plat, + .plat = &mxc_serial_plat, }; diff --git a/board/toradex/colibri-imx6ull/colibri-imx6ull.c b/board/toradex/colibri-imx6ull/colibri-imx6ull.c index 45f8da3c42..6ff55ce57b 100644 --- a/board/toradex/colibri-imx6ull/colibri-imx6ull.c +++ b/board/toradex/colibri-imx6ull/colibri-imx6ull.c @@ -203,12 +203,12 @@ int ft_board_setup(void *blob, struct bd_info *bd) } #endif -static struct mxc_serial_platdata mxc_serial_plat = { +static struct mxc_serial_plat mxc_serial_plat = { .reg = (struct mxc_uart *)UART1_BASE, .use_dte = 1, }; -U_BOOT_DEVICE(mxc_serial) = { +U_BOOT_DRVINFO(mxc_serial) = { .name = "serial_mxc", - .platdata = &mxc_serial_plat, + .plat = &mxc_serial_plat, }; diff --git a/board/toradex/colibri_imx6/colibri_imx6.c b/board/toradex/colibri_imx6/colibri_imx6.c index a416b5e54b..57d3e526b4 100644 --- a/board/toradex/colibri_imx6/colibri_imx6.c +++ b/board/toradex/colibri_imx6/colibri_imx6.c @@ -1086,12 +1086,12 @@ void reset_cpu(ulong addr) #endif /* CONFIG_SPL_BUILD */ -static struct mxc_serial_platdata mxc_serial_plat = { +static struct mxc_serial_plat mxc_serial_plat = { .reg = (struct mxc_uart *)UART1_BASE, .use_dte = true, }; -U_BOOT_DEVICE(mxc_serial) = { +U_BOOT_DRVINFO(mxc_serial) = { .name = "serial_mxc", - .platdata = &mxc_serial_plat, + .plat = &mxc_serial_plat, }; diff --git a/board/toradex/colibri_pxa270/colibri_pxa270.c b/board/toradex/colibri_pxa270/colibri_pxa270.c index 273a17f608..645751a37e 100644 --- a/board/toradex/colibri_pxa270/colibri_pxa270.c +++ b/board/toradex/colibri_pxa270/colibri_pxa270.c @@ -129,24 +129,24 @@ int board_mmc_init(struct bd_info *bis) return 0; } #else /* !CONFIG_IS_ENABLED(DM_MMC) */ -static const struct pxa_mmc_plat mmc_platdata = { +static const struct pxa_mmc_plat mmc_plat = { .base = (struct pxa_mmc_regs *)MMC0_BASE, }; -U_BOOT_DEVICE(pxa_mmcs) = { +U_BOOT_DRVINFO(pxa_mmcs) = { .name = "pxa_mmc", - .platdata = &mmc_platdata, + .plat = &mmc_plat, }; #endif /* !CONFIG_IS_ENABLED(DM_MMC) */ #endif -static const struct pxa_serial_platdata serial_platdata = { +static const struct pxa_serial_plat serial_plat = { .base = (struct pxa_uart_regs *)FFUART_BASE, .port = FFUART_INDEX, .baudrate = CONFIG_BAUDRATE, }; -U_BOOT_DEVICE(pxa_serials) = { +U_BOOT_DRVINFO(pxa_serials) = { .name = "serial_pxa", - .platdata = &serial_platdata, + .plat = &serial_plat, }; diff --git a/board/xilinx/common/fru_ops.c b/board/xilinx/common/fru_ops.c index b4cd3d4998..44f0913f2e 100644 --- a/board/xilinx/common/fru_ops.c +++ b/board/xilinx/common/fru_ops.c @@ -170,7 +170,7 @@ static int fru_parse_board(unsigned long addr) data = (u8 *)&fru_data.brd.manufacturer_type_len; /* Record max structure limit not to write data over allocated space */ - limit = data + sizeof(struct fru_board_data); + limit = (u8 *)&fru_data.brd + sizeof(struct fru_board_data); for (i = 0; ; i++, data += FRU_BOARD_MAX_LEN) { len = fru_check_type_len(*(u8 *)addr, fru_data.brd.lang_code, diff --git a/board/xilinx/microblaze-generic/MAINTAINERS b/board/xilinx/microblaze-generic/MAINTAINERS index 6796d4d51a..9a42a8b740 100644 --- a/board/xilinx/microblaze-generic/MAINTAINERS +++ b/board/xilinx/microblaze-generic/MAINTAINERS @@ -1,6 +1,7 @@ MICROBLAZE-GENERIC BOARD M: Michal Simek <monstr@monstr.eu> S: Maintained +T: git https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze.git F: board/xilinx/microblaze-generic/ F: include/configs/microblaze-generic.h F: configs/microblaze-generic_defconfig diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c index e590999769..d4095c07c1 100644 --- a/board/xilinx/microblaze-generic/microblaze-generic.c +++ b/board/xilinx/microblaze-generic/microblaze-generic.c @@ -67,7 +67,10 @@ int board_late_init(void) status |= env_set_hex("ramdisk_addr_r", gd->ram_base + SZ_32M + SZ_4M + SZ_2M); - + if (IS_ENABLED(CONFIG_MTD_NOR_FLASH)) + status |= env_set_hex("script_offset_nor", + gd->bd->bi_flashstart + + CONFIG_BOOT_SCRIPT_OFFSET); if (status) printf("%s: Saving run time variables FAILED\n", __func__); diff --git a/board/xilinx/versal/MAINTAINERS b/board/xilinx/versal/MAINTAINERS index 2d2b808245..0d40196ade 100644 --- a/board/xilinx/versal/MAINTAINERS +++ b/board/xilinx/versal/MAINTAINERS @@ -1,6 +1,7 @@ XILINX_VERSAL BOARDS M: Michal Simek <michal.simek@xilinx.com> S: Maintained +T: git https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze.git F: arch/arm/dts/versal* F: board/xilinx/versal/ F: include/configs/xilinx_versal* diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index 912c1143a8..2782a346f0 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -153,9 +153,9 @@ int board_late_init(void) puts("Boot from EMMC but without SD1 enabled!\n"); return -1; } - debug("mmc1 device found at %p, seq %d\n", dev, dev->seq); + debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev)); mode = "mmc"; - bootseq = dev->seq; + bootseq = dev_seq(dev); break; case SD_MODE: puts("SD_MODE\n"); @@ -164,10 +164,10 @@ int board_late_init(void) puts("Boot from SD0 but without SD0 enabled!\n"); return -1; } - debug("mmc0 device found at %p, seq %d\n", dev, dev->seq); + debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev)); mode = "mmc"; - bootseq = dev->seq; + bootseq = dev_seq(dev); break; case SD1_LSHFT_MODE: puts("LVL_SHFT_"); @@ -179,10 +179,10 @@ int board_late_init(void) puts("Boot from SD1 but without SD1 enabled!\n"); return -1; } - debug("mmc1 device found at %p, seq %d\n", dev, dev->seq); + debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev)); mode = "mmc"; - bootseq = dev->seq; + bootseq = dev_seq(dev); break; default: mode = ""; diff --git a/board/xilinx/zynq/MAINTAINERS b/board/xilinx/zynq/MAINTAINERS index 78bcd84d30..ce760ab02c 100644 --- a/board/xilinx/zynq/MAINTAINERS +++ b/board/xilinx/zynq/MAINTAINERS @@ -1,6 +1,7 @@ ZYNQ BOARD M: Michal Simek <monstr@monstr.eu> S: Maintained +T: git https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze.git F: arch/arm/dts/zynq-* F: board/xilinx/zynq/ F: include/configs/zynq*.h diff --git a/board/xilinx/zynqmp/MAINTAINERS b/board/xilinx/zynqmp/MAINTAINERS index 9cd4f3f53e..a631b380bd 100644 --- a/board/xilinx/zynqmp/MAINTAINERS +++ b/board/xilinx/zynqmp/MAINTAINERS @@ -1,6 +1,7 @@ XILINX_ZYNQMP BOARDS M: Michal Simek <michal.simek@xilinx.com> S: Maintained +T: git https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze.git F: arch/arm/dts/zynqmp-* F: arch/arm/dts/avnet-ultra96* F: board/xilinx/common/ diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 731285a736..047b070485 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -596,10 +596,10 @@ int board_late_init(void) puts("Boot from EMMC but without SD0 enabled!\n"); return -1; } - debug("mmc0 device found at %p, seq %d\n", dev, dev->seq); + debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev)); mode = "mmc"; - bootseq = dev->seq; + bootseq = dev_seq(dev); break; case SD_MODE: puts("SD_MODE\n"); @@ -610,10 +610,10 @@ int board_late_init(void) puts("Boot from SD0 but without SD0 enabled!\n"); return -1; } - debug("mmc0 device found at %p, seq %d\n", dev, dev->seq); + debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev)); mode = "mmc"; - bootseq = dev->seq; + bootseq = dev_seq(dev); env_set("modeboot", "sdboot"); break; case SD1_LSHFT_MODE: @@ -628,10 +628,10 @@ int board_late_init(void) puts("Boot from SD1 but without SD1 enabled!\n"); return -1; } - debug("mmc1 device found at %p, seq %d\n", dev, dev->seq); + debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev)); mode = "mmc"; - bootseq = dev->seq; + bootseq = dev_seq(dev); env_set("modeboot", "sdboot"); break; case NAND_MODE: diff --git a/cmd/Kconfig b/cmd/Kconfig index 1595de999b..da86a940ce 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -55,6 +55,15 @@ config SYS_PROMPT This string is displayed in the command line to the left of the cursor. +config SYS_PROMPT_HUSH_PS2 + string "Hush shell secondary prompt" + depends on HUSH_PARSER + default "> " + help + This defines the secondary prompt string, which is + printed when the command interpreter needs more input + to complete a command. Usually "> ". + config SYS_XTRACE string "Command execution tracer" depends on CMDLINE @@ -1682,7 +1691,7 @@ config CMD_EFIDEBUG config CMD_EXCEPTION bool "exception - raise exception" - depends on ARM || RISCV || X86 + depends on ARM || RISCV || SANDBOX || X86 help Enable the 'exception' command which allows to raise an exception. @@ -1908,7 +1917,7 @@ config CMD_REGULATOR The '-f' (force) option can be used for set the value which exceeds the limits, which are found in device-tree and are kept in regulator's - uclass platdata structure. + uclass plat structure. endmenu diff --git a/cmd/Makefile b/cmd/Makefile index dd86675bf2..5b3400a840 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -193,6 +193,7 @@ obj-$(CONFIG_CMD_AVB) += avb.o obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_RISCV) += riscv/ +obj-$(CONFIG_SANDBOX) += sandbox/ obj-$(CONFIG_X86) += x86/ obj-$(CONFIG_ARCH_MVEBU) += mvebu/ @@ -33,9 +33,9 @@ static void show_bus(struct udevice *bus) { struct udevice *dev; - printf("Bus %d:\t%s", bus->req_seq, bus->name); + printf("Bus %d:\t%s", dev_seq(bus), bus->name); if (device_active(bus)) - printf(" (active %d)", bus->seq); + printf(" (active)"); printf("\n"); for (device_find_first_child(bus, &dev); dev; @@ -147,7 +147,7 @@ static int do_axi_bus_num(struct cmd_tbl *cmdtp, int flag, int argc, struct udevice *bus; if (!axi_get_cur_bus(&bus)) - bus_no = bus->seq; + bus_no = dev_seq(bus); else bus_no = -1; diff --git a/cmd/button.c b/cmd/button.c index 64c5a8fa04..1b45d0a2a0 100644 --- a/cmd/button.c +++ b/cmd/button.c @@ -37,7 +37,7 @@ static int list_buttons(void) for (uclass_find_first_device(UCLASS_BUTTON, &dev); dev; uclass_find_next_device(&dev)) { - struct button_uc_plat *plat = dev_get_uclass_platdata(dev); + struct button_uc_plat *plat = dev_get_uclass_plat(dev); if (!plat->label) continue; @@ -26,13 +26,13 @@ static int print_cpu_list(bool detail) for (uclass_first_device(UCLASS_CPU, &dev); dev; uclass_next_device(&dev)) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); struct cpu_info info; bool first = true; int ret, i; ret = cpu_get_desc(dev, buf, sizeof(buf)); - printf("%3d: %-10s %s\n", dev->seq, dev->name, + printf("%3d: %-10s %s\n", dev_seq(dev), dev->name, ret ? "<no description>" : buf); if (!detail) continue; diff --git a/cmd/demo.c b/cmd/demo.c index 7310aa2907..78a55f72b6 100644 --- a/cmd/demo.c +++ b/cmd/demo.c @@ -71,10 +71,10 @@ int do_demo_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) for (i = 0, ret = uclass_first_device(UCLASS_DEMO, &dev); dev; ret = uclass_next_device(&dev)) { - printf("entry %d - instance %08x, ops %08x, platdata %08x\n", + printf("entry %d - instance %08x, ops %08x, plat %08x\n", i++, (uint)map_to_sysmem(dev), (uint)map_to_sysmem(dev->driver->ops), - (uint)map_to_sysmem(dev_get_platdata(dev))); + (uint)map_to_sysmem(dev_get_plat(dev))); } return cmd_process_error(cmdtp, ret); diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 5288b9920b..5fb7b1e3c6 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -19,6 +19,240 @@ #include <linux/ctype.h> #define BS systab.boottime +#define RT systab.runtime + +#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT +/** + * do_efi_capsule_update() - process a capsule update + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + * + * Implement efidebug "capsule update" sub-command. + * process a capsule update. + * + * efidebug capsule update [-v] <capsule address> + */ +static int do_efi_capsule_update(struct cmd_tbl *cmdtp, int flag, + int argc, char * const argv[]) +{ + struct efi_capsule_header *capsule; + int verbose = 0; + char *endp; + efi_status_t ret; + + if (argc != 2 && argc != 3) + return CMD_RET_USAGE; + + if (argc == 3) { + if (strcmp(argv[1], "-v")) + return CMD_RET_USAGE; + + verbose = 1; + argc--; + argv++; + } + + capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16); + if (endp == argv[1]) { + printf("Invalid address: %s", argv[1]); + return CMD_RET_FAILURE; + } + + if (verbose) { + printf("Capsule guid: %pUl\n", &capsule->capsule_guid); + printf("Capsule flags: 0x%x\n", capsule->flags); + printf("Capsule header size: 0x%x\n", capsule->header_size); + printf("Capsule image size: 0x%x\n", + capsule->capsule_image_size); + } + + ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL)); + if (ret) { + printf("Cannot handle a capsule at %p", capsule); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + +static int do_efi_capsule_on_disk_update(struct cmd_tbl *cmdtp, int flag, + int argc, char * const argv[]) +{ + efi_status_t ret; + + ret = efi_launch_capsules(); + + return ret == EFI_SUCCESS ? CMD_RET_SUCCESS : CMD_RET_FAILURE; +} + +/** + * do_efi_capsule_show() - show capsule information + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + * + * Implement efidebug "capsule show" sub-command. + * show capsule information. + * + * efidebug capsule show <capsule address> + */ +static int do_efi_capsule_show(struct cmd_tbl *cmdtp, int flag, + int argc, char * const argv[]) +{ + struct efi_capsule_header *capsule; + char *endp; + + if (argc != 2) + return CMD_RET_USAGE; + + capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16); + if (endp == argv[1]) { + printf("Invalid address: %s", argv[1]); + return CMD_RET_FAILURE; + } + + printf("Capsule guid: %pUl\n", &capsule->capsule_guid); + printf("Capsule flags: 0x%x\n", capsule->flags); + printf("Capsule header size: 0x%x\n", capsule->header_size); + printf("Capsule image size: 0x%x\n", + capsule->capsule_image_size); + + return CMD_RET_SUCCESS; +} + +/** + * do_efi_capsule_res() - show a capsule update result + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + * + * Implement efidebug "capsule result" sub-command. + * show a capsule update result. + * If result number is not specified, CapsuleLast will be shown. + * + * efidebug capsule result [<capsule result number>] + */ +static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag, + int argc, char * const argv[]) +{ + int capsule_id; + char *endp; + char var_name[12]; + u16 var_name16[12], *p; + efi_guid_t guid; + struct efi_capsule_result_variable_header *result = NULL; + efi_uintn_t size; + efi_status_t ret; + + if (argc != 1 && argc != 2) + return CMD_RET_USAGE; + + guid = efi_guid_capsule_report; + if (argc == 1) { + size = sizeof(var_name16); + ret = EFI_CALL(RT->get_variable(L"CapsuleLast", &guid, NULL, + &size, var_name16)); + if (ret != EFI_SUCCESS) { + if (ret == EFI_NOT_FOUND) + printf("CapsuleLast doesn't exist\n"); + else + printf("Failed to get CapsuleLast\n"); + + return CMD_RET_FAILURE; + } + printf("CapsuleLast is %ls\n", var_name16); + } else { + argc--; + argv++; + + capsule_id = simple_strtoul(argv[0], &endp, 16); + if (capsule_id < 0 || capsule_id > 0xffff) + return CMD_RET_USAGE; + + sprintf(var_name, "Capsule%04X", capsule_id); + p = var_name16; + utf8_utf16_strncpy(&p, var_name, 9); + } + + size = 0; + ret = EFI_CALL(RT->get_variable(var_name16, &guid, NULL, &size, NULL)); + if (ret == EFI_BUFFER_TOO_SMALL) { + result = malloc(size); + ret = EFI_CALL(RT->get_variable(var_name16, &guid, NULL, &size, + result)); + if (ret != EFI_SUCCESS) { + free(result); + printf("Failed to get %ls\n", var_name16); + + return CMD_RET_FAILURE; + } + } + + printf("Result total size: 0x%x\n", result->variable_total_size); + printf("Capsule guid: %pUl\n", &result->capsule_guid); + printf("Time processed: %04d-%02d-%02d %02d:%02d:%02d\n", + result->capsule_processed.year, result->capsule_processed.month, + result->capsule_processed.day, result->capsule_processed.hour, + result->capsule_processed.minute, + result->capsule_processed.second); + printf("Capsule status: 0x%lx\n", result->capsule_status); + + free(result); + + return CMD_RET_SUCCESS; +} + +static struct cmd_tbl cmd_efidebug_capsule_sub[] = { + U_BOOT_CMD_MKENT(update, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_update, + "", ""), + U_BOOT_CMD_MKENT(show, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_show, + "", ""), + U_BOOT_CMD_MKENT(disk-update, 0, 0, do_efi_capsule_on_disk_update, + "", ""), + U_BOOT_CMD_MKENT(result, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_res, + "", ""), +}; + +/** + * do_efi_capsule() - manage UEFI capsules + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure + * + * Implement efidebug "capsule" sub-command. + */ +static int do_efi_capsule(struct cmd_tbl *cmdtp, int flag, + int argc, char * const argv[]) +{ + struct cmd_tbl *cp; + + if (argc < 2) + return CMD_RET_USAGE; + + argc--; argv++; + + cp = find_cmd_tbl(argv[0], cmd_efidebug_capsule_sub, + ARRAY_SIZE(cmd_efidebug_capsule_sub)); + if (!cp) + return CMD_RET_USAGE; + + return cp->cmd(cmdtp, flag, argc, argv); +} +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ /** * efi_get_device_handle_info() - get information of UEFI device @@ -278,6 +512,10 @@ static const struct { "Runtime properties", EFI_RT_PROPERTIES_TABLE_GUID, }, + { + "TCG2 Final Events Table", + EFI_TCG2_FINAL_EVENTS_TABLE_GUID, + }, }; /** @@ -1237,6 +1475,10 @@ static int do_efi_query_info(struct cmd_tbl *cmdtp, int flag, static struct cmd_tbl cmd_efidebug_sub[] = { U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""), +#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT + U_BOOT_CMD_MKENT(capsule, CONFIG_SYS_MAXARGS, 1, do_efi_capsule, + "", ""), +#endif U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices, "", ""), U_BOOT_CMD_MKENT(drivers, CONFIG_SYS_MAXARGS, 1, do_efi_show_drivers, @@ -1311,6 +1553,17 @@ static char efidebug_help_text[] = "efidebug boot order [<bootid#1> [<bootid#2> [<bootid#3> [...]]]]\n" " - set/show UEFI boot order\n" "\n" +#ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT + "efidebug capsule update [-v] <capsule address>\n" + " - process a capsule\n" + "efidebug capsule disk-update\n" + " - update a capsule from disk\n" + "efidebug capsule show <capsule address>\n" + " - show capsule information\n" + "efidebug capsule result [<capsule result var>]\n" + " - show a capsule update result\n" + "\n" +#endif "efidebug devices\n" " - show UEFI devices\n" "efidebug drivers\n" diff --git a/cmd/host.c b/cmd/host.c index ff119da738..1d21f796ac 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -91,7 +91,7 @@ static int do_host_info(struct cmd_tbl *cmdtp, int flag, int argc, struct host_block_dev *host_dev; #ifdef CONFIG_BLK - host_dev = dev_get_platdata(blk_dev->bdev); + host_dev = dev_get_plat(blk_dev->bdev); #else host_dev = blk_dev->priv; #endif @@ -390,7 +390,7 @@ static int do_i2c_write(struct cmd_tbl *cmdtp, int flag, int argc, ret = i2c_set_chip_offset_len(dev, alen); if (ret) return i2c_report_err(ret, I2C_ERR_WRITE); - i2c_chip = dev_get_parent_platdata(dev); + i2c_chip = dev_get_parent_plat(dev); if (!i2c_chip) return i2c_report_err(ret, I2C_ERR_WRITE); #endif @@ -1700,14 +1700,14 @@ static void show_bus(struct udevice *bus) { struct udevice *dev; - printf("Bus %d:\t%s", bus->req_seq, bus->name); + printf("Bus %d:\t%s", dev_seq(bus), bus->name); if (device_active(bus)) - printf(" (active %d)", bus->seq); + printf(" (active %d)", dev_seq(bus)); printf("\n"); for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); printf(" %02x: %s, offset len %x, flags %x\n", chip->chip_addr, dev->name, chip->offset_len, @@ -1825,7 +1825,7 @@ static int do_i2c_bus_num(struct cmd_tbl *cmdtp, int flag, int argc, struct udevice *bus; if (!i2c_get_cur_bus(&bus)) - bus_no = bus->seq; + bus_no = dev_seq(bus); else bus_no = -1; #else diff --git a/cmd/itest.c b/cmd/itest.c index a0cf4bee04..9a441ce9b8 100644 --- a/cmd/itest.c +++ b/cmd/itest.c @@ -197,10 +197,10 @@ static int do_itest(struct cmd_tbl *cmdtp, int flag, int argc, #endif value = binary_test (argv[2], argv[1], argv[3], w); break; - case -2: + case CMD_DATA_SIZE_STR: value = binary_test (argv[2], argv[1], argv[3], 0); break; - case -1: + case CMD_DATA_SIZE_ERR: default: puts("Invalid data width specifier\n"); value = 0; @@ -54,7 +54,7 @@ static int list_leds(void) for (uclass_find_first_device(UCLASS_LED, &dev); dev; uclass_find_next_device(&dev)) { - struct led_uc_plat *plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *plat = dev_get_uclass_plat(dev); if (!plat->label) continue; diff --git a/cmd/load.c b/cmd/load.c index 9a3a16979c..c6a7cc4651 100644 --- a/cmd/load.c +++ b/cmd/load.c @@ -228,12 +228,11 @@ static int read_record(char *buf, ulong len) *p = c; } - /* Check for the console hangup (if any different from serial) */ - if (gd->jt->getc != getchar) { - if (ctrlc()) { - return (-1); + /* Check for the console hangup (if any different from serial) */ + if (gd->jt->getc != getchar) { + if (ctrlc()) + return (-1); } - } } /* line too long - truncate */ diff --git a/cmd/lsblk.c b/cmd/lsblk.c index 653dffce04..6a1c8f5ef4 100644 --- a/cmd/lsblk.c +++ b/cmd/lsblk.c @@ -34,7 +34,7 @@ static int do_lsblk(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv uclass_foreach_dev(udev, uc) { if (udev->driver != entry) continue; - desc = dev_get_uclass_platdata(udev); + desc = dev_get_uclass_plat(udev); printf("%c %s %u", i ? ',' : ':', blk_get_if_type_name(desc->if_type), desc->devnum); @@ -393,7 +393,7 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc, * Defaults to long if no or incorrect specification. */ size = cmd_get_data_size(argv[0], 4); - if (size < 0 && size != -2 /* string */) + if (size < 0 && size != CMD_DATA_SIZE_STR) return 1; argc--; diff --git a/cmd/misc.c b/cmd/misc.c index 653deed7f5..ef540e836f 100644 --- a/cmd/misc.c +++ b/cmd/misc.c @@ -34,7 +34,7 @@ static int do_misc_list(struct cmd_tbl *cmdtp, int flag, for (uclass_first_device(UCLASS_MISC, &dev); dev; uclass_next_device(&dev)) { - printf("%-20s %5d %10s\n", dev->name, dev->seq, + printf("%-20s %5d %10s\n", dev->name, dev_seq(dev), dev->driver->name); } diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 7fce723800..d0d2eca904 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -266,7 +266,9 @@ static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) /* Delete only ? */ if (argc < 3 || argv[2] == NULL) { int rc = hdelete_r(name, &env_htab, env_flag); - return !rc; + + /* If the variable didn't exist, don't report an error */ + return rc && rc != -ENOENT ? 1 : 0; } /* @@ -895,7 +897,7 @@ static int do_env_delete(struct cmd_tbl *cmdtp, int flag, while (--argc > 0) { char *name = *++argv; - if (!hdelete_r(name, &env_htab, env_flag)) + if (hdelete_r(name, &env_htab, env_flag)) ret = 1; } @@ -75,9 +75,9 @@ static int osd_get_osd_cur(struct udevice **osdp) */ static void show_osd(struct udevice *osd) { - printf("OSD %d:\t%s", osd->req_seq, osd->name); + printf("OSD %d:\t%s", dev_seq(osd), osd->name); if (device_active(osd)) - printf(" (active %d)", osd->seq); + printf(" (active)"); printf("\n"); } @@ -235,7 +235,7 @@ static int do_osd_num(struct cmd_tbl *cmdtp, int flag, int argc, struct udevice *osd; if (!osd_get_osd_cur(&osd)) - osd_no = osd->seq; + osd_no = dev_seq(osd); else osd_no = -1; printf("Current osd is %d\n", osd_no); @@ -334,20 +334,21 @@ static void pciinfo(struct udevice *bus, bool short_listing) { struct udevice *dev; - pciinfo_header(bus->seq, short_listing); + pciinfo_header(dev_seq(bus), short_listing); for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (short_listing) { - printf("%02x.%02x.%02x ", bus->seq, + printf("%02x.%02x.%02x ", dev_seq(bus), PCI_DEV(pplat->devfn), PCI_FUNC(pplat->devfn)); pci_header_show_brief(dev); } else { - printf("\nFound PCI device %02x.%02x.%02x:\n", bus->seq, + printf("\nFound PCI device %02x.%02x.%02x:\n", + dev_seq(bus), PCI_DEV(pplat->devfn), PCI_FUNC(pplat->devfn)); pci_header_show(dev); } diff --git a/cmd/pmic.c b/cmd/pmic.c index 3bda0534a3..0cb44d0740 100644 --- a/cmd/pmic.c +++ b/cmd/pmic.c @@ -41,7 +41,7 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_USAGE; } - printf("dev: %d @ %s\n", currdev->seq, currdev->name); + printf("dev: %d @ %s\n", dev_seq(currdev), currdev->name); } return CMD_RET_SUCCESS; @@ -66,7 +66,7 @@ static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, printf("| %-*.*s| %-*.*s| %s @ %d\n", LIMIT_DEV, LIMIT_DEV, dev->name, LIMIT_PARENT, LIMIT_PARENT, dev->parent->name, - dev_get_uclass_name(dev->parent), dev->parent->seq); + dev_get_uclass_name(dev->parent), dev_seq(dev->parent)); } if (ret) diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 8716e782f6..b9d9a5786c 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -322,7 +322,8 @@ static int label_localboot(struct pxe_label *label) if (label->append) { char bootargs[CONFIG_SYS_CBSIZE]; - cli_simple_process_macros(label->append, bootargs); + cli_simple_process_macros(label->append, bootargs, + sizeof(bootargs)); env_set("bootargs", bootargs); } @@ -430,7 +431,8 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) strcat(bootargs, ip_str); strcat(bootargs, mac_str); - cli_simple_process_macros(bootargs, finalbootargs); + cli_simple_process_macros(bootargs, finalbootargs, + sizeof(finalbootargs)); env_set("bootargs", finalbootargs); printf("append: %s\n", finalbootargs); } @@ -451,11 +453,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) /* * fdt usage is optional: - * It handles the following scenarios. All scenarios are exclusive + * It handles the following scenarios. * - * Scenario 1: If fdt_addr_r specified and "fdt" label is defined in - * pxe file, retrieve fdt blob from server. Pass fdt_addr_r to bootm, - * and adjust argc appropriately. + * Scenario 1: If fdt_addr_r specified and "fdt" or "fdtdir" label is + * defined in pxe file, retrieve fdt blob from server. Pass fdt_addr_r to + * bootm, and adjust argc appropriately. + * + * If retrieve fails and no exact fdt blob is specified in pxe file with + * "fdt" label, try Scenario 2. * * Scenario 2: If there is an fdt_addr specified, pass it along to * bootm, and adjust argc appropriately. @@ -521,9 +526,13 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) free(fdtfilefree); if (err < 0) { - printf("Skipping %s for failure retrieving fdt\n", - label->name); - goto cleanup; + bootm_argv[3] = NULL; + + if (label->fdt) { + printf("Skipping %s for failure retrieving FDT\n", + label->name); + goto cleanup; + } } } else { bootm_argv[3] = NULL; diff --git a/cmd/regulator.c b/cmd/regulator.c index aa06c9a9fc..60a70036d6 100644 --- a/cmd/regulator.c +++ b/cmd/regulator.c @@ -25,7 +25,7 @@ static int failure(int ret) static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; const char *name; int ret = -ENXIO; @@ -43,7 +43,7 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_USAGE; } - uc_pdata = dev_get_uclass_platdata(currdev); + uc_pdata = dev_get_uclass_plat(currdev); if (!uc_pdata) { printf("%s: no regulator platform data!\n", currdev->name); return failure(ret); @@ -55,9 +55,9 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_SUCCESS; } -static int curr_dev_and_platdata(struct udevice **devp, - struct dm_regulator_uclass_platdata **uc_pdata, - bool allow_type_fixed) +static int curr_dev_and_plat(struct udevice **devp, + struct dm_regulator_uclass_plat **uc_pdata, + bool allow_type_fixed) { *devp = NULL; *uc_pdata = NULL; @@ -69,7 +69,7 @@ static int curr_dev_and_platdata(struct udevice **devp, *devp = currdev; - *uc_pdata = dev_get_uclass_platdata(*devp); + *uc_pdata = dev_get_uclass_plat(*devp); if (!*uc_pdata) { pr_err("Regulator: %s - missing platform data!\n", currdev->name); return CMD_RET_FAILURE; @@ -86,7 +86,7 @@ static int curr_dev_and_platdata(struct udevice **devp, static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; int ret; @@ -100,7 +100,7 @@ static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, if (ret) continue; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); printf("| %-*.*s| %-*.*s| %s\n", LIMIT_DEVNAME, LIMIT_DEVNAME, dev->name, LIMIT_OFNAME, LIMIT_OFNAME, uc_pdata->name, @@ -143,14 +143,14 @@ static int do_info(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct dm_regulator_mode *modes; const char *parent_uc; int mode_count; int ret; int i; - ret = curr_dev_and_platdata(&dev, &uc_pdata, true); + ret = curr_dev_and_plat(&dev, &uc_pdata, true); if (ret) return ret; @@ -183,7 +183,7 @@ static int do_info(struct cmd_tbl *cmdtp, int flag, int argc, } static void do_status_detail(struct udevice *dev, - struct dm_regulator_uclass_platdata *uc_pdata) + struct dm_regulator_uclass_plat *uc_pdata) { int current, value, mode; const char *mode_name; @@ -207,12 +207,12 @@ static void do_status_detail(struct udevice *dev, static void do_status_line(struct udevice *dev) { - struct dm_regulator_uclass_platdata *pdata; + struct dm_regulator_uclass_plat *pdata; int current, value, mode; const char *mode_name; bool enabled; - pdata = dev_get_uclass_platdata(dev); + pdata = dev_get_uclass_plat(dev); enabled = regulator_get_enable(dev); value = regulator_get_value(dev); current = regulator_get_current(dev); @@ -237,12 +237,12 @@ static void do_status_line(struct udevice *dev) static int do_status(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; int ret; if (currdev && (argc < 2 || strcmp(argv[1], "-a"))) { - ret = curr_dev_and_platdata(&dev, &uc_pdata, true); + ret = curr_dev_and_plat(&dev, &uc_pdata, true); if (ret) return CMD_RET_FAILURE; do_status_detail(dev, uc_pdata); @@ -263,12 +263,12 @@ static int do_value(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int value; int force; int ret; - ret = curr_dev_and_platdata(&dev, &uc_pdata, argc == 1); + ret = curr_dev_and_plat(&dev, &uc_pdata, argc == 1); if (ret) return ret; @@ -313,11 +313,11 @@ static int do_current(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int current; int ret; - ret = curr_dev_and_platdata(&dev, &uc_pdata, argc == 1); + ret = curr_dev_and_plat(&dev, &uc_pdata, argc == 1); if (ret) return ret; @@ -353,11 +353,11 @@ static int do_mode(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int mode; int ret; - ret = curr_dev_and_platdata(&dev, &uc_pdata, false); + ret = curr_dev_and_plat(&dev, &uc_pdata, false); if (ret) return ret; @@ -389,10 +389,10 @@ static int do_enable(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int ret; - ret = curr_dev_and_platdata(&dev, &uc_pdata, true); + ret = curr_dev_and_plat(&dev, &uc_pdata, true); if (ret) return ret; @@ -409,10 +409,10 @@ static int do_disable(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int ret; - ret = curr_dev_and_platdata(&dev, &uc_pdata, true); + ret = curr_dev_and_plat(&dev, &uc_pdata, true); if (ret) return ret; diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c index e8b9178e74..b3ddcebe31 100644 --- a/cmd/remoteproc.c +++ b/cmd/remoteproc.c @@ -32,10 +32,10 @@ static int print_remoteproc_list(void) struct dm_rproc_uclass_pdata *uc_pdata; const struct dm_rproc_ops *ops = rproc_get_ops(dev); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); /* Do not print if rproc is not probed */ - if (!(dev->flags & DM_FLAG_ACTIVATED)) + if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)) continue; switch (uc_pdata->mem_type) { @@ -47,7 +47,7 @@ static int print_remoteproc_list(void) break; } printf("%d - Name:'%s' type:'%s' supports: %s%s%s%s%s%s\n", - dev->seq, + dev_seq(dev), uc_pdata->name, type, ops->load ? "load " : "", diff --git a/cmd/sandbox/Makefile b/cmd/sandbox/Makefile new file mode 100644 index 0000000000..24df023ece --- /dev/null +++ b/cmd/sandbox/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_CMD_EXCEPTION) += exception.o diff --git a/cmd/sandbox/exception.c b/cmd/sandbox/exception.c new file mode 100644 index 0000000000..1aa1d673ae --- /dev/null +++ b/cmd/sandbox/exception.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * The 'exception' command can be used for testing exception handling. + * + * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de> + */ + +#include <common.h> +#include <command.h> + +static int do_sigsegv(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + u8 *ptr = NULL; + + *ptr = 0; + return CMD_RET_FAILURE; +} + +static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + asm volatile (".word 0xffff\n"); + return CMD_RET_FAILURE; +} + +static struct cmd_tbl cmd_sub[] = { + U_BOOT_CMD_MKENT(sigsegv, CONFIG_SYS_MAXARGS, 1, do_sigsegv, + "", ""), + U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined, + "", ""), +}; + +static char exception_help_text[] = + "<ex>\n" + " The following exceptions are available:\n" + " undefined - undefined instruction\n" + " sigsegv - illegal memory access\n" + ; + +#include <exception.h> diff --git a/cmd/setexpr.c b/cmd/setexpr.c index 770dc24d2b..e828be3970 100644 --- a/cmd/setexpr.c +++ b/cmd/setexpr.c @@ -13,10 +13,27 @@ #include <command.h> #include <env.h> #include <log.h> +#include <malloc.h> #include <mapmem.h> +#include <linux/sizes.h> -static ulong get_arg(char *s, int w) +/** + * struct expr_arg: Holds an argument to an expression + * + * @ival: Integer value (if width is not CMD_DATA_SIZE_STR) + * @sval: String value (if width is CMD_DATA_SIZE_STR) + */ +struct expr_arg { + union { + ulong ival; + char *sval; + }; +}; + +static int get_arg(char *s, int w, struct expr_arg *argp) { + struct expr_arg arg; + /* * If the parameter starts with a '*' then assume it is a pointer to * the value we want. @@ -25,6 +42,8 @@ static ulong get_arg(char *s, int w) ulong *p; ulong addr; ulong val; + int len; + char *str; addr = simple_strtoul(&s[1], NULL, 16); switch (w) { @@ -32,31 +51,56 @@ static ulong get_arg(char *s, int w) p = map_sysmem(addr, sizeof(uchar)); val = (ulong)*(uchar *)p; unmap_sysmem(p); - return val; + arg.ival = val; + break; case 2: p = map_sysmem(addr, sizeof(ushort)); val = (ulong)*(ushort *)p; unmap_sysmem(p); - return val; + arg.ival = val; + break; + case CMD_DATA_SIZE_STR: + p = map_sysmem(addr, SZ_64K); + + /* Maximum string length of 64KB plus terminator */ + len = strnlen((char *)p, SZ_64K) + 1; + str = malloc(len); + if (!str) { + printf("Out of memory\n"); + return -ENOMEM; + } + memcpy(str, p, len); + str[len - 1] = '\0'; + unmap_sysmem(p); + arg.sval = str; + break; case 4: + p = map_sysmem(addr, sizeof(u32)); + val = *(u32 *)p; + unmap_sysmem(p); + arg.ival = val; + break; default: p = map_sysmem(addr, sizeof(ulong)); val = *p; unmap_sysmem(p); - return val; + arg.ival = val; + break; } } else { - return simple_strtoul(s, NULL, 16); + if (w == CMD_DATA_SIZE_STR) + return -EINVAL; + arg.ival = simple_strtoul(s, NULL, 16); } + *argp = arg; + + return 0; } #ifdef CONFIG_REGEX #include <slre.h> -#define SLRE_BUFSZ 16384 -#define SLRE_PATSZ 4096 - /* * memstr - Find the first substring in memory * @s1: The string to be searched @@ -79,13 +123,24 @@ static char *memstr(const char *s1, int l1, const char *s2, int l2) return NULL; } -static char *substitute(char *string, /* string buffer */ - int *slen, /* current string length */ - int ssize, /* string bufer size */ - const char *old,/* old (replaced) string */ - int olen, /* length of old string */ - const char *new,/* new (replacement) string */ - int nlen) /* length of new string */ +/** + * substitute() - Substitute part of one string with another + * + * This updates @string so that the first occurrence of @old is replaced with + * @new + * + * @string: String buffer containing string to update at the start + * @slen: Pointer to current string length, updated on success + * @ssize: Size of string buffer + * @old: Old string to find in the buffer (no terminator needed) + * @olen: Length of @old excluding terminator + * @new: New string to replace @old with + * @nlen: Length of @new excluding terminator + * @return pointer to immediately after the copied @new in @string, or NULL if + * no replacement took place + */ +static char *substitute(char *string, int *slen, int ssize, + const char *old, int olen, const char *new, int nlen) { char *p = memstr(string, *slen, old, olen); @@ -114,7 +169,7 @@ static char *substitute(char *string, /* string buffer */ memmove(p + nlen, p + olen, tail); } - /* insert substitue */ + /* insert substitute */ memcpy(p, new, nlen); *slen += nlen - olen; @@ -122,71 +177,32 @@ static char *substitute(char *string, /* string buffer */ return p + nlen; } -/* - * Perform regex operations on a environment variable - * - * Returns 0 if OK, 1 in case of errors. - */ -static int regex_sub(const char *name, - const char *r, const char *s, const char *t, - int global) +int setexpr_regex_sub(char *data, uint data_size, char *nbuf, uint nbuf_size, + const char *r, const char *s, bool global) { struct slre slre; - char data[SLRE_BUFSZ]; char *datap = data; - const char *value; int res, len, nlen, loop; - if (name == NULL) - return 1; - if (slre_compile(&slre, r) == 0) { printf("Error compiling regex: %s\n", slre.err_str); return 1; } - if (t == NULL) { - value = env_get(name); - - if (value == NULL) { - printf("## Error: variable \"%s\" not defined\n", name); - return 1; - } - t = value; - } - - debug("REGEX on %s=%s\n", name, t); - debug("REGEX=\"%s\", SUBST=\"%s\", GLOBAL=%d\n", - r, s ? s : "<NULL>", global); - - len = strlen(t); - if (len + 1 > SLRE_BUFSZ) { - printf("## error: subst buffer overflow: have %d, need %d\n", - SLRE_BUFSZ, len + 1); - return 1; - } - - strcpy(data, t); - - if (s == NULL) - nlen = 0; - else - nlen = strlen(s); - + len = strlen(data); for (loop = 0;; loop++) { struct cap caps[slre.num_caps + 2]; - char nbuf[SLRE_PATSZ]; const char *old; char *np; int i, olen; (void) memset(caps, 0, sizeof(caps)); - res = slre_match(&slre, datap, len, caps); + res = slre_match(&slre, datap, len - (datap - data), caps); debug("Result: %d\n", res); - for (i = 0; i < slre.num_caps; i++) { + for (i = 0; i <= slre.num_caps; i++) { if (caps[i].len > 0) { debug("Substring %d: [%.*s]\n", i, caps[i].len, caps[i].ptr); @@ -195,7 +211,7 @@ static int regex_sub(const char *name, if (res == 0) { if (loop == 0) { - printf("%s: No match\n", t); + printf("%s: No match\n", data); return 1; } else { break; @@ -204,17 +220,16 @@ static int regex_sub(const char *name, debug("## MATCH ## %s\n", data); - if (s == NULL) { - printf("%s=%s\n", name, t); + if (!s) return 1; - } old = caps[0].ptr; olen = caps[0].len; + nlen = strlen(s); - if (nlen + 1 >= SLRE_PATSZ) { + if (nlen + 1 >= nbuf_size) { printf("## error: pattern buffer overflow: have %d, need %d\n", - SLRE_BUFSZ, nlen + 1); + nbuf_size, nlen + 1); return 1; } strcpy(nbuf, s); @@ -259,7 +274,7 @@ static int regex_sub(const char *name, break; np = substitute(np, &nlen, - SLRE_PATSZ, + nbuf_size - (np - nbuf), backref, 2, caps[i].ptr, caps[i].len); @@ -269,9 +284,8 @@ static int regex_sub(const char *name, } debug("## SUBST(2) ## %s\n", nbuf); - datap = substitute(datap, &len, SLRE_BUFSZ, - old, olen, - nbuf, nlen); + datap = substitute(datap, &len, data_size - (datap - data), + old, olen, nbuf, nlen); if (datap == NULL) return 1; @@ -285,6 +299,62 @@ static int regex_sub(const char *name, } debug("## FINAL (now env_set()) : %s\n", data); + return 0; +} + +#define SLRE_BUFSZ 16384 +#define SLRE_PATSZ 4096 + +/* + * Perform regex operations on a environment variable + * + * Returns 0 if OK, 1 in case of errors. + */ +static int regex_sub_var(const char *name, const char *r, const char *s, + const char *t, int global) +{ + struct slre slre; + char data[SLRE_BUFSZ]; + char nbuf[SLRE_PATSZ]; + const char *value; + int len; + int ret; + + if (!name) + return 1; + + if (slre_compile(&slre, r) == 0) { + printf("Error compiling regex: %s\n", slre.err_str); + return 1; + } + + if (!t) { + value = env_get(name); + if (!value) { + printf("## Error: variable \"%s\" not defined\n", name); + return 1; + } + t = value; + } + + debug("REGEX on %s=%s\n", name, t); + debug("REGEX=\"%s\", SUBST=\"%s\", GLOBAL=%d\n", r, s ? s : "<NULL>", + global); + + len = strlen(t); + if (len + 1 > SLRE_BUFSZ) { + printf("## error: subst buffer overflow: have %d, need %d\n", + SLRE_BUFSZ, len + 1); + return 1; + } + + strcpy(data, t); + + ret = setexpr_regex_sub(data, SLRE_BUFSZ, nbuf, SLRE_PATSZ, r, s, + global); + if (ret) + return 1; + printf("%s=%s\n", name, data); return env_set(name, data); @@ -294,8 +364,9 @@ static int regex_sub(const char *name, static int do_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - ulong a, b; + struct expr_arg aval, bval; ulong value; + int ret = 0; int w; /* @@ -312,12 +383,19 @@ static int do_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, w = cmd_get_data_size(argv[0], 4); - a = get_arg(argv[2], w); + if (get_arg(argv[2], w, &aval)) + return CMD_RET_FAILURE; /* plain assignment: "setexpr name value" */ if (argc == 3) { - env_set_hex(argv[1], a); - return 0; + if (w == CMD_DATA_SIZE_STR) { + ret = env_set(argv[1], aval.sval); + free(aval.sval); + } else { + ret = env_set_hex(argv[1], aval.ival); + } + + return ret; } /* 5 or 6 args (6 args only with [g]sub) */ @@ -327,10 +405,10 @@ static int do_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, * with 5 args, "t" will be NULL */ if (strcmp(argv[2], "gsub") == 0) - return regex_sub(argv[1], argv[3], argv[4], argv[5], 1); + return regex_sub_var(argv[1], argv[3], argv[4], argv[5], 1); if (strcmp(argv[2], "sub") == 0) - return regex_sub(argv[1], argv[3], argv[4], argv[5], 0); + return regex_sub_var(argv[1], argv[3], argv[4], argv[5], 0); #endif /* standard operators: "setexpr name val1 op val2" */ @@ -340,49 +418,89 @@ static int do_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, if (strlen(argv[3]) != 1) return CMD_RET_USAGE; - b = get_arg(argv[4], w); - - switch (argv[3][0]) { - case '|': - value = a | b; - break; - case '&': - value = a & b; - break; - case '+': - value = a + b; - break; - case '^': - value = a ^ b; - break; - case '-': - value = a - b; - break; - case '*': - value = a * b; - break; - case '/': - value = a / b; - break; - case '%': - value = a % b; - break; - default: - printf("invalid op\n"); - return 1; + if (get_arg(argv[4], w, &bval)) { + if (w == CMD_DATA_SIZE_STR) + free(aval.sval); + return CMD_RET_FAILURE; } - env_set_hex(argv[1], value); + if (w == CMD_DATA_SIZE_STR) { + int len; + char *str; + + switch (argv[3][0]) { + case '+': + len = strlen(aval.sval) + strlen(bval.sval) + 1; + str = malloc(len); + if (!str) { + printf("Out of memory\n"); + ret = CMD_RET_FAILURE; + } else { + /* These were copied out and checked earlier */ + strcpy(str, aval.sval); + strcat(str, bval.sval); + ret = env_set(argv[1], str); + if (ret) + printf("Could not set var\n"); + free(str); + } + break; + default: + printf("invalid op\n"); + ret = 1; + } + } else { + ulong a = aval.ival; + ulong b = bval.ival; - return 0; + switch (argv[3][0]) { + case '|': + value = a | b; + break; + case '&': + value = a & b; + break; + case '+': + value = a + b; + break; + case '^': + value = a ^ b; + break; + case '-': + value = a - b; + break; + case '*': + value = a * b; + break; + case '/': + value = a / b; + break; + case '%': + value = a % b; + break; + default: + printf("invalid op\n"); + return 1; + } + + env_set_hex(argv[1], value); + } + + if (w == CMD_DATA_SIZE_STR) { + free(aval.sval); + free(bval.sval); + } + + return ret; } U_BOOT_CMD( setexpr, 6, 0, do_setexpr, "set environment variable as the result of eval expression", - "[.b, .w, .l] name [*]value1 <op> [*]value2\n" + "[.b, .w, .l, .s] name [*]value1 <op> [*]value2\n" " - set environment variable 'name' to the result of the evaluated\n" " expression specified by <op>. <op> can be &, |, ^, +, -, *, /, %\n" + " (for strings only + is supported)\n" " size argument is only meaningful if value1 and/or value2 are\n" " memory addresses (*)\n" "setexpr[.b, .w, .l] name [*]value\n" diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c index 5fa4788a72..daae91100a 100644 --- a/cmd/tpm-v2.c +++ b/cmd/tpm-v2.c @@ -116,7 +116,8 @@ static int do_tpm2_pcr_extend(struct cmd_tbl *cmdtp, int flag, int argc, if (index >= priv->pcr_count) return -EINVAL; - rc = tpm2_pcr_extend(dev, index, digest); + rc = tpm2_pcr_extend(dev, index, TPM2_ALG_SHA256, digest, + TPM2_DIGEST_LEN); unmap_sysmem(digest); @@ -21,7 +21,7 @@ static int w1_bus(void) printf("one wire interface not found\n"); return CMD_RET_FAILURE; } - printf("Bus %d:\t%s", bus->seq, bus->name); + printf("Bus %d:\t%s", dev_seq(bus), bus->name); if (device_active(bus)) printf(" (active)"); printf("\n"); @@ -31,7 +31,7 @@ static int w1_bus(void) device_find_next_child(&dev)) { ret = device_probe(dev); - printf("\t%s (%d) uclass %s : ", dev->name, dev->seq, + printf("\t%s (%d) uclass %s : ", dev->name, dev_seq(dev), dev->uclass->uc_drv->name); if (ret) diff --git a/common/Kconfig.boot b/common/Kconfig.boot index 3f6d9c1a25..58e98548de 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -865,6 +865,23 @@ config BOOTARGS CONFIG_BOOTARGS goes into the environment value "bootargs". Note that this value will also override the "chosen" node in FDT blob. +config BOOTARGS_SUBST + bool "Support substituting strings in boot arguments" + help + This allows substituting string values in the boot arguments. These + are applied after the commandline has been built. + + One use for this is to insert the root-disk UUID into the command + line where bootargs contains "root=${uuid}" + + setenv bootargs "console= root=${uuid}" + # Set the 'uuid' environment variable + part uuid mmc 2:2 uuid + + # Command-line substitution will put the real uuid into the + # kernel command line + bootm + config USE_BOOTCOMMAND bool "Enable a default value for bootcmd" help diff --git a/common/bootm.c b/common/bootm.c index 167eea4a1e..8298693900 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -7,6 +7,7 @@ #ifndef USE_HOSTCC #include <common.h> #include <bootstage.h> +#include <cli.h> #include <cpu_func.h> #include <env.h> #include <errno.h> @@ -19,6 +20,7 @@ #include <net.h> #include <asm/cache.h> #include <asm/io.h> +#include <linux/sizes.h> #if defined(CONFIG_CMD_USB) #include <usb.h> #endif @@ -35,6 +37,8 @@ #define CONFIG_SYS_BOOTM_LEN 0x800000 #endif +#define MAX_CMDLINE_SIZE SZ_4K + #define IH_INITRD_ARCH IH_ARCH_DEFAULT #ifndef USE_HOSTCC @@ -465,19 +469,35 @@ ulong bootm_disable_interrupts(void) return iflag; } -#if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY) - -#define CONSOLE_ARG "console=" -#define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1) +#define CONSOLE_ARG "console=" +#define CONSOLE_ARG_SIZE sizeof(CONSOLE_ARG) -static void fixup_silent_linux(void) +/** + * fixup_silent_linux() - Handle silencing the linux boot if required + * + * This uses the silent_linux envvar to control whether to add/set a "console=" + * parameter to the command line + * + * @buf: Buffer containing the string to process + * @maxlen: Maximum length of buffer + * @return 0 if OK, -ENOSPC if @maxlen is too small + */ +static int fixup_silent_linux(char *buf, int maxlen) { - char *buf; - const char *env_val; - char *cmdline = env_get("bootargs"); int want_silent; + char *cmdline; + int size; /* + * Move the input string to the end of buffer. The output string will be + * built up at the start. + */ + size = strlen(buf) + 1; + if (size * 2 > maxlen) + return -ENOSPC; + cmdline = buf + maxlen - size; + memmove(cmdline, buf, size); + /* * Only fix cmdline when requested. The environment variable can be: * * no - we never fixup @@ -486,44 +506,132 @@ static void fixup_silent_linux(void) */ want_silent = env_get_yesno("silent_linux"); if (want_silent == 0) - return; + return 0; else if (want_silent == -1 && !(gd->flags & GD_FLG_SILENT)) - return; + return 0; debug("before silent fix-up: %s\n", cmdline); - if (cmdline && (cmdline[0] != '\0')) { + if (*cmdline) { char *start = strstr(cmdline, CONSOLE_ARG); - /* Allocate space for maximum possible new command line */ - buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_LEN + 1); - if (!buf) { - debug("%s: out of memory\n", __func__); - return; - } + /* Check space for maximum possible new command line */ + if (size + CONSOLE_ARG_SIZE > maxlen) + return -ENOSPC; if (start) { char *end = strchr(start, ' '); - int num_start_bytes = start - cmdline + CONSOLE_ARG_LEN; + int start_bytes; - strncpy(buf, cmdline, num_start_bytes); + start_bytes = start - cmdline + CONSOLE_ARG_SIZE - 1; + strncpy(buf, cmdline, start_bytes); if (end) - strcpy(buf + num_start_bytes, end); + strcpy(buf + start_bytes, end); else - buf[num_start_bytes] = '\0'; + buf[start_bytes] = '\0'; } else { sprintf(buf, "%s %s", cmdline, CONSOLE_ARG); } - env_val = buf; + if (buf + strlen(buf) >= cmdline) + return -ENOSPC; } else { - buf = NULL; - env_val = CONSOLE_ARG; + if (maxlen < sizeof(CONSOLE_ARG)) + return -ENOSPC; + strcpy(buf, CONSOLE_ARG); } + debug("after silent fix-up: %s\n", buf); + + return 0; +} - env_set("bootargs", env_val); - debug("after silent fix-up: %s\n", env_val); +/** + * process_subst() - Handle substitution of ${...} fields in the environment + * + * Handle variable substitution in the provided buffer + * + * @buf: Buffer containing the string to process + * @maxlen: Maximum length of buffer + * @return 0 if OK, -ENOSPC if @maxlen is too small + */ +static int process_subst(char *buf, int maxlen) +{ + char *cmdline; + int size; + int ret; + + /* Move to end of buffer */ + size = strlen(buf) + 1; + cmdline = buf + maxlen - size; + if (buf + size > cmdline) + return -ENOSPC; + memmove(cmdline, buf, size); + + ret = cli_simple_process_macros(cmdline, buf, cmdline - buf); + + return ret; +} + +int bootm_process_cmdline(char *buf, int maxlen, int flags) +{ + int ret; + + /* Check config first to enable compiler to eliminate code */ + if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && + !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && + (flags & BOOTM_CL_SILENT)) { + ret = fixup_silent_linux(buf, maxlen); + if (ret) + return log_msg_ret("silent", ret); + } + if (IS_ENABLED(CONFIG_BOOTARGS_SUBST) && (flags & BOOTM_CL_SUBST)) { + ret = process_subst(buf, maxlen); + if (ret) + return log_msg_ret("silent", ret); + } + + return 0; +} + +int bootm_process_cmdline_env(int flags) +{ + const int maxlen = MAX_CMDLINE_SIZE; + bool do_silent; + const char *env; + char *buf; + int ret; + + /* First check if any action is needed */ + do_silent = IS_ENABLED(CONFIG_SILENT_CONSOLE) && + !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && (flags & BOOTM_CL_SILENT); + if (!do_silent && !IS_ENABLED(CONFIG_BOOTARGS_SUBST)) + return 0; + + env = env_get("bootargs"); + if (env && strlen(env) >= maxlen) + return -E2BIG; + buf = malloc(maxlen); + if (!buf) + return -ENOMEM; + if (env) + strcpy(buf, env); + else + *buf = '\0'; + ret = bootm_process_cmdline(buf, maxlen, flags); + if (!ret) { + ret = env_set("bootargs", buf); + + /* + * If buf is "" and bootargs does not exist, this will produce + * an error trying to delete bootargs. Ignore it + */ + if (ret == -ENOENT) + ret = 0; + } free(buf); + if (ret) + return log_msg_ret("env", ret); + + return 0; } -#endif /* CONFIG_SILENT_CONSOLE */ /** * Execute selected states of the bootm command. @@ -627,10 +735,12 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, if (!ret && (states & BOOTM_STATE_OS_BD_T)) ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images); if (!ret && (states & BOOTM_STATE_OS_PREP)) { -#if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY) - if (images->os.os == IH_OS_LINUX) - fixup_silent_linux(); -#endif + ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX); + if (ret) { + printf("Cmdline setup failed (err=%d)\n", ret); + ret = CMD_RET_FAILURE; + goto err; + } ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images); } diff --git a/common/cli_hush.c b/common/cli_hush.c index 66995c255b..b7f0f0ff41 100644 --- a/common/cli_hush.c +++ b/common/cli_hush.c @@ -84,9 +84,6 @@ #include <cli.h> #include <cli_hush.h> #include <command.h> /* find_cmd */ -#ifndef CONFIG_SYS_PROMPT_HUSH_PS2 -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " -#endif #endif #ifndef __U_BOOT__ #include <ctype.h> /* isalpha, isdigit */ diff --git a/common/cli_simple.c b/common/cli_simple.c index 7d91316a0f..e80ba488a5 100644 --- a/common/cli_simple.c +++ b/common/cli_simple.c @@ -60,13 +60,14 @@ int cli_simple_parse_line(char *line, char *argv[]) return nargs; } -void cli_simple_process_macros(const char *input, char *output) +int cli_simple_process_macros(const char *input, char *output, int max_size) { char c, prev; const char *varname_start = NULL; int inputcnt = strlen(input); - int outputcnt = CONFIG_SYS_CBSIZE; + int outputcnt = max_size; int state = 0; /* 0 = waiting for '$' */ + int ret; /* 1 = waiting for '(' or '{' */ /* 2 = waiting for ')' or '}' */ @@ -157,13 +158,18 @@ void cli_simple_process_macros(const char *input, char *output) prev = c; } - if (outputcnt) + ret = inputcnt ? -ENOSPC : 0; + if (outputcnt) { *output = 0; - else + } else { *(output - 1) = 0; + ret = -ENOSPC; + } debug_parser("[PROCESS_MACROS] OUTPUT len %zd: \"%s\"\n", strlen(output_start), output_start); + + return ret; } /* @@ -239,7 +245,8 @@ int cli_simple_run_command(const char *cmd, int flag) debug_parser("token: \"%s\"\n", token); /* find macros in this token and replace them */ - cli_simple_process_macros(token, finaltoken); + cli_simple_process_macros(token, finaltoken, + sizeof(finaltoken)); /* Extract arguments */ argc = cli_simple_parse_line(finaltoken, argv); diff --git a/common/command.c b/common/command.c index 2c491e20a7..068cb55b4c 100644 --- a/common/command.c +++ b/common/command.c @@ -475,13 +475,13 @@ int cmd_get_data_size(char* arg, int default_size) case 'l': return 4; case 's': - return -2; + return CMD_DATA_SIZE_STR; case 'q': if (MEM_SUPPORT_64BIT_DATA) return 8; /* no break */ default: - return -1; + return CMD_DATA_SIZE_ERR; } } return default_size; diff --git a/common/fdt_support.c b/common/fdt_support.c index 5ae75df3c6..638eca983e 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -20,6 +20,8 @@ #include <exports.h> #include <fdtdec.h> +DECLARE_GLOBAL_DATA_PTR; + /** * fdt_getprop_u32_default_node - Return a node's property or a default * @@ -996,8 +998,8 @@ void fdt_del_node_and_alias(void *blob, const char *alias) /* Max address size we deal with */ #define OF_MAX_ADDR_CELLS 4 #define OF_BAD_ADDR FDT_ADDR_T_NONE -#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ - (ns) > 0) +#define OF_CHECK_COUNTS(na, ns) (((na) > 0 && (na) <= OF_MAX_ADDR_CELLS) && \ + ((ns) > 0 || gd_size_cells_0())) /* Debug utility */ #ifdef DEBUG diff --git a/common/image-fdt.c b/common/image-fdt.c index 327a8c4c39..707b44a69d 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -407,6 +407,9 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, &fit_uname_config, arch, &load, &len); + if (fdt_noffset < 0) + goto error; + images->fit_hdr_fdt = map_sysmem(fdt_addr, 0); images->fit_uname_fdt = fit_uname_fdt; images->fit_noffset_fdt = fdt_noffset; diff --git a/common/image.c b/common/image.c index 451fc689a8..6923dac7c0 100644 --- a/common/image.c +++ b/common/image.c @@ -189,6 +189,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_STM32IMAGE, "stm32image", "STMicroelectronics STM32 Image" }, { IH_TYPE_MTKIMAGE, "mtk_image", "MediaTek BootROM loadable Image" }, { IH_TYPE_COPRO, "copro", "Coprocessor Image"}, + { IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot Image" }, { -1, "", "", }, }; diff --git a/common/lcd_simplefb.c b/common/lcd_simplefb.c index fca600691e..246eb4c495 100644 --- a/common/lcd_simplefb.c +++ b/common/lcd_simplefb.c @@ -22,7 +22,7 @@ static int lcd_dt_simplefb_configure_node(void *blob, int off) const char *name; ulong fb_base; #ifdef CONFIG_DM_VIDEO - struct video_uc_platdata *plat; + struct video_uc_plat *plat; struct video_priv *uc_priv; struct udevice *dev; int ret; @@ -31,7 +31,7 @@ static int lcd_dt_simplefb_configure_node(void *blob, int off) if (ret) return ret; uc_priv = dev_get_uclass_priv(dev); - plat = dev_get_uclass_platdata(dev); + plat = dev_get_uclass_plat(dev); xsize = uc_priv->xsize; ysize = uc_priv->ysize; bpix = uc_priv->bpix; diff --git a/common/main.c b/common/main.c index 4b3cd302c3..ae5bcdb32f 100644 --- a/common/main.c +++ b/common/main.c @@ -16,6 +16,7 @@ #include <init.h> #include <net.h> #include <version.h> +#include <efi_loader.h> static void run_preboot_environment_command(void) { @@ -53,6 +54,9 @@ void main_loop(void) if (IS_ENABLED(CONFIG_UPDATE_TFTP)) update_tftp(0UL, NULL, NULL); + if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) + efi_launch_capsules(); + s = bootdelay_process(); if (cli_process_fdt(&s)) cli_secure_boot_cmd(s); diff --git a/common/spl/Kconfig b/common/spl/Kconfig index d8086bd9e8..6b0186763b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -113,6 +113,15 @@ config SPL_FSL_PBL Create boot binary having SPL binary in PBI format concatenated with u-boot binary. +config SPL_ALLOC_BD + bool "Allocate memory for bd_info" + default y if X86 || SANDBOX + help + Some boards don't allocate space for this in their board_init_f() + code. In this case U-Boot can allocate space for gd->bd in the + standard SPL flow (board_init_r()). Enable this option to support + this feature. + endmenu config HANDOFF @@ -1276,6 +1285,15 @@ config SPL_ATF is loaded by SPL (which is considered as BL2 in ATF terminology). More detail at: https://github.com/ARM-software/arm-trusted-firmware +config SPL_ATF_LOAD_IMAGE_V2 + bool "Use the new LOAD_IMAGE_V2 parameter passing" + depends on SPL_ATF + help + Some platforms use the newer LOAD_IMAGE_V2 parameter passing. + + If you want to load a bl31 image from the SPL and need the new + method, say Y. + config SPL_ATF_NO_PLATFORM_PARAM bool "Pass no platform parameter" depends on SPL_ATF diff --git a/common/spl/spl.c b/common/spl/spl.c index 63c48fbf33..835c53deaa 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -53,9 +53,6 @@ binman_sym_declare(ulong, spl, image_pos); binman_sym_declare(ulong, spl, size); #endif -/* Define board data structure */ -static struct bd_info bdata __attribute__ ((section(".data"))); - /* * Board-specific Platform code can reimplement show_boot_progress () if needed */ @@ -443,14 +440,19 @@ static int spl_common_init(bool setup_malloc) return 0; } -void spl_set_bd(void) +int spl_alloc_bd(void) { /* * NOTE: On some platforms (e.g. x86) bdata may be in flash and not * writeable. */ - if (!gd->bd) - gd->bd = &bdata; + if (!gd->bd) { + gd->bd = malloc(sizeof(*gd->bd)); + if (!gd->bd) + return -ENOMEM; + } + + return 0; } int spl_early_init(void) @@ -600,8 +602,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2) debug(">>" SPL_TPL_PROMPT "board_init_r()\n"); - spl_set_bd(); - #if defined(CONFIG_SYS_SPL_MALLOC_START) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); @@ -611,6 +611,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2) if (spl_init()) hang(); } + if (IS_ENABLED(CONFIG_SPL_ALLOC_BD) && spl_alloc_bd()) { + puts("Cannot alloc bd\n"); + hang(); + } #if !defined(CONFIG_PPC) && !defined(CONFIG_ARCH_MX6) /* * timer_init() does not exist on PPC systems. The timer is initialized diff --git a/common/spl/spl_atf.c b/common/spl/spl_atf.c index 9bd25f6b32..e1b68dd561 100644 --- a/common/spl/spl_atf.c +++ b/common/spl/spl_atf.c @@ -18,13 +18,36 @@ #include <spl.h> #include <asm/cache.h> -static struct bl2_to_bl31_params_mem bl31_params_mem; -static struct bl31_params *bl2_to_bl31_params; - -__weak struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry, - uintptr_t bl33_entry, - uintptr_t fdt_addr) +/* Holds all the structures we need for bl31 parameter passing */ +struct bl2_to_bl31_params_mem { + struct bl31_params bl31_params; + struct atf_image_info bl31_image_info; + struct atf_image_info bl32_image_info; + struct atf_image_info bl33_image_info; + struct entry_point_info bl33_ep_info; + struct entry_point_info bl32_ep_info; + struct entry_point_info bl31_ep_info; +}; + +struct bl2_to_bl31_params_mem_v2 { + struct bl_params bl_params; + struct bl_params_node bl31_params_node; + struct bl_params_node bl32_params_node; + struct bl_params_node bl33_params_node; + struct atf_image_info bl31_image_info; + struct atf_image_info bl32_image_info; + struct atf_image_info bl33_image_info; + struct entry_point_info bl33_ep_info; + struct entry_point_info bl32_ep_info; + struct entry_point_info bl31_ep_info; +}; + +struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr) { + static struct bl2_to_bl31_params_mem bl31_params_mem; + struct bl31_params *bl2_to_bl31_params; struct entry_point_info *bl32_ep_info; struct entry_point_info *bl33_ep_info; @@ -78,6 +101,87 @@ __weak struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry, return bl2_to_bl31_params; } +__weak struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr) +{ + return bl2_plat_get_bl31_params_default(bl32_entry, bl33_entry, + fdt_addr); +} + +struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr) +{ + static struct bl2_to_bl31_params_mem_v2 bl31_params_mem; + struct bl_params *bl_params; + struct bl_params_node *bl_params_node; + + /* + * Initialise the memory for all the arguments that needs to + * be passed to BL31 + */ + memset(&bl31_params_mem, 0, sizeof(bl31_params_mem)); + + /* Assign memory for TF related information */ + bl_params = &bl31_params_mem.bl_params; + SET_PARAM_HEAD(bl_params, ATF_PARAM_BL_PARAMS, ATF_VERSION_2, 0); + bl_params->head = &bl31_params_mem.bl31_params_node; + + /* Fill BL31 related information */ + bl_params_node = &bl31_params_mem.bl31_params_node; + bl_params_node->image_id = ATF_BL31_IMAGE_ID; + bl_params_node->image_info = &bl31_params_mem.bl31_image_info; + bl_params_node->ep_info = &bl31_params_mem.bl31_ep_info; + bl_params_node->next_params_info = &bl31_params_mem.bl32_params_node; + SET_PARAM_HEAD(bl_params_node->image_info, ATF_PARAM_IMAGE_BINARY, + ATF_VERSION_2, 0); + + /* Fill BL32 related information */ + bl_params_node = &bl31_params_mem.bl32_params_node; + bl_params_node->image_id = ATF_BL32_IMAGE_ID; + bl_params_node->image_info = &bl31_params_mem.bl32_image_info; + bl_params_node->ep_info = &bl31_params_mem.bl32_ep_info; + bl_params_node->next_params_info = &bl31_params_mem.bl33_params_node; + SET_PARAM_HEAD(bl_params_node->ep_info, ATF_PARAM_EP, + ATF_VERSION_2, ATF_EP_SECURE); + + /* secure payload is optional, so set pc to 0 if absent */ + bl_params_node->ep_info->args.arg3 = fdt_addr; + bl_params_node->ep_info->pc = bl32_entry ? bl32_entry : 0; + bl_params_node->ep_info->spsr = SPSR_64(MODE_EL1, MODE_SP_ELX, + DISABLE_ALL_EXECPTIONS); + SET_PARAM_HEAD(bl_params_node->image_info, ATF_PARAM_IMAGE_BINARY, + ATF_VERSION_2, 0); + + /* Fill BL33 related information */ + bl_params_node = &bl31_params_mem.bl33_params_node; + bl_params_node->image_id = ATF_BL33_IMAGE_ID; + bl_params_node->image_info = &bl31_params_mem.bl33_image_info; + bl_params_node->ep_info = &bl31_params_mem.bl33_ep_info; + bl_params_node->next_params_info = NULL; + SET_PARAM_HEAD(bl_params_node->ep_info, ATF_PARAM_EP, + ATF_VERSION_2, ATF_EP_NON_SECURE); + + /* BL33 expects to receive the primary CPU MPID (through x0) */ + bl_params_node->ep_info->args.arg0 = 0xffff & read_mpidr(); + bl_params_node->ep_info->pc = bl33_entry; + bl_params_node->ep_info->spsr = SPSR_64(MODE_EL2, MODE_SP_ELX, + DISABLE_ALL_EXECPTIONS); + SET_PARAM_HEAD(bl_params_node->image_info, ATF_PARAM_IMAGE_BINARY, + ATF_VERSION_2, 0); + + return bl_params; +} + +__weak struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr) +{ + return bl2_plat_get_bl31_params_v2_default(bl32_entry, bl33_entry, + fdt_addr); +} + static inline void raw_write_daif(unsigned int daif) { __asm__ __volatile__("msr DAIF, %0\n\t" : : "r" (daif) : "memory"); @@ -88,16 +192,21 @@ typedef void (*atf_entry_t)(struct bl31_params *params, void *plat_params); static void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry, uintptr_t bl33_entry, uintptr_t fdt_addr) { - struct bl31_params *bl31_params; atf_entry_t atf_entry = (atf_entry_t)bl31_entry; + void *bl31_params; - bl31_params = bl2_plat_get_bl31_params(bl32_entry, bl33_entry, - fdt_addr); + if (CONFIG_IS_ENABLED(ATF_LOAD_IMAGE_V2)) + bl31_params = bl2_plat_get_bl31_params_v2(bl32_entry, + bl33_entry, + fdt_addr); + else + bl31_params = bl2_plat_get_bl31_params(bl32_entry, bl33_entry, + fdt_addr); raw_write_daif(SPSR_EXCEPTION_MASK); dcache_disable(); - atf_entry((void *)bl31_params, (void *)fdt_addr); + atf_entry(bl31_params, (void *)fdt_addr); } static int spl_fit_images_find(void *blob, int os) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 6418062b93..795e2922ce 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -495,6 +495,23 @@ static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os) } /* + * The purpose of the FIT load buffer is to provide a memory location that is + * independent of the load address of any FIT component. + */ +static void *spl_get_fit_load_buffer(size_t size) +{ + void *buf; + + buf = malloc(size); + if (!buf) { + pr_err("Could not get FIT buffer of %lu bytes\n", (ulong)size); + pr_err("\tcheck CONFIG_SYS_SPL_MALLOC_SIZE\n"); + buf = spl_get_load_buffer(0, size); + } + return buf; +} + +/* * Weak default function to allow customizing SPL fit loading for load-only * use cases by allowing to skip the parsing/processing of the FIT contents * (so that this can be done separately in a more customized fashion) @@ -508,12 +525,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, struct spl_load_info *info, ulong sector, void *fit) { int sectors; - ulong size; + ulong size, hsize; unsigned long count; struct spl_image_info image_info; int node = -1; int images, ret; - int base_offset, hsize, align_len = ARCH_DMA_MINALIGN - 1; + int base_offset; int index = 0; int firmware_node; @@ -529,24 +546,14 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, /* * So far we only have one block of data from the FIT. Read the entire - * thing, including that first block, placing it so it finishes before - * where we will load the image. - * - * Note that we will load the image such that its first byte will be - * at the load address. Since that byte may be part-way through a - * block, we may load the image up to one block before the load - * address. So take account of that here by subtracting an addition - * block length from the FIT start position. - * - * In fact the FIT has its own load address, but we assume it cannot - * be before CONFIG_SYS_TEXT_BASE. + * thing, including that first block. * * For FIT with data embedded, data is loaded as part of FIT image. * For FIT with external data, data is not loaded in this step. */ - hsize = (size + info->bl_len + align_len) & ~align_len; - fit = spl_get_load_buffer(-hsize, hsize); sectors = get_aligned_image_size(info, size, 0); + hsize = sectors * info->bl_len; + fit = spl_get_fit_load_buffer(hsize); count = info->read(info, sector, sectors, fit); debug("fit read sector %lx, sectors=%d, dst=%p, count=%lu, size=0x%lx\n", sector, sectors, fit, count, size); @@ -558,6 +565,16 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, if (spl_load_simple_fit_skip_processing()) return 0; + if (IS_ENABLED(CONFIG_SPL_FIT_SIGNATURE)) { + int conf_offset = fit_find_config_node(fit); + + printf("## Checking hash(es) for config %s ... ", + fit_get_name(fit, conf_offset, NULL)); + if (fit_config_verify(fit, conf_offset)) + return -EPERM; + puts("OK\n"); + } + /* find the node holding the images information */ images = fdt_path_offset(fit, FIT_IMAGES_PATH); if (images < 0) { diff --git a/common/usb_hub.c b/common/usb_hub.c index e578f0be28..3d856e7de7 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -958,9 +958,9 @@ UCLASS_DRIVER(usb_hub) = { .post_bind = dm_scan_fdt_dev, .post_probe = usb_hub_post_probe, .child_pre_probe = usb_child_pre_probe, - .per_child_auto_alloc_size = sizeof(struct usb_device), - .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), - .per_device_auto_alloc_size = sizeof(struct usb_hub_device), + .per_child_auto = sizeof(struct usb_device), + .per_child_plat_auto = sizeof(struct usb_dev_plat), + .per_device_auto = sizeof(struct usb_hub_device), }; static const struct usb_device_id hub_id_table[] = { diff --git a/common/usb_storage.c b/common/usb_storage.c index ff25441995..946c6b2b32 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -146,7 +146,7 @@ int usb_stor_info(void) for (blk_first_device(IF_TYPE_USB, &dev); dev; blk_next_device(&dev)) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); printf(" Device %d: ", desc->devnum); dev_print(desc); @@ -203,11 +203,11 @@ static int usb_stor_probe_device(struct usb_device *udev) debug("\n\nProbing for storage\n"); #if CONFIG_IS_ENABLED(BLK) /* - * We store the us_data in the mass storage device's platdata. It + * We store the us_data in the mass storage device's plat. It * is shared by all LUNs (block devices) attached to this mass storage * device. */ - data = dev_get_platdata(udev->dev); + data = dev_get_plat(udev->dev); if (!usb_storage_probe(udev, 0, data)) return 0; max_lun = usb_get_max_lun(data); @@ -225,7 +225,7 @@ static int usb_stor_probe_device(struct usb_device *udev) return ret; } - blkdev = dev_get_uclass_platdata(dev); + blkdev = dev_get_uclass_plat(dev); blkdev->target = 0xff; blkdev->lun = lun; @@ -431,8 +431,8 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length) return 0; } /* if our try counter reaches 0, bail out */ - debug(" %ld, data %d\n", - us->pusb_dev->status, partial); + debug(" %ld, data %d\n", + us->pusb_dev->status, partial); if (!maxtry--) return result; } @@ -1147,7 +1147,7 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr, return 0; /* Setup device */ #if CONFIG_IS_ENABLED(BLK) - block_dev = dev_get_uclass_platdata(dev); + block_dev = dev_get_uclass_plat(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); #else @@ -1231,7 +1231,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, /* Setup device */ #if CONFIG_IS_ENABLED(BLK) - block_dev = dev_get_uclass_platdata(dev); + block_dev = dev_get_uclass_plat(dev); udev = dev_get_parent_priv(dev_get_parent(dev)); debug("\nusb_read: udev %d\n", block_dev->devnum); #else @@ -1529,7 +1529,7 @@ U_BOOT_DRIVER(usb_mass_storage) = { .of_match = usb_mass_storage_ids, .probe = usb_mass_storage_probe, #if CONFIG_IS_ENABLED(BLK) - .platdata_auto_alloc_size = sizeof(struct us_data), + .plat_auto = sizeof(struct us_data), #endif }; diff --git a/configs/at91sam9260ek_dataflash_cs0_defconfig b/configs/at91sam9260ek_dataflash_cs0_defconfig index 0d9b69160a..89f5f2c959 100644 --- a/configs/at91sam9260ek_dataflash_cs0_defconfig +++ b/configs/at91sam9260ek_dataflash_cs0_defconfig @@ -43,7 +43,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9260ek_dataflash_cs1_defconfig b/configs/at91sam9260ek_dataflash_cs1_defconfig index d0542ec60e..a7d0d2811b 100644 --- a/configs/at91sam9260ek_dataflash_cs1_defconfig +++ b/configs/at91sam9260ek_dataflash_cs1_defconfig @@ -43,7 +43,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9260ek_nandflash_defconfig b/configs/at91sam9260ek_nandflash_defconfig index e68f0bd03d..a5eaba57bd 100644 --- a/configs/at91sam9260ek_nandflash_defconfig +++ b/configs/at91sam9260ek_nandflash_defconfig @@ -40,7 +40,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9261ek_dataflash_cs0_defconfig b/configs/at91sam9261ek_dataflash_cs0_defconfig index e19b97b3b1..2172c7908d 100644 --- a/configs/at91sam9261ek_dataflash_cs0_defconfig +++ b/configs/at91sam9261ek_dataflash_cs0_defconfig @@ -42,7 +42,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9261ek_dataflash_cs3_defconfig b/configs/at91sam9261ek_dataflash_cs3_defconfig index 0ea3d0d471..c1f79bc69d 100644 --- a/configs/at91sam9261ek_dataflash_cs3_defconfig +++ b/configs/at91sam9261ek_dataflash_cs3_defconfig @@ -42,7 +42,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9261ek_nandflash_defconfig b/configs/at91sam9261ek_nandflash_defconfig index 48a8f3591a..4aaae5016a 100644 --- a/configs/at91sam9261ek_nandflash_defconfig +++ b/configs/at91sam9261ek_nandflash_defconfig @@ -39,7 +39,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9263ek_dataflash_cs0_defconfig b/configs/at91sam9263ek_dataflash_cs0_defconfig index 2e0e808fe1..cee2b72c89 100644 --- a/configs/at91sam9263ek_dataflash_cs0_defconfig +++ b/configs/at91sam9263ek_dataflash_cs0_defconfig @@ -47,7 +47,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9263ek_dataflash_defconfig b/configs/at91sam9263ek_dataflash_defconfig index 2e0e808fe1..cee2b72c89 100644 --- a/configs/at91sam9263ek_dataflash_defconfig +++ b/configs/at91sam9263ek_dataflash_defconfig @@ -47,7 +47,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9263ek_nandflash_defconfig b/configs/at91sam9263ek_nandflash_defconfig index aad5e138f4..4f5a9d46e4 100644 --- a/configs/at91sam9263ek_nandflash_defconfig +++ b/configs/at91sam9263ek_nandflash_defconfig @@ -44,7 +44,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9263ek_norflash_boot_defconfig b/configs/at91sam9263ek_norflash_boot_defconfig index f1d3575a19..7ee13e3199 100644 --- a/configs/at91sam9263ek_norflash_boot_defconfig +++ b/configs/at91sam9263ek_norflash_boot_defconfig @@ -47,7 +47,6 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_CFI=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9263ek_norflash_defconfig b/configs/at91sam9263ek_norflash_defconfig index 04302f88e9..4eba692e03 100644 --- a/configs/at91sam9263ek_norflash_defconfig +++ b/configs/at91sam9263ek_norflash_defconfig @@ -47,7 +47,6 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_CFI=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g10ek_dataflash_cs0_defconfig b/configs/at91sam9g10ek_dataflash_cs0_defconfig index 2b3469b26e..65e8fab559 100644 --- a/configs/at91sam9g10ek_dataflash_cs0_defconfig +++ b/configs/at91sam9g10ek_dataflash_cs0_defconfig @@ -42,7 +42,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g10ek_dataflash_cs3_defconfig b/configs/at91sam9g10ek_dataflash_cs3_defconfig index 8f5fdd21a6..2c292d2c7f 100644 --- a/configs/at91sam9g10ek_dataflash_cs3_defconfig +++ b/configs/at91sam9g10ek_dataflash_cs3_defconfig @@ -42,7 +42,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g10ek_nandflash_defconfig b/configs/at91sam9g10ek_nandflash_defconfig index 5bc3cb3d00..2a5acd5f01 100644 --- a/configs/at91sam9g10ek_nandflash_defconfig +++ b/configs/at91sam9g10ek_nandflash_defconfig @@ -39,7 +39,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g20ek_2mmc_defconfig b/configs/at91sam9g20ek_2mmc_defconfig index 546ae19227..67dbca0b86 100644 --- a/configs/at91sam9g20ek_2mmc_defconfig +++ b/configs/at91sam9g20ek_2mmc_defconfig @@ -42,7 +42,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g20ek_2mmc_nandflash_defconfig b/configs/at91sam9g20ek_2mmc_nandflash_defconfig index bb9ff3ea9c..6bba1ab46f 100644 --- a/configs/at91sam9g20ek_2mmc_nandflash_defconfig +++ b/configs/at91sam9g20ek_2mmc_nandflash_defconfig @@ -42,7 +42,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g20ek_dataflash_cs0_defconfig b/configs/at91sam9g20ek_dataflash_cs0_defconfig index 2576f93acd..25232054b1 100644 --- a/configs/at91sam9g20ek_dataflash_cs0_defconfig +++ b/configs/at91sam9g20ek_dataflash_cs0_defconfig @@ -43,7 +43,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g20ek_dataflash_cs1_defconfig b/configs/at91sam9g20ek_dataflash_cs1_defconfig index 46d611c158..ecfbacde0b 100644 --- a/configs/at91sam9g20ek_dataflash_cs1_defconfig +++ b/configs/at91sam9g20ek_dataflash_cs1_defconfig @@ -43,7 +43,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9g20ek_nandflash_defconfig b/configs/at91sam9g20ek_nandflash_defconfig index 843e17f796..8e0db87696 100644 --- a/configs/at91sam9g20ek_nandflash_defconfig +++ b/configs/at91sam9g20ek_nandflash_defconfig @@ -40,7 +40,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9m10g45ek_mmc_defconfig b/configs/at91sam9m10g45ek_mmc_defconfig index dd77c8d6ed..2c4bbd016c 100644 --- a/configs/at91sam9m10g45ek_mmc_defconfig +++ b/configs/at91sam9m10g45ek_mmc_defconfig @@ -42,7 +42,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_ETH=y CONFIG_MACB=y diff --git a/configs/at91sam9m10g45ek_nandflash_defconfig b/configs/at91sam9m10g45ek_nandflash_defconfig index e13851d8f6..4494f8d9ed 100644 --- a/configs/at91sam9m10g45ek_nandflash_defconfig +++ b/configs/at91sam9m10g45ek_nandflash_defconfig @@ -42,7 +42,6 @@ CONFIG_AT91_GPIO=y CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_ETH=y CONFIG_MACB=y diff --git a/configs/at91sam9n12ek_mmc_defconfig b/configs/at91sam9n12ek_mmc_defconfig index fa802c3625..74a28a3029 100644 --- a/configs/at91sam9n12ek_mmc_defconfig +++ b/configs/at91sam9n12ek_mmc_defconfig @@ -41,7 +41,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/at91sam9n12ek_nandflash_defconfig b/configs/at91sam9n12ek_nandflash_defconfig index 429b14053d..42d86fd3b7 100644 --- a/configs/at91sam9n12ek_nandflash_defconfig +++ b/configs/at91sam9n12ek_nandflash_defconfig @@ -41,7 +41,6 @@ CONFIG_AT91_GPIO=y CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y CONFIG_DM_SPI_FLASH=y diff --git a/configs/at91sam9n12ek_spiflash_defconfig b/configs/at91sam9n12ek_spiflash_defconfig index 997594720b..6a340f5a01 100644 --- a/configs/at91sam9n12ek_spiflash_defconfig +++ b/configs/at91sam9n12ek_spiflash_defconfig @@ -43,7 +43,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/at91sam9rlek_dataflash_defconfig b/configs/at91sam9rlek_dataflash_defconfig index ea14df9e27..7e2b63562f 100644 --- a/configs/at91sam9rlek_dataflash_defconfig +++ b/configs/at91sam9rlek_dataflash_defconfig @@ -45,7 +45,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9rlek_mmc_defconfig b/configs/at91sam9rlek_mmc_defconfig index 5e62ff3d3f..f8fe961ddc 100644 --- a/configs/at91sam9rlek_mmc_defconfig +++ b/configs/at91sam9rlek_mmc_defconfig @@ -41,7 +41,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9rlek_nandflash_defconfig b/configs/at91sam9rlek_nandflash_defconfig index ff32bf5801..60715a0cd9 100644 --- a/configs/at91sam9rlek_nandflash_defconfig +++ b/configs/at91sam9rlek_nandflash_defconfig @@ -42,7 +42,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9x5ek_dataflash_defconfig b/configs/at91sam9x5ek_dataflash_defconfig index e9159d8ec3..b6d6a302d8 100644 --- a/configs/at91sam9x5ek_dataflash_defconfig +++ b/configs/at91sam9x5ek_dataflash_defconfig @@ -46,7 +46,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y CONFIG_DM_SPI_FLASH=y diff --git a/configs/at91sam9x5ek_mmc_defconfig b/configs/at91sam9x5ek_mmc_defconfig index 7f8fa22dc2..d48d2d7333 100644 --- a/configs/at91sam9x5ek_mmc_defconfig +++ b/configs/at91sam9x5ek_mmc_defconfig @@ -44,7 +44,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/at91sam9x5ek_nandflash_defconfig b/configs/at91sam9x5ek_nandflash_defconfig index 2f39c8235c..2b1256d184 100644 --- a/configs/at91sam9x5ek_nandflash_defconfig +++ b/configs/at91sam9x5ek_nandflash_defconfig @@ -44,7 +44,6 @@ CONFIG_AT91_GPIO=y CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y CONFIG_DM_SPI_FLASH=y diff --git a/configs/at91sam9x5ek_spiflash_defconfig b/configs/at91sam9x5ek_spiflash_defconfig index 8575a33943..eb935d6ddc 100644 --- a/configs/at91sam9x5ek_spiflash_defconfig +++ b/configs/at91sam9x5ek_spiflash_defconfig @@ -46,7 +46,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/at91sam9xeek_dataflash_cs0_defconfig b/configs/at91sam9xeek_dataflash_cs0_defconfig index c92d08f5c7..d9633051fd 100644 --- a/configs/at91sam9xeek_dataflash_cs0_defconfig +++ b/configs/at91sam9xeek_dataflash_cs0_defconfig @@ -43,7 +43,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9xeek_dataflash_cs1_defconfig b/configs/at91sam9xeek_dataflash_cs1_defconfig index 5959c623e4..fd07ebcb8d 100644 --- a/configs/at91sam9xeek_dataflash_cs1_defconfig +++ b/configs/at91sam9xeek_dataflash_cs1_defconfig @@ -43,7 +43,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/at91sam9xeek_nandflash_defconfig b/configs/at91sam9xeek_nandflash_defconfig index 1f32b824b1..a7722276ea 100644 --- a/configs/at91sam9xeek_nandflash_defconfig +++ b/configs/at91sam9xeek_nandflash_defconfig @@ -40,7 +40,6 @@ CONFIG_AT91_GPIO=y # CONFIG_MMC is not set CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig index d0c8929525..30a02e2bc3 100644 --- a/configs/nokia_rx51_defconfig +++ b/configs/nokia_rx51_defconfig @@ -4,6 +4,7 @@ CONFIG_ARCH_OMAP2PLUS=y CONFIG_SYS_TEXT_BASE=0x80008000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_NOKIA_RX51=y +# CONFIG_TI_SYSC is not set # CONFIG_FIT is not set CONFIG_BOOTDELAY=30 CONFIG_AUTOBOOT_KEYED=y diff --git a/configs/pinecube_defconfig b/configs/pinecube_defconfig new file mode 100644 index 0000000000..a8c404f6b1 --- /dev/null +++ b/configs/pinecube_defconfig @@ -0,0 +1,15 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_SPL=y +CONFIG_MACH_SUN8I_V3S=y +CONFIG_SUNXI_DRAM_DDR3_1333=y +CONFIG_DRAM_CLK=504 +CONFIG_DRAM_ODT_EN=y +CONFIG_I2C0_ENABLE=y +CONFIG_DEFAULT_DEVICE_TREE="sun8i-s3-pinecube" +CONFIG_SPL_I2C_SUPPORT=y +# CONFIG_NETDEVICES is not set +CONFIG_AXP209_POWER=y +CONFIG_AXP_DCDC2_VOLT=1250 +CONFIG_AXP_DCDC3_VOLT=3300 +CONFIG_CONS_INDEX=3 diff --git a/configs/sama5d2_ptc_ek_mmc_defconfig b/configs/sama5d2_ptc_ek_mmc_defconfig index e566f54685..0c0dcbb545 100644 --- a/configs/sama5d2_ptc_ek_mmc_defconfig +++ b/configs/sama5d2_ptc_ek_mmc_defconfig @@ -52,7 +52,6 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ATMEL=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_ATMEL_NAND_HW_PMECC=y CONFIG_PMECC_CAP=4 diff --git a/configs/sama5d2_ptc_ek_nandflash_defconfig b/configs/sama5d2_ptc_ek_nandflash_defconfig index a3316093c0..224afea367 100644 --- a/configs/sama5d2_ptc_ek_nandflash_defconfig +++ b/configs/sama5d2_ptc_ek_nandflash_defconfig @@ -52,7 +52,6 @@ CONFIG_DM_MMC=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ATMEL=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_ATMEL_NAND_HW_PMECC=y CONFIG_PMECC_CAP=4 diff --git a/configs/sama5d36ek_cmp_mmc_defconfig b/configs/sama5d36ek_cmp_mmc_defconfig index 846f96b595..22c1134658 100644 --- a/configs/sama5d36ek_cmp_mmc_defconfig +++ b/configs/sama5d36ek_cmp_mmc_defconfig @@ -45,7 +45,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/sama5d36ek_cmp_nandflash_defconfig b/configs/sama5d36ek_cmp_nandflash_defconfig index d38a0bea6d..ed78f4ed48 100644 --- a/configs/sama5d36ek_cmp_nandflash_defconfig +++ b/configs/sama5d36ek_cmp_nandflash_defconfig @@ -45,7 +45,6 @@ CONFIG_AT91_GPIO=y CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y CONFIG_DM_SPI_FLASH=y diff --git a/configs/sama5d36ek_cmp_spiflash_defconfig b/configs/sama5d36ek_cmp_spiflash_defconfig index 6a63a74162..8fc183faa2 100644 --- a/configs/sama5d36ek_cmp_spiflash_defconfig +++ b/configs/sama5d36ek_cmp_spiflash_defconfig @@ -47,7 +47,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/sama5d3_xplained_mmc_defconfig b/configs/sama5d3_xplained_mmc_defconfig index ec117ee693..c839b4fe6e 100644 --- a/configs/sama5d3_xplained_mmc_defconfig +++ b/configs/sama5d3_xplained_mmc_defconfig @@ -64,7 +64,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_ETH=y CONFIG_MACB=y diff --git a/configs/sama5d3_xplained_nandflash_defconfig b/configs/sama5d3_xplained_nandflash_defconfig index 7f9c73b464..4d8a63fbd7 100644 --- a/configs/sama5d3_xplained_nandflash_defconfig +++ b/configs/sama5d3_xplained_nandflash_defconfig @@ -63,7 +63,6 @@ CONFIG_AT91_GPIO=y CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_PMECC_CAP=4 CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y diff --git a/configs/sama5d3xek_mmc_defconfig b/configs/sama5d3xek_mmc_defconfig index 50f97e68e1..70c6e30718 100644 --- a/configs/sama5d3xek_mmc_defconfig +++ b/configs/sama5d3xek_mmc_defconfig @@ -69,7 +69,6 @@ CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/sama5d3xek_nandflash_defconfig b/configs/sama5d3xek_nandflash_defconfig index 3521a44081..fe615c3d1d 100644 --- a/configs/sama5d3xek_nandflash_defconfig +++ b/configs/sama5d3xek_nandflash_defconfig @@ -67,7 +67,6 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_PMECC_CAP=4 CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y diff --git a/configs/sama5d3xek_spiflash_defconfig b/configs/sama5d3xek_spiflash_defconfig index b8c4d3263f..5a06518c9c 100644 --- a/configs/sama5d3xek_spiflash_defconfig +++ b/configs/sama5d3xek_spiflash_defconfig @@ -70,7 +70,6 @@ CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/sama5d4_xplained_mmc_defconfig b/configs/sama5d4_xplained_mmc_defconfig index 33a1ea7165..d1cbf32bd0 100644 --- a/configs/sama5d4_xplained_mmc_defconfig +++ b/configs/sama5d4_xplained_mmc_defconfig @@ -60,7 +60,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_ATMEL_NAND_HW_PMECC=y CONFIG_PMECC_CAP=8 diff --git a/configs/sama5d4_xplained_nandflash_defconfig b/configs/sama5d4_xplained_nandflash_defconfig index a47199fbf7..f805cf1182 100644 --- a/configs/sama5d4_xplained_nandflash_defconfig +++ b/configs/sama5d4_xplained_nandflash_defconfig @@ -60,7 +60,6 @@ CONFIG_I2C_EEPROM=y CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_PMECC_CAP=8 CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y diff --git a/configs/sama5d4_xplained_spiflash_defconfig b/configs/sama5d4_xplained_spiflash_defconfig index de5f92de6f..d9ad9cc522 100644 --- a/configs/sama5d4_xplained_spiflash_defconfig +++ b/configs/sama5d4_xplained_spiflash_defconfig @@ -66,7 +66,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/sama5d4ek_mmc_defconfig b/configs/sama5d4ek_mmc_defconfig index 25d875ec2e..d91a6f6644 100644 --- a/configs/sama5d4ek_mmc_defconfig +++ b/configs/sama5d4ek_mmc_defconfig @@ -60,7 +60,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/sama5d4ek_nandflash_defconfig b/configs/sama5d4ek_nandflash_defconfig index 3ef8ed6c30..00216f0da8 100644 --- a/configs/sama5d4ek_nandflash_defconfig +++ b/configs/sama5d4ek_nandflash_defconfig @@ -60,7 +60,6 @@ CONFIG_AT91_GPIO=y CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_PMECC_CAP=8 CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER=y diff --git a/configs/sama5d4ek_spiflash_defconfig b/configs/sama5d4ek_spiflash_defconfig index cb8ed99cdd..5ebd1cc9b1 100644 --- a/configs/sama5d4ek_spiflash_defconfig +++ b/configs/sama5d4ek_spiflash_defconfig @@ -63,7 +63,6 @@ CONFIG_DM_MMC=y CONFIG_GENERIC_ATMEL_MCI=y CONFIG_MTD=y CONFIG_MTD_RAW_NAND=y -# CONFIG_SYS_NAND_USE_FLASH_BBT is not set CONFIG_NAND_ATMEL=y CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=30000000 diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig new file mode 100644 index 0000000000..af362021b9 --- /dev/null +++ b/configs/sama7g5ek_mmc1_defconfig @@ -0,0 +1,70 @@ +CONFIG_ARM=y +CONFIG_ARCH_AT91=y +CONFIG_SYS_TEXT_BASE=0x66f00000 +CONFIG_TARGET_SAMA7G5EK=y +CONFIG_SYS_MALLOC_F_LEN=0x11000 +CONFIG_NR_DRAM_BANKS=1 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DM_GPIO=y +CONFIG_DEBUG_UART_BOARD_INIT=y +CONFIG_DEBUG_UART_BASE=0xe1824200 +CONFIG_DEBUG_UART_CLOCK=200000000 +CONFIG_DEFAULT_DEVICE_TREE="sama7g5ek" +CONFIG_DEBUG_UART=y +CONFIG_ENV_VARS_UBOOT_CONFIG=y +CONFIG_FIT=y +CONFIG_SD_BOOT=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk1p2 rw rootwait" +CONFIG_MISC_INIT_R=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_IMI is not set +CONFIG_CMD_MD5SUM=y +CONFIG_CMD_MEMTEST=y +CONFIG_SYS_MEMTEST_START=0x60000000 +CONFIG_SYS_MEMTEST_END=0x70000000 +CONFIG_CMD_STRINGS=y +CONFIG_CMD_DM=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y +# CONFIG_CMD_LOADS is not set +CONFIG_CMD_MMC=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_MII=y +CONFIG_CMD_PING=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_FAT=y +CONFIG_OF_CONTROL=y +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_FAT_DEVICE_AND_PART="1:1" +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DM=y +CONFIG_CLK=y +CONFIG_CLK_CCF=y +CONFIG_CLK_AT91=y +CONFIG_AT91_UTMI=y +CONFIG_AT91_GENERIC_CLK=y +CONFIG_AT91_SAM9X60_PLL=y +CONFIG_CPU=y +CONFIG_ATMEL_PIO4=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_AT91=y +CONFIG_I2C_EEPROM=y +CONFIG_MICROCHIP_FLEXCOM=y +CONFIG_DM_MMC=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_ATMEL=y +CONFIG_PHY_MICREL=y +CONFIG_PHY_MICREL_KSZ90X1=y +CONFIG_DM_ETH=y +CONFIG_MACB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_AT91PIO4=y +CONFIG_DM_SERIAL=y +CONFIG_DEBUG_UART_ANNOUNCE=y +CONFIG_ATMEL_USART=y +CONFIG_TIMER=y +CONFIG_MCHP_PIT64B_TIMER=y +CONFIG_OF_LIBFDT_OVERLAY=y +# CONFIG_EFI_LOADER_HII is not set diff --git a/configs/sama7g5ek_mmc_defconfig b/configs/sama7g5ek_mmc_defconfig new file mode 100644 index 0000000000..bbd1a0c659 --- /dev/null +++ b/configs/sama7g5ek_mmc_defconfig @@ -0,0 +1,70 @@ +CONFIG_ARM=y +CONFIG_ARCH_AT91=y +CONFIG_SYS_TEXT_BASE=0x66f00000 +CONFIG_TARGET_SAMA7G5EK=y +CONFIG_SYS_MALLOC_F_LEN=0x11000 +CONFIG_NR_DRAM_BANKS=1 +CONFIG_ENV_SIZE=0x4000 +CONFIG_DM_GPIO=y +CONFIG_DEBUG_UART_BOARD_INIT=y +CONFIG_DEBUG_UART_BASE=0xe1824200 +CONFIG_DEBUG_UART_CLOCK=200000000 +CONFIG_DEFAULT_DEVICE_TREE="sama7g5ek" +CONFIG_DEBUG_UART=y +CONFIG_ENV_VARS_UBOOT_CONFIG=y +CONFIG_FIT=y +CONFIG_SD_BOOT=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait" +CONFIG_MISC_INIT_R=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_IMI is not set +CONFIG_CMD_MD5SUM=y +CONFIG_CMD_MEMTEST=y +CONFIG_SYS_MEMTEST_START=0x60000000 +CONFIG_SYS_MEMTEST_END=0x70000000 +CONFIG_CMD_STRINGS=y +CONFIG_CMD_DM=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y +# CONFIG_CMD_LOADS is not set +CONFIG_CMD_MMC=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_MII=y +CONFIG_CMD_PING=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_FAT=y +CONFIG_OF_CONTROL=y +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DM=y +CONFIG_CLK=y +CONFIG_CLK_CCF=y +CONFIG_CLK_AT91=y +CONFIG_AT91_UTMI=y +CONFIG_AT91_GENERIC_CLK=y +CONFIG_AT91_SAM9X60_PLL=y +CONFIG_CPU=y +CONFIG_ATMEL_PIO4=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_AT91=y +CONFIG_I2C_EEPROM=y +CONFIG_MICROCHIP_FLEXCOM=y +CONFIG_DM_MMC=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_ATMEL=y +CONFIG_PHY_MICREL=y +CONFIG_PHY_MICREL_KSZ90X1=y +CONFIG_DM_ETH=y +CONFIG_MACB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_AT91PIO4=y +CONFIG_DM_SERIAL=y +CONFIG_DEBUG_UART_ANNOUNCE=y +CONFIG_ATMEL_USART=y +CONFIG_TIMER=y +CONFIG_MCHP_PIT64B_TIMER=y +CONFIG_OF_LIBFDT_OVERLAY=y +# CONFIG_EFI_LOADER_HII is not set diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 5fbbfd7236..2066d0a292 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -7,6 +7,7 @@ CONFIG_PRE_CON_BUF_ADDR=0x100000 CONFIG_BOOTSTAGE_STASH_ADDR=0x0 CONFIG_DEFAULT_DEVICE_TREE="sandbox64" CONFIG_SANDBOX64=y +CONFIG_DEBUG_UART=y CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y @@ -231,3 +232,9 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +# +CONFIG_DFU_SF=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index f1ec701a9f..58d4ef18c3 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -274,3 +274,9 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +# +CONFIG_DFU_SF=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index edca7f1808..efd99a92f1 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -5,6 +5,7 @@ CONFIG_SYS_MEMTEST_END=0x00101000 CONFIG_ENV_SIZE=0x2000 CONFIG_BOOTSTAGE_STASH_ADDR=0x0 CONFIG_DEFAULT_DEVICE_TREE="sandbox" +CONFIG_DEBUG_UART=y CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index 479f0226e3..d193b18f47 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -11,6 +11,7 @@ CONFIG_SPL=y CONFIG_BOOTSTAGE_STASH_ADDR=0x0 CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_SANDBOX_SPL=y +CONFIG_DEBUG_UART=y CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y diff --git a/doc/api/linker_lists.rst b/doc/api/linker_lists.rst index 72f514e0ac..7063fdc831 100644 --- a/doc/api/linker_lists.rst +++ b/doc/api/linker_lists.rst @@ -96,5 +96,64 @@ defined for the whole list and each sub-list: %u_boot_list_2_drivers_2_pci_3 %u_boot_list_2_drivers_3 +Alignment issues +---------------- + +The linker script uses alphabetic sorting to group the different linker +lists together. Each group has its own struct and potentially its own +alignment. But when the linker packs the structs together it cannot ensure +that a linker list starts on the expected alignment boundary. + +For example, if the first list has a struct size of 8 and we place 3 of +them in the image, that means that the next struct will start at offset +0x18 from the start of the linker_list section. If the next struct has +a size of 16 then it will start at an 8-byte aligned offset, but not a +16-byte aligned offset. + +With sandbox on x86_64, a reference to a linker list item using +ll_entry_get() can force alignment of that particular linker_list item, +if it is in the same file as the linker_list item is declared. + +Consider this example, where struct driver is 0x80 bytes:: + + ll_entry_declare(struct driver, fred, driver) + + ... + + void *p = ll_entry_get(struct driver, fred, driver) + +If these two lines of code are in the same file, then the entry is forced +to be aligned at the 'struct driver' alignment, which is 16 bytes. If the +second line of code is in a different file, then no action is taken, since +the compiler cannot update the alignment of the linker_list item. + +In the first case, an 8-byte 'fill' region is added:: + + .u_boot_list_2_driver_2_testbus_drv + 0x0000000000270018 0x80 test/built-in.o + 0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv + .u_boot_list_2_driver_2_testfdt1_drv + 0x0000000000270098 0x80 test/built-in.o + 0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv + *fill* 0x0000000000270118 0x8 + .u_boot_list_2_driver_2_testfdt_drv + 0x0000000000270120 0x80 test/built-in.o + 0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv + .u_boot_list_2_driver_2_testprobe_drv + 0x00000000002701a0 0x80 test/built-in.o + 0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drv + +With this, the linker_list no-longer works since items after testfdt1_drv +are not at the expected address. + +Ideally we would have a way to tell gcc not to align structs in this way. +It is not clear how we could do this, and in any case it would require us +to adjust every struct used by the linker_list feature. + +The simplest fix seems to be to force each separate linker_list to start +on the largest possible boundary that can be required by the compiler. This +is the purpose of CONFIG_LINKER_LIST_ALIGN + + .. kernel-doc:: include/linker_lists.h :internal: diff --git a/doc/board/emulation/index.rst b/doc/board/emulation/index.rst index 1adefee155..a09ead1c35 100644 --- a/doc/board/emulation/index.rst +++ b/doc/board/emulation/index.rst @@ -10,3 +10,4 @@ Emulation qemu-mips qemu-riscv qemu-x86 + qemu_capsule_update diff --git a/doc/board/emulation/qemu_capsule_update.rst b/doc/board/emulation/qemu_capsule_update.rst new file mode 100644 index 0000000000..9fec75f8f1 --- /dev/null +++ b/doc/board/emulation/qemu_capsule_update.rst @@ -0,0 +1,210 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright (C) 2020, Linaro Limited + +Enabling UEFI Capsule Update feature +------------------------------------ + +Support has been added for the UEFI capsule update feature which +enables updating the U-Boot image using the UEFI firmware management +protocol (fmp). The capsules are not passed to the firmware through +the UpdateCapsule runtime service. Instead, capsule-on-disk +functionality is used for fetching the capsule from the EFI System +Partition (ESP) by placing the capsule file under the +\EFI\UpdateCapsule directory. + +Currently, support has been added on the QEMU ARM64 virt platform for +updating the U-Boot binary as a raw image when the platform is booted +in non-secure mode, i.e. with CONFIG_TFABOOT disabled. For this +configuration, the QEMU platform needs to be booted with +'secure=off'. The U-Boot binary placed on the first bank of the NOR +flash at offset 0x0. The U-Boot environment is placed on the second +NOR flash bank at offset 0x4000000. + +The capsule update feature is enabled with the following configuration +settings:: + + CONFIG_MTD=y + CONFIG_FLASH_CFI_MTD=y + CONFIG_CMD_MTDPARTS=y + CONFIG_CMD_DFU=y + CONFIG_DFU_MTD=y + CONFIG_PCI_INIT_R=y + CONFIG_EFI_CAPSULE_ON_DISK=y + CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT=y + CONFIG_EFI_CAPSULE_FIRMWARE=y + CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y + CONFIG_EFI_CAPSULE_FMP_HEADER=y + +In addition, the following config needs to be disabled(QEMU ARM specific):: + + CONFIG_TFABOOT + +The capsule file can be generated by using the GenerateCapsule.py +script in EDKII:: + + $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \ + <capsule_file_name> --fw-version <val> --lsv <val> --guid \ + e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose --update-image-index \ + <val> --verbose <u-boot.bin> + +The above is a wrapper script(GenerateCapsule) which eventually calls +the actual GenerateCapsule.py script. + +As per the UEFI specification, the capsule file needs to be placed on +the EFI System Partition, under the \EFI\UpdateCapsule directory. The +EFI System Partition can be a virtio-blk-device. + +Before initiating the firmware update, the efi variables BootNext, +BootXXXX and OsIndications need to be set. The BootXXXX variable needs +to be pointing to the EFI System Partition which contains the capsule +file. The BootNext, BootXXXX and OsIndications variables can be set +using the following commands:: + + => efidebug boot add 0 Boot0000 virtio 0:1 <capsule_file_name> + => efidebug boot next 0 + => setenv -e -nv -bs -rt -v OsIndications =0x04 + => saveenv + +Finally, the capsule update can be initiated with the following +command:: + + => efidebug capsule disk-update + +The updated U-Boot image will be booted on subsequent boot. + +Enabling Capsule Authentication +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The UEFI specification defines a way of authenticating the capsule to +be updated by verifying the capsule signature. The capsule signature +is computed and prepended to the capsule payload at the time of +capsule generation. This signature is then verified by using the +public key stored as part of the X509 certificate. This certificate is +in the form of an efi signature list (esl) file, which is embedded as +part of the platform's device tree blob using the mkeficapsule +utility. + +On the QEMU virt platforms, the device-tree is generated on the fly +based on the devices configured. This device tree is then passed on to +the various software components booting on the platform, including +U-Boot. Therefore, on the QEMU virt platform, the signatute is +embedded on an overlay. This overlay is then applied at runtime to the +base platform device-tree. Steps needed for embedding the esl file in +the overlay are highlighted below. + +The capsule authentication feature can be enabled through the +following config, in addition to the configs listed above for capsule +update:: + + CONFIG_EFI_CAPSULE_AUTHENTICATE=y + +The public and private keys used for the signing process are generated +and used by the steps highlighted below:: + + 1. Install utility commands on your host + * OPENSSL + * efitools + + 2. Create signing keys and certificate files on your host + + $ openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=CRT/ \ + -keyout CRT.key -out CRT.crt -nodes -days 365 + $ cert-to-efi-sig-list CRT.crt CRT.esl + + $ openssl x509 -in CRT.crt -out CRT.cer -outform DER + $ openssl x509 -inform DER -in CRT.cer -outform PEM -out CRT.pub.pem + + $ openssl pkcs12 -export -out CRT.pfx -inkey CRT.key -in CRT.crt + $ openssl pkcs12 -in CRT.pfx -nodes -out CRT.pem + +The capsule file can be generated by using the GenerateCapsule.py +script in EDKII:: + + $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \ + <capsule_file_name> --monotonic-count <val> --fw-version \ + <val> --lsv <val> --guid \ + e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose \ + --update-image-index <val> --signer-private-cert \ + /path/to/CRT.pem --trusted-public-cert \ + /path/to/CRT.pub.pem --other-public-cert /path/to/CRT.pub.pem \ + <u-boot.bin> + +Place the capsule generated in the above step on the EFI System +Partition under the EFI/UpdateCapsule directory + +For embedding the public key certificate, the following steps need to +be followed:: + + 1. Generate a skeleton overlay dts file, with a single fragment + node and an empty __overlay__ node + + A typical skeleton overlay file will look like this + + /dts-v1/; + /plugin/; + + / { + fragment@0 { + target-path = "/"; + __overlay__ { + }; + }; + }; + + + 2. Convert the dts to a corresponding dtb with the following + command + ./scripts/dtc/dtc -@ -I dts -O dtb -o <ov_dtb_file_name> \ + <dts_file> + + 3. Run the dtb file generated above through the mkeficapsule tool + in U-Boot + ./tools/mkeficapsule -O <pub_key.esl> -D <ov_dtb> + +Running the above command results in the creation of a 'signature' +node in the dtb, under which the public key is stored as a +'capsule-key' property. The '-O' option is to be used since the +public key certificate(esl) file is being embedded in an overlay. + +The dtb file embedded with the certificate is now to be placed on an +EFI System Partition. This would then be loaded and "merged" with the +base platform flattened device-tree(dtb) at runtime. + +Build U-Boot with the following steps(QEMU ARM64):: + + $ make qemu_arm64_defconfig + $ make menuconfig + Disable CONFIG_TFABOOT + Enable CONFIG_EFI_CAPSULE_AUTHENTICATE + Enable all configs needed for capsule update(listed above) + $ make all + +Boot the platform and perform the following steps on the U-Boot +command line:: + + 1. Enable capsule authentication by setting the following env + variable + + => setenv capsule_authentication_enabled 1 + => saveenv + + 2. Load the overlay dtb to memory and merge it with the base fdt + + => fatload virtio 0:1 <$fdtovaddr> EFI/<ov_dtb_file> + => fdt addr $fdtcontroladdr + => fdt resize <size_of_ov_dtb_file> + => fdt apply <$fdtovaddr> + + 3. Set the following environment and UEFI boot variables + + => setenv -e -nv -bs -rt -v OsIndications =0x04 + => efidebug boot add 0 Boot0000 virtio 0:1 <capsule_file_name> + => efidebug boot next 0 + => saveenv + + 4. Finally, the capsule update can be initiated with the following + command + + => efidebug capsule disk-update + +On subsequent reboot, the platform should boot the updated U-Boot binary. diff --git a/doc/device-tree-bindings/video/syncoam,seps525.txt b/doc/device-tree-bindings/video/syncoam,seps525.txt new file mode 100644 index 0000000000..e1e0db9d71 --- /dev/null +++ b/doc/device-tree-bindings/video/syncoam,seps525.txt @@ -0,0 +1,24 @@ +spi based seps525 framebuffer display driver + +Driver for seps525 display controller (in spi mode), This binding supports selection +of spi chipselect, spi max frequency, gpio to drive dc and reset pin of seps525 +controller and spi transaction bit length. + +Required properties: +- compatible: "syncoam,seps525" +- reg: Specifies the chip-select the seps525 is connected to on the spi bus +- reset-gpios: gpio connected to reset pin of seps525 controller. +- dc-gpios: gpio connected to dc pin of seps525 controller: +- buswidth: bitlength of each spi transaction + +Example: + displayspi@0 { + compatible = "syncoam,seps525"; + reg = <0>; + spi-max-frequency = <10000000>; + spi-cpol; + spi-cpha; + buswidth = <8>; + reset-gpios = <&gpio 0x1c GPIO_ACTIVE_LOW>; + dc-gpios = <&gpio 0x1b GPIO_ACTIVE_HIGH>; + }; diff --git a/doc/driver-model/debugging.rst b/doc/driver-model/debugging.rst index c59bf6763b..bbb2794340 100644 --- a/doc/driver-model/debugging.rst +++ b/doc/driver-model/debugging.rst @@ -46,7 +46,7 @@ to see errors. Common ones are: going. - -EINVAL which typically indicates that something was missing or wrong in the device tree node. Check that everything is correct and look at the - ofdata_to_platdata() method in the driver. + of_to_plat() method in the driver. If there is no error, you should check if the device is actually bound. Call dm_dump_all() just before you locate the device to make sure it exists. diff --git a/doc/driver-model/design.rst b/doc/driver-model/design.rst index 96525b6ccc..ffed7d5f79 100644 --- a/doc/driver-model/design.rst +++ b/doc/driver-model/design.rst @@ -59,7 +59,7 @@ uclass: The demo class is pretty simple, but not trivial. The intention is that it can be used for testing, so it will implement all driver model features and provide good code coverage of them. It does have multiple drivers, it -handles parameter data and platdata (data which tells the driver how +handles parameter data and plat (data which tells the driver how to operate on a particular platform) and it uses private driver data. To try it, see the example session below:: @@ -282,7 +282,7 @@ in drivers/demo/demo-simple.c: static int simple_hello(struct udevice *dev, int ch) { - const struct dm_demo_pdata *pdata = dev_get_platdata(dev); + const struct dm_demo_pdata *pdata = dev_get_plat(dev); printf("Hello from %08x: %s %d\n", map_to_sysmem(dev), pdata->colour, pdata->sides); @@ -333,11 +333,11 @@ Briefly, they are: * bind - make the driver model aware of a device (bind it to its driver) * unbind - make the driver model forget the device - * ofdata_to_platdata - convert device tree data to platdata - see later + * of_to_plat - convert device tree data to plat - see later * probe - make a device ready for use * remove - remove a device so it cannot be used until probed again -The sequence to get a device to work is bind, ofdata_to_platdata (if using +The sequence to get a device to work is bind, of_to_plat (if using device tree) and probe. @@ -396,7 +396,7 @@ The data can be interpreted by the drivers however they like - it is basically a communication scheme between the board-specific code and the generic drivers, which are intended to work on any board. -Drivers can access their data via dev->info->platdata. Here is +Drivers can access their data via dev->info->plat. Here is the declaration for the platform data, which would normally appear in the board file. @@ -410,7 +410,7 @@ in the board file. static const struct driver_info info[] = { { .name = "demo_shape_drv", - .platdata = &red_square, + .plat = &red_square, }, }; @@ -420,9 +420,9 @@ in the board file. Device Tree ----------- -While platdata is useful, a more flexible way of providing device data is +While plat is useful, a more flexible way of providing device data is by using device tree. In U-Boot you should use this where possible. Avoid -sending patches which make use of the U_BOOT_DEVICE() macro unless strictly +sending patches which make use of the U_BOOT_DRVINFO() macro unless strictly necessary. With device tree we replace the above code with the following device tree @@ -436,7 +436,7 @@ fragment: sides = <4>; }; -This means that instead of having lots of U_BOOT_DEVICE() declarations in +This means that instead of having lots of U_BOOT_DRVINFO() declarations in the board file, we put these in the device tree. This approach allows a lot more generality, since the same board file can support many types of boards (e,g. with the same SoC) just by using different device trees. An added @@ -448,24 +448,24 @@ The easiest way to make this work it to add a few members to the driver: .. code-block:: c - .platdata_auto_alloc_size = sizeof(struct dm_test_pdata), - .ofdata_to_platdata = testfdt_ofdata_to_platdata, + .plat_auto = sizeof(struct dm_test_pdata), + .of_to_plat = testfdt_of_to_plat, -The 'auto_alloc' feature allowed space for the platdata to be allocated -and zeroed before the driver's ofdata_to_platdata() method is called. The -ofdata_to_platdata() method, which the driver write supplies, should parse -the device tree node for this device and place it in dev->platdata. Thus +The 'auto' feature allowed space for the plat to be allocated +and zeroed before the driver's of_to_plat() method is called. The +of_to_plat() method, which the driver write supplies, should parse +the device tree node for this device and place it in dev->plat. Thus when the probe method is called later (to set up the device ready for use) the platform data will be present. -Note that both methods are optional. If you provide an ofdata_to_platdata +Note that both methods are optional. If you provide an of_to_plat method then it will be called first (during activation). If you provide a probe method it will be called next. See Driver Lifecycle below for more details. -If you don't want to have the platdata automatically allocated then you -can leave out platdata_auto_alloc_size. In this case you can use malloc -in your ofdata_to_platdata (or probe) method to allocate the required memory, +If you don't want to have the plat automatically allocated then you +can leave out plat_auto. In this case you can use malloc +in your of_to_plat (or probe) method to allocate the required memory, and you should free it in the remove method. The driver model tree is intended to mirror that of the device tree. The @@ -515,11 +515,23 @@ cases. While it might be tempting to automatically renumber the devices where there are gaps in the sequence, this can lead to confusion and is not the way that U-Boot works. -Each device can request a sequence number. If none is required then the -device will be automatically allocated the next available sequence number. +Where a device gets its sequence number is controlled by the DM_SEQ_ALIAS +Kconfig option, which can have a different value in U-Boot proper and SPL. +If this option is not set, aliases are ignored. -To specify the sequence number in the device tree an alias is typically -used. Make sure that the uclass has the DM_UC_FLAG_SEQ_ALIAS flag set. +Even if CONFIG_DM_SEQ_ALIAS is enabled, the uclass must still have the +DM_UC_FLAG_SEQ_ALIAS flag set, for its devices to be sequenced by aliases. + +With those options set, devices with an alias (e.g. "serial2") will get that +sequence number (e.g. 2). Other devices get the next available number after all +aliases and all existing numbers. This means that if there is just a single +alias "serial2", unaliased serial devices will be assigned 3 or more, with 0 and +1 being unused. + +If CONFIG_DM_SEQ_ALIAS or DM_UC_FLAG_SEQ_ALIAS are not set, all devices will get +sequence numbers in a simple ordering starting from 0. To find the next number +to allocate, driver model scans through to find the maximum existing number, +then uses the next one. It does not attempt to fill in gaps. .. code-block:: none @@ -546,12 +558,18 @@ More commonly you can use node references, which expand to the full path: The alias resolves to the same string in this case, but this version is easier to read. -Device sequence numbers are resolved when a device is probed. Before then -the sequence number is only a request which may or may not be honoured, -depending on what other devices have been probed. However the numbering is -entirely under the control of the board author so a conflict is generally -an error. +Device sequence numbers are resolved when a device is bound and the number does +not change for the life of the device. + +There are some situations where the uclass must allocate sequence numbers, +since a strictly increase sequence (with devicetree nodes bound first) is not +suitable. An example of this is the PCI bus. In this case, you can set the +uclass DM_UC_FLAG_NO_AUTO_SEQ flag. With this flag set, only devices with an +alias will be assigned a number by driver model. The rest is left to the uclass +to sort out, e.g. when enumerating the bus. +Note that changing the sequence number for a device (e.g. in a driver) is not +permitted. If it is felt to be necessary, ask on the mailing list. Bus Drivers ----------- @@ -587,9 +605,9 @@ Each of the devices is connected to a different address on the USB bus. The bus device wants to store this address and some other information such as the bus speed for each device. -To achieve this, the bus device can use dev->parent_platdata in each of its +To achieve this, the bus device can use dev->parent_plat in each of its three children. This can be auto-allocated if the bus driver (or bus uclass) -has a non-zero value for per_child_platdata_auto_alloc_size. If not, then +has a non-zero value for per_child_plat_auto. If not, then the bus device or uclass can allocate the space itself before the child device is probed. @@ -647,32 +665,36 @@ Bind stage U-Boot discovers devices using one of these two methods: -- Scan the U_BOOT_DEVICE() definitions. U-Boot looks up the name specified +- Scan the U_BOOT_DRVINFO() definitions. U-Boot looks up the name specified by each, to find the appropriate U_BOOT_DRIVER() definition. In this case, - there is no path by which driver_data may be provided, but the U_BOOT_DEVICE() - may provide platdata. + there is no path by which driver_data may be provided, but the U_BOOT_DRVINFO() + may provide plat. - Scan through the device tree definitions. U-Boot looks at top-level nodes in the the device tree. It looks at the compatible string in each node and uses the of_match table of the U_BOOT_DRIVER() structure to find the right driver for each node. In this case, the of_match table may provide a - driver_data value, but platdata cannot be provided until later. + driver_data value, but plat cannot be provided until later. For each device that is discovered, U-Boot then calls device_bind() to create a new device, initializes various core fields of the device object such as name, uclass & driver, initializes any optional fields of the device object that are -applicable such as of_offset, driver_data & platdata, and finally calls the +applicable such as of_offset, driver_data & plat, and finally calls the driver's bind() method if one is defined. At this point all the devices are known, and bound to their drivers. There is a 'struct udevice' allocated for all devices. However, nothing has been activated (except for the root device). Each bound device that was created -from a U_BOOT_DEVICE() declaration will hold the platdata pointer specified +from a U_BOOT_DRVINFO() declaration will hold the plat pointer specified in that declaration. For a bound device created from the device tree, -platdata will be NULL, but of_offset will be the offset of the device tree +plat will be NULL, but of_offset will be the offset of the device tree node that caused the device to be created. The uclass is set correctly for the device. +The device's sequence number is assigned, either the requested one or the next +available one (after all aliases are processed) if nothing particular is +requested. + The device's bind() method is permitted to perform simple actions, but should not scan the device tree node, not initialise hardware, nor set up structures or allocate memory. All of these tasks should be left for @@ -690,52 +712,52 @@ Most devices have data in the device tree which they can read to find out the base address of hardware registers and parameters relating to driver operation. This is called 'ofdata' (Open-Firmware data). -The device's_ofdata_to_platdata() implemnents allocation and reading of -platdata. A parent's ofdata is always read before a child. +The device's of_to_plat() implemnents allocation and reading of +plat. A parent's ofdata is always read before a child. The steps are: - 1. If priv_auto_alloc_size is non-zero, then the device-private space + 1. If priv_auto is non-zero, then the device-private space is allocated for the device and zeroed. It will be accessible as dev->priv. The driver can put anything it likes in there, but should use it for run-time information, not platform data (which should be static and known before the device is probed). - 2. If platdata_auto_alloc_size is non-zero, then the platform data space + 2. If plat_auto is non-zero, then the platform data space is allocated. This is only useful for device tree operation, since otherwise you would have to specific the platform data in the - U_BOOT_DEVICE() declaration. The space is allocated for the device and - zeroed. It will be accessible as dev->platdata. + U_BOOT_DRVINFO() declaration. The space is allocated for the device and + zeroed. It will be accessible as dev->plat. - 3. If the device's uclass specifies a non-zero per_device_auto_alloc_size, + 3. If the device's uclass specifies a non-zero per_device_auto, then this space is allocated and zeroed also. It is allocated for and stored in the device, but it is uclass data. owned by the uclass driver. It is possible for the device to access it. - 4. If the device's immediate parent specifies a per_child_auto_alloc_size + 4. If the device's immediate parent specifies a per_child_auto then this space is allocated. This is intended for use by the parent device to keep track of things related to the child. For example a USB flash stick attached to a USB host controller would likely use this space. The controller can hold information about the USB state of each of its children. - 5. If the driver provides an ofdata_to_platdata() method, then this is + 5. If the driver provides an of_to_plat() method, then this is called to convert the device tree data into platform data. This should do various calls like dev_read_u32(dev, ...) to access the node and store - the resulting information into dev->platdata. After this point, the device + the resulting information into dev->plat. After this point, the device works the same way whether it was bound using a device tree node or - U_BOOT_DEVICE() structure. In either case, the platform data is now stored - in the platdata structure. Typically you will use the - platdata_auto_alloc_size feature to specify the size of the platform data + U_BOOT_DRVINFO() structure. In either case, the platform data is now stored + in the plat structure. Typically you will use the + plat_auto feature to specify the size of the platform data structure, and U-Boot will automatically allocate and zero it for you before - entry to ofdata_to_platdata(). But if not, you can allocate it yourself in - ofdata_to_platdata(). Note that it is preferable to do all the device tree - decoding in ofdata_to_platdata() rather than in probe(). (Apart from the + entry to of_to_plat(). But if not, you can allocate it yourself in + of_to_plat(). Note that it is preferable to do all the device tree + decoding in of_to_plat() rather than in probe(). (Apart from the ugliness of mixing configuration and run-time data, one day it is possible that U-Boot will cache platform data for devices which are regularly de/activated). - 5. The device is marked 'platdata valid'. + 6. The device is marked 'plat valid'. Note that ofdata reading is always done (for a child and all its parents) before probing starts. Thus devices go through two distinct states when @@ -744,7 +766,7 @@ the device up. Having probing separate from ofdata-reading helps deal with of-platdata, where the probe() method is common to both DT/of-platdata operation, but the -ofdata_to_platdata() method is implemented differently. +of_to_plat() method is implemented differently. Another case has come up where this separate is useful. Generation of ACPI tables uses the of-platdata but does not want to probe the device. Probing @@ -755,18 +777,18 @@ even be possible to probe the device - e.g. an SD card which is not present will cause an error on probe, yet we still must tell Linux about the SD card connector in case it is used while Linux is running. -It is important that the ofdata_to_platdata() method does not actually probe +It is important that the of_to_plat() method does not actually probe the device itself. However there are cases where other devices must be probed -in the ofdata_to_platdata() method. An example is where a device requires a +in the of_to_plat() method. An example is where a device requires a GPIO for it to operate. To select a GPIO obviously requires that the GPIO device is probed. This is OK when used by common, core devices such as GPIO, clock, interrupts, reset and the like. If your device relies on its parent setting up a suitable address space, so that dev_read_addr() works correctly, then make sure that the parent device -has its setup code in ofdata_to_platdata(). If it has it in the probe method, +has its setup code in of_to_plat(). If it has it in the probe method, then you cannot call dev_read_addr() from the child device's -ofdata_to_platdata() method. Move it to probe() instead. Buses like PCI can +of_to_plat() method. Move it to probe() instead. Buses like PCI can fall afoul of this rule. Activation/probe @@ -780,28 +802,24 @@ as above and then following these steps (see device_probe()): This means (for example) that an I2C driver will require that its bus be activated. - 2. The device's sequence number is assigned, either the requested one - (assuming no conflicts) or the next available one if there is a conflict - or nothing particular is requested. - - 4. The device's probe() method is called. This should do anything that + 2. The device's probe() method is called. This should do anything that is required by the device to get it going. This could include checking that the hardware is actually present, setting up clocks for the hardware and setting up hardware registers to initial values. The code in probe() can access: - - platform data in dev->platdata (for configuration) + - platform data in dev->plat (for configuration) - private data in dev->priv (for run-time state) - uclass data in dev->uclass_priv (for things the uclass stores about this device) - Note: If you don't use priv_auto_alloc_size then you will need to + Note: If you don't use priv_auto then you will need to allocate the priv space here yourself. The same applies also to - platdata_auto_alloc_size. Remember to free them in the remove() method. + plat_auto. Remember to free them in the remove() method. - 5. The device is marked 'activated' + 3. The device is marked 'activated' - 10. The uclass's post_probe() method is called, if one exists. This may + 4. The uclass's post_probe() method is called, if one exists. This may cause the uclass to do some housekeeping to record the device as activated and 'known' by the uclass. @@ -837,27 +855,20 @@ remove it. This performs the probe steps in reverse: 4. The device memory is freed (platform data, private data, uclass data, parent data). - Note: Because the platform data for a U_BOOT_DEVICE() is defined with a + Note: Because the platform data for a U_BOOT_DRVINFO() is defined with a static pointer, it is not de-allocated during the remove() method. For a device instantiated using the device tree data, the platform data will be dynamically allocated, and thus needs to be deallocated during the remove() method, either: - - if the platdata_auto_alloc_size is non-zero, the deallocation + - if the plat_auto is non-zero, the deallocation happens automatically within the driver model core; or - - when platdata_auto_alloc_size is 0, both the allocation (in probe() - or preferably ofdata_to_platdata()) and the deallocation in remove() + - when plat_auto is 0, both the allocation (in probe() + or preferably of_to_plat()) and the deallocation in remove() are the responsibility of the driver author. - 5. The device sequence number is set to -1, meaning that it no longer - has an allocated sequence. If the device is later reactivated and that - sequence number is still free, it may well receive the name sequence - number again. But from this point, the sequence number previously used - by this device will no longer exist (think of SPI bus 2 being removed - and bus 2 is no longer available for use). - - 6. The device is marked inactive. Note that it is still bound, so the + 5. The device is marked inactive. Note that it is still bound, so the device structure itself is not freed at this point. Should the device be activated again, then the cycle starts again at step 2 above. @@ -890,14 +901,14 @@ original patches, but makes at least the following changes: the driver operations structure in the driver, rather than passing it to the driver bind function. - Rename some structures to make them more similar to Linux (struct udevice - instead of struct instance, struct platdata, etc.) + instead of struct instance, struct plat, etc.) - Change the name 'core' to 'uclass', meaning U-Boot class. It seems that this concept relates to a class of drivers (or a subsystem). We shouldn't use 'class' since it is a C++ reserved word, so U-Boot class (uclass) seems better than 'core'. - Remove 'struct driver_instance' and just use a single 'struct udevice'. This removes a level of indirection that doesn't seem necessary. -- Built in device tree support, to avoid the need for platdata +- Built in device tree support, to avoid the need for plat - Removed the concept of driver relocation, and just make it possible for the new driver (created after relocation) to access the old driver data. I feel that relocation is a very special case and will only apply to a few @@ -920,7 +931,7 @@ property can provide better control granularity on which device is bound before relocation. While with DM_FLAG_PRE_RELOC flag of the driver all devices with the same driver are bound, which requires allocation a large amount of memory. When device tree is not used, DM_FLAG_PRE_RELOC is the -only way for statically declared devices via U_BOOT_DEVICE() to be bound +only way for statically declared devices via U_BOOT_DRVINFO() to be bound prior to relocation. It is possible to limit this to specific relocation steps, by using diff --git a/doc/driver-model/ethernet.rst b/doc/driver-model/ethernet.rst index 1f5310daaa..cdbccca34d 100644 --- a/doc/driver-model/ethernet.rst +++ b/doc/driver-model/ethernet.rst @@ -25,17 +25,17 @@ the UCLASS_ETH .id field in the U-Boot driver struct: .name = "eth_ape", .id = UCLASS_ETH, .of_match = eth_ape_ids, - .ofdata_to_platdata = eth_ape_ofdata_to_platdata, + .of_to_plat = eth_ape_of_to_plat, .probe = eth_ape_probe, .ops = ð_ape_ops, - .priv_auto_alloc_size = sizeof(struct eth_ape_priv), - .platdata_auto_alloc_size = sizeof(struct eth_ape_pdata), + .priv_auto = sizeof(struct eth_ape_priv), + .plat_auto = sizeof(struct eth_ape_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; struct eth_ape_priv contains runtime per-instance data, like buffers, pointers to current descriptors, current speed settings, pointers to PHY related data -(like struct mii_dev) and so on. Declaring its size in .priv_auto_alloc_size +(like struct mii_dev) and so on. Declaring its size in .priv_auto will let the driver framework allocate it at the right time. It can be retrieved using a dev_get_priv(dev) call. @@ -43,7 +43,7 @@ struct eth_ape_pdata contains static platform data, like the MMIO base address, a hardware variant, the MAC address. ``struct eth_pdata eth_pdata`` as the first member of this struct helps to avoid duplicated code. If you don't need any more platform data beside the standard member, -just use sizeof(struct eth_pdata) for the platdata_auto_alloc_size. +just use sizeof(struct eth_pdata) for the plat_auto. PCI devices add a line pointing to supported vendor/device ID pairs: @@ -96,7 +96,7 @@ operations. You often do things here such as resetting the MAC and/or PHY, and waiting for the link to autonegotiate. You should also take the opportunity to program the device's MAC address with the enetaddr member of the generic struct eth_pdata (which would be the first member of your -own platdata struct). This allows the rest of U-Boot to dynamically change +own plat struct). This allows the rest of U-Boot to dynamically change the MAC address and have the new settings be respected. The **send** function does what you think -- transmit the specified packet diff --git a/doc/driver-model/of-plat.rst b/doc/driver-model/of-plat.rst index 58481665ce..4ef2fe699a 100644 --- a/doc/driver-model/of-plat.rst +++ b/doc/driver-model/of-plat.rst @@ -21,7 +21,7 @@ SoCs require a 16KB SPL image which must include a full MMC stack. In this case the overhead of device tree access may be too great. It is possible to create platform data manually by defining C structures -for it, and reference that data in a U_BOOT_DEVICE() declaration. This +for it, and reference that data in a U_BOOT_DRVINFO() declaration. This bypasses the use of device tree completely, effectively creating a parallel configuration mechanism. But it is an available option for SPL. @@ -79,7 +79,7 @@ SPL/TPL and should be tested with: A new tool called 'dtoc' converts a device tree file either into a set of struct declarations, one for each compatible node, and a set of -U_BOOT_DEVICE() declarations along with the actual platform data for each +U_BOOT_DRVINFO() declarations along with the actual platform data for each device. As an example, consider this MMC node: .. code-block:: none @@ -155,47 +155,41 @@ and the following device declarations: .card_detect_delay = 0xc8, }; - U_BOOT_DEVICE(dwmmc_at_ff0c0000) = { + U_BOOT_DRVINFO(dwmmc_at_ff0c0000) = { .name = "rockchip_rk3288_dw_mshc", - .platdata = &dtv_dwmmc_at_ff0c0000, - .platdata_size = sizeof(dtv_dwmmc_at_ff0c0000), + .plat = &dtv_dwmmc_at_ff0c0000, + .plat_size = sizeof(dtv_dwmmc_at_ff0c0000), .parent_idx = -1, }; - void dm_populate_phandle_data(void) { - } - The device is then instantiated at run-time and the platform data can be accessed using: .. code-block:: c struct udevice *dev; - struct dtd_rockchip_rk3288_dw_mshc *plat = dev_get_platdata(dev); + struct dtd_rockchip_rk3288_dw_mshc *plat = dev_get_plat(dev); This avoids the code overhead of converting the device tree data to -platform data in the driver. The ofdata_to_platdata() method should +platform data in the driver. The of_to_plat() method should therefore do nothing in such a driver. Note that for the platform data to be matched with a driver, the 'name' -property of the U_BOOT_DEVICE() declaration has to match a driver declared +property of the U_BOOT_DRVINFO() declaration has to match a driver declared via U_BOOT_DRIVER(). This effectively means that a U_BOOT_DRIVER() with a 'name' corresponding to the devicetree 'compatible' string (after converting it to a valid name for C) is needed, so a dedicated driver is required for each 'compatible' string. -In order to make this a bit more flexible U_BOOT_DRIVER_ALIAS macro can be +In order to make this a bit more flexible DM_DRIVER_ALIAS macro can be used to declare an alias for a driver name, typically a 'compatible' string. This macro produces no code, but it is by dtoc tool. The parent_idx is the index of the parent driver_info structure within its -linker list (instantiated by the U_BOOT_DEVICE() macro). This is used to support -dev_get_parent(). The dm_populate_phandle_data() is included to allow for -fix-ups required by dtoc. It is not currently used. The values in 'clocks' are -the index of the driver_info for the target device followed by any phandle -arguments. This is used to support device_get_by_driver_info_idx(). +linker list (instantiated by the U_BOOT_DRVINFO() macro). This is used to support +dev_get_parent(). -During the build process dtoc parses both U_BOOT_DRIVER and U_BOOT_DRIVER_ALIAS +During the build process dtoc parses both U_BOOT_DRIVER and DM_DRIVER_ALIAS to build a list of valid driver names and driver aliases. If the 'compatible' string used for a device does not not match a valid driver name, it will be checked against the list of driver aliases in order to get the right driver @@ -222,7 +216,7 @@ all the limitations metioned in caveats above. Therefore it is recommended that the of-platdata structure should be used only in the probe() method of your driver. It cannot be used in the -ofdata_to_platdata() method since this is not called when platform data is +of_to_plat() method since this is not called when platform data is already present. @@ -232,9 +226,9 @@ How to structure your driver Drivers should always support device tree as an option. The of-platdata feature is intended as a add-on to existing drivers. -Your driver should convert the platdata struct in its probe() method. The +Your driver should convert the plat struct in its probe() method. The existing device tree decoding logic should be kept in the -ofdata_to_platdata() method and wrapped with #if. +of_to_plat() method and wrapped with #if. For example: @@ -242,7 +236,7 @@ For example: #include <dt-structs.h> - struct mmc_platdata { + struct mmc_plat { #if CONFIG_IS_ENABLED(OF_PLATDATA) /* Put this first since driver model will copy the data here */ struct dtd_mmc dtplat; @@ -254,11 +248,11 @@ For example: int fifo_depth; }; - static int mmc_ofdata_to_platdata(struct udevice *dev) + static int mmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) /* Decode the device tree data */ - struct mmc_platdata *plat = dev_get_platdata(dev); + struct mmc_plat *plat = dev_get_plat(dev); const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); @@ -270,7 +264,7 @@ For example: static int mmc_probe(struct udevice *dev) { - struct mmc_platdata *plat = dev_get_platdata(dev); + struct mmc_plat *plat = dev_get_plat(dev); #if CONFIG_IS_ENABLED(OF_PLATDATA) /* Decode the of-platdata from the C structures */ @@ -291,29 +285,29 @@ For example: .name = "mmc_drv", .id = UCLASS_MMC, .of_match = mmc_ids, - .ofdata_to_platdata = mmc_ofdata_to_platdata, + .of_to_plat = mmc_of_to_plat, .probe = mmc_probe, - .priv_auto_alloc_size = sizeof(struct mmc_priv), - .platdata_auto_alloc_size = sizeof(struct mmc_platdata), + .priv_auto = sizeof(struct mmc_priv), + .plat_auto = sizeof(struct mmc_plat), }; - U_BOOT_DRIVER_ALIAS(mmc_drv, vendor_mmc) /* matches compatible string */ + DM_DRIVER_ALIAS(mmc_drv, vendor_mmc) /* matches compatible string */ -Note that struct mmc_platdata is defined in the C file, not in a header. This +Note that struct mmc_plat is defined in the C file, not in a header. This is to avoid needing to include dt-structs.h in a header file. The idea is to keep the use of each of-platdata struct to the smallest possible code area. There is just one driver C file for each struct, that can convert from the of-platdata struct to the standard one used by the driver. -In the case where SPL_OF_PLATDATA is enabled, platdata_auto_alloc_size is +In the case where SPL_OF_PLATDATA is enabled, plat_auto is still used to allocate space for the platform data. This is different from the normal behaviour and is triggered by the use of of-platdata (strictly -speaking it is a non-zero platdata_size which triggers this). +speaking it is a non-zero plat_size which triggers this). The of-platdata struct contents is copied from the C structure data to the start of the newly allocated area. In the case where device tree is used, the platform data is allocated, and starts zeroed. In this case the -ofdata_to_platdata() method should still set up the platform data (and the +of_to_plat() method should still set up the platform data (and the of-platdata struct will not be present). SPL must use either of-platdata or device tree. Drivers cannot use both at @@ -336,10 +330,12 @@ Otherwise (such as in U-Boot proper) these structs are not available. This prevents them being used inadvertently. All usage must be bracketed with #if CONFIG_IS_ENABLED(OF_PLATDATA). -The dt-platdata.c file contains the device declarations and is is built in -spl/dt-platdata.c. It additionally contains the definition of -dm_populate_phandle_data() which is responsible of filling the phandle -information by adding references to U_BOOT_DEVICE by using DM_GET_DEVICE +The dt-plat.c file contains the device declarations and is is built in +spl/dt-plat.c. + +The dm_populate_phandle_data() function that was previous needed has now been +removed, since dtoc can address the drivers directly from dt-plat.c and does +not need to fix up things at runtime. The pylibfdt Python module is used to access the devicetree. diff --git a/doc/driver-model/remoteproc-framework.rst b/doc/driver-model/remoteproc-framework.rst index f21de0a10f..566495a21c 100644 --- a/doc/driver-model/remoteproc-framework.rst +++ b/doc/driver-model/remoteproc-framework.rst @@ -125,9 +125,9 @@ a simplified definition of a device is as follows: .driver_plat_data = &mydriver_data; }; - U_BOOT_DEVICE(proc_3_demo) = { + U_BOOT_DRVINFO(proc_3_demo) = { .name = "sandbox_test_proc", - .platdata = &proc_3_test, + .plat = &proc_3_test, }; There can be additional data that may be desired depending on the diff --git a/doc/driver-model/spi-howto.rst b/doc/driver-model/spi-howto.rst index 9631a5059d..97fbf750cb 100644 --- a/doc/driver-model/spi-howto.rst +++ b/doc/driver-model/spi-howto.rst @@ -69,7 +69,7 @@ Put this code at the bottom of your existing driver file: return NULL; } - static int exynos_spi_ofdata_to_platdata(struct udevice *dev) + static int exynos_spi_of_to_plat(struct udevice *dev) { return -ENODEV; } @@ -138,7 +138,7 @@ Put this code at the bottom of your existing driver file: .id = UCLASS_SPI, .of_match = exynos_spi_ids, .ops = &exynos_spi_ops, - .ofdata_to_platdata = exynos_spi_ofdata_to_platdata, + .of_to_plat = exynos_spi_of_to_plat, .probe = exynos_spi_probe, .remove = exynos_spi_remove, }; @@ -209,7 +209,7 @@ DM tells you. The name is not quite right. So in this case we would use: .. code-block:: c - struct exynos_spi_platdata { + struct exynos_spi_plat { enum periph_id periph_id; s32 frequency; /* Default clock frequency, -1 for none */ struct exynos_spi *regs; @@ -217,7 +217,7 @@ DM tells you. The name is not quite right. So in this case we would use: }; -Write ofdata_to_platdata() [for device tree only] +Write of_to_plat() [for device tree only] ------------------------------------------------- This method will convert information in the device tree node into a C @@ -231,7 +231,7 @@ tree, but we need to tell it the size: U_BOOT_DRIVER(spi_exynos) = { ... - .platdata_auto_alloc_size = sizeof(struct exynos_spi_platdata), + .plat_auto = sizeof(struct exynos_spi_plat), Here is a sample function. It gets a pointer to the platform data and @@ -239,9 +239,9 @@ fills in the fields from device tree. .. code-block:: c - static int exynos_spi_ofdata_to_platdata(struct udevice *bus) + static int exynos_spi_of_to_plat(struct udevice *bus) { - struct exynos_spi_platdata *plat = bus->platdata; + struct exynos_spi_plat *plat = bus->plat; const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -270,20 +270,20 @@ fills in the fields from device tree. Add the platform data [non-device-tree only] -------------------------------------------- -Specify this data in a U_BOOT_DEVICE() declaration in your board file: +Specify this data in a U_BOOT_DRVINFO() declaration in your board file: .. code-block:: c - struct exynos_spi_platdata platdata_spi0 = { + struct exynos_spi_plat platdata_spi0 = { .periph_id = ... .frequency = ... .regs = ... .deactivate_delay_us = ... }; - U_BOOT_DEVICE(board_spi0) = { + U_BOOT_DRVINFO(board_spi0) = { .name = "exynos_spi", - .platdata = &platdata_spi0, + .plat = &platdata_spi0, }; You will unfortunately need to put the struct definition into a header file @@ -335,7 +335,7 @@ DM can auto-allocate this also: U_BOOT_DRIVER(spi_exynos) = { ... - .priv_auto_alloc_size = sizeof(struct exynos_spi_priv), + .priv_auto = sizeof(struct exynos_spi_priv), Note that this is created before the probe method is called, and destroyed @@ -357,7 +357,7 @@ what you can copy out to set things up. static int exynos_spi_probe(struct udevice *bus) { - struct exynos_spi_platdata *plat = dev_get_platdata(bus); + struct exynos_spi_plat *plat = dev_get_plat(bus); struct exynos_spi_priv *priv = dev_get_priv(bus); priv->regs = plat->regs; @@ -437,7 +437,7 @@ Here is an example for the speed part: static int exynos_spi_set_speed(struct udevice *bus, uint speed) { - struct exynos_spi_platdata *plat = bus->platdata; + struct exynos_spi_plat *plat = bus->plat; struct exynos_spi_priv *priv = dev_get_priv(bus); int ret; @@ -585,7 +585,7 @@ The new version looks like this: static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct exynos_spi_platdata *pdata = dev_get_platdata(bus); + struct exynos_spi_plat *pdata = dev_get_plat(bus); struct exynos_spi_priv *priv = dev_get_priv(bus); /* If it's too soon to do another transaction, wait */ @@ -621,7 +621,7 @@ needs, but this is the minimum. U_BOOT_DRIVER(exynos_spi) = { ... - .per_child_auto_alloc_size = sizeof(struct spi_slave), + .per_child_auto = sizeof(struct spi_slave), } @@ -657,8 +657,8 @@ A little note about SPI uclass features The SPI uclass keeps some information about each device 'dev' on the bus: - struct dm_spi_slave_platdata: - This is device_get_parent_platdata(dev). + struct dm_spi_slave_plat: + This is device_get_parent_plat(dev). This is where the chip select number is stored, along with the default bus speed and mode. It is automatically read from the device tree in spi_child_post_bind(). It must not diff --git a/doc/driver-model/usb-info.rst b/doc/driver-model/usb-info.rst index 1817df420f..24d1e81a6c 100644 --- a/doc/driver-model/usb-info.rst +++ b/doc/driver-model/usb-info.rst @@ -39,31 +39,31 @@ as drivers in the USB uclass. For example: .name = "ehci_tegra", .id = UCLASS_USB, .of_match = ehci_usb_ids, - .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .of_to_plat = ehci_usb_of_to_plat, .probe = tegra_ehci_usb_probe, .remove = tegra_ehci_usb_remove, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct fdt_usb), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct fdt_usb), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; Here ehci_usb_ids is used to list the controllers that the driver supports. Each has its own data value. Controllers must be in the UCLASS_USB uclass. -The ofdata_to_platdata() method allows the controller driver to grab any +The of_to_plat() method allows the controller driver to grab any necessary settings from the device tree. The ops here are ehci_usb_ops. All EHCI drivers will use these same ops in most cases, since they are all EHCI-compatible. For EHCI there are also some special operations that can be overridden when calling ehci_register(). -The driver can use priv_auto_alloc_size to set the size of its private data. +The driver can use priv_auto to set the size of its private data. This can hold run-time information needed by the driver for operation. It exists when the device is probed (not when it is bound) and is removed when the driver is removed. -Note that usb_platdata is currently only used to deal with setting up a bus +Note that usb_plat is currently only used to deal with setting up a bus in USB device mode (OTG operation). It can be omitted if that is not supported. @@ -93,14 +93,14 @@ The following primary data structures are in use: handles that). Once the device is set up, you can find the device descriptor and current configuration descriptor in this structure. -- struct usb_platdata: +- struct usb_plat: This holds platform data for a controller. So far this is only used as a work-around for controllers which can act as USB devices in OTG mode, since the gadget framework does not use driver model. -- struct usb_dev_platdata: +- struct usb_dev_plat: This holds platform data for a device. You can access it for a - device 'dev' with dev_get_parent_platdata(dev). It holds the device + device 'dev' with dev_get_parent_plat(dev). It holds the device address and speed - anything that can be determined before the device driver is actually set up. When probing the bus this structure is used to provide essential information to the device driver. diff --git a/doc/imx/clk/ccf.txt b/doc/imx/clk/ccf.txt index e40ac360e8..f47ca8832d 100644 --- a/doc/imx/clk/ccf.txt +++ b/doc/imx/clk/ccf.txt @@ -37,7 +37,7 @@ Design decisions: modify clk-uclass.c file and add there struct uc_clk_priv, which would have clock related members (like pointer to clk). As of this writing there is no such need, so to avoid extra allocations (as it can be auto allocated by - setting .per_device_auto_alloc_size = sizeof(struct uc_clk_priv)) the + setting .per_device_auto = sizeof(struct uc_clk_priv)) the uclass_priv stores the pointer to struct clk. * Non-CCF clocks do not have a pointer to a clock in clk->dev->priv. In the case diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c index d435667258..8781f32855 100644 --- a/drivers/adc/adc-uclass.c +++ b/drivers/adc/adc-uclass.c @@ -15,7 +15,7 @@ #include <linux/delay.h> #include <power/regulator.h> -#define ADC_UCLASS_PLATDATA_SIZE sizeof(struct adc_uclass_platdata) +#define ADC_UCLASS_PLATDATA_SIZE sizeof(struct adc_uclass_plat) #define CHECK_NUMBER true #define CHECK_MASK (!CHECK_NUMBER) @@ -29,7 +29,7 @@ extern void sdelay(unsigned long loops); static int check_channel(struct udevice *dev, int value, bool number_or_mask, const char *caller_function) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); unsigned mask = number_or_mask ? (1 << value) : value; /* For the real ADC hardware, some ADC channels can be inactive. @@ -48,7 +48,7 @@ static int check_channel(struct udevice *dev, int value, bool number_or_mask, static int adc_supply_enable(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); const char *supply_type; int ret = 0; @@ -70,7 +70,7 @@ static int adc_supply_enable(struct udevice *dev) int adc_data_mask(struct udevice *dev, unsigned int *data_mask) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENOSYS; @@ -81,7 +81,7 @@ int adc_data_mask(struct udevice *dev, unsigned int *data_mask) int adc_channel_mask(struct udevice *dev, unsigned int *channel_mask) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENOSYS; @@ -141,7 +141,7 @@ int adc_start_channels(struct udevice *dev, unsigned int channel_mask) int adc_channel_data(struct udevice *dev, int channel, unsigned int *data) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); const struct adc_ops *ops = dev_get_driver_ops(dev); unsigned int timeout_us = uc_pdata->data_timeout_us; int ret; @@ -168,7 +168,7 @@ int adc_channel_data(struct udevice *dev, int channel, unsigned int *data) int adc_channels_data(struct udevice *dev, unsigned int channel_mask, struct adc_channel *channels) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); unsigned int timeout_us = uc_pdata->multidata_timeout_us; const struct adc_ops *ops = dev_get_driver_ops(dev); int ret; @@ -267,9 +267,9 @@ try_manual: return _adc_channels_single_shot(dev, channel_mask, channels); } -static int adc_vdd_platdata_update(struct udevice *dev) +static int adc_vdd_plat_update(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); int ret; /* Warning! @@ -290,9 +290,9 @@ static int adc_vdd_platdata_update(struct udevice *dev) return 0; } -static int adc_vss_platdata_update(struct udevice *dev) +static int adc_vss_plat_update(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); int ret; if (!uc_pdata->vss_supply) @@ -309,11 +309,11 @@ static int adc_vss_platdata_update(struct udevice *dev) int adc_vdd_value(struct udevice *dev, int *uV) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); int ret, value_sign = uc_pdata->vdd_polarity_negative ? -1 : 1; /* Update the regulator Value. */ - ret = adc_vdd_platdata_update(dev); + ret = adc_vdd_plat_update(dev); if (ret) return ret; @@ -327,11 +327,11 @@ int adc_vdd_value(struct udevice *dev, int *uV) int adc_vss_value(struct udevice *dev, int *uV) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); int ret, value_sign = uc_pdata->vss_polarity_negative ? -1 : 1; /* Update the regulator Value. */ - ret = adc_vss_platdata_update(dev); + ret = adc_vss_plat_update(dev); if (ret) return ret; @@ -367,9 +367,9 @@ int adc_raw_to_uV(struct udevice *dev, unsigned int raw, int *uV) return 0; } -static int adc_vdd_platdata_set(struct udevice *dev) +static int adc_vdd_plat_set(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); int ret; char *prop; @@ -380,7 +380,7 @@ static int adc_vdd_platdata_set(struct udevice *dev) ret = device_get_supply_regulator(dev, "vdd-supply", &uc_pdata->vdd_supply); if (!ret) - return adc_vdd_platdata_update(dev); + return adc_vdd_plat_update(dev); if (ret != -ENOENT) return ret; @@ -392,9 +392,9 @@ static int adc_vdd_platdata_set(struct udevice *dev) return 0; } -static int adc_vss_platdata_set(struct udevice *dev) +static int adc_vss_plat_set(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); int ret; char *prop; @@ -404,7 +404,7 @@ static int adc_vss_platdata_set(struct udevice *dev) ret = device_get_supply_regulator(dev, "vss-supply", &uc_pdata->vss_supply); if (!ret) - return adc_vss_platdata_update(dev); + return adc_vss_plat_update(dev); if (ret != -ENOENT) return ret; @@ -420,13 +420,13 @@ static int adc_pre_probe(struct udevice *dev) { int ret; - /* Set ADC VDD platdata: polarity, uV, regulator (phandle). */ - ret = adc_vdd_platdata_set(dev); + /* Set ADC VDD plat: polarity, uV, regulator (phandle). */ + ret = adc_vdd_plat_set(dev); if (ret) pr_err("%s: Can't update Vdd. Error: %d", dev->name, ret); - /* Set ADC VSS platdata: polarity, uV, regulator (phandle). */ - ret = adc_vss_platdata_set(dev); + /* Set ADC VSS plat: polarity, uV, regulator (phandle). */ + ret = adc_vss_plat_set(dev); if (ret) pr_err("%s: Can't update Vss. Error: %d", dev->name, ret); @@ -437,5 +437,5 @@ UCLASS_DRIVER(adc) = { .id = UCLASS_ADC, .name = "adc", .pre_probe = adc_pre_probe, - .per_device_platdata_auto_alloc_size = ADC_UCLASS_PLATDATA_SIZE, + .per_device_plat_auto = ADC_UCLASS_PLATDATA_SIZE, }; diff --git a/drivers/adc/exynos-adc.c b/drivers/adc/exynos-adc.c index b459b57050..6589817085 100644 --- a/drivers/adc/exynos-adc.c +++ b/drivers/adc/exynos-adc.c @@ -101,9 +101,9 @@ int exynos_adc_probe(struct udevice *dev) return 0; } -int exynos_adc_ofdata_to_platdata(struct udevice *dev) +int exynos_adc_of_to_plat(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); struct exynos_adc_priv *priv = dev_get_priv(dev); priv->regs = dev_read_addr_ptr(dev); @@ -139,6 +139,6 @@ U_BOOT_DRIVER(exynos_adc) = { .of_match = exynos_adc_ids, .ops = &exynos_adc_ops, .probe = exynos_adc_probe, - .ofdata_to_platdata = exynos_adc_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct exynos_adc_priv), + .of_to_plat = exynos_adc_of_to_plat, + .priv_auto = sizeof(struct exynos_adc_priv), }; diff --git a/drivers/adc/meson-saradc.c b/drivers/adc/meson-saradc.c index e7a8ff3932..21db55831d 100644 --- a/drivers/adc/meson-saradc.c +++ b/drivers/adc/meson-saradc.c @@ -678,9 +678,9 @@ static int meson_saradc_probe(struct udevice *dev) return 0; } -int meson_saradc_ofdata_to_platdata(struct udevice *dev) +int meson_saradc_of_to_plat(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); struct meson_saradc_priv *priv = dev_get_priv(dev); priv->data = (struct meson_saradc_data *)dev_get_driver_data(dev); @@ -725,6 +725,6 @@ U_BOOT_DRIVER(meson_saradc) = { .of_match = meson_saradc_ids, .ops = &meson_saradc_ops, .probe = meson_saradc_probe, - .ofdata_to_platdata = meson_saradc_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct meson_saradc_priv), + .of_to_plat = meson_saradc_of_to_plat, + .priv_auto = sizeof(struct meson_saradc_priv), }; diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c index 561740f63b..e464d33f22 100644 --- a/drivers/adc/rockchip-saradc.c +++ b/drivers/adc/rockchip-saradc.c @@ -44,7 +44,7 @@ int rockchip_saradc_channel_data(struct udevice *dev, int channel, unsigned int *data) { struct rockchip_saradc_priv *priv = dev_get_priv(dev); - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); if (channel != priv->active_channel) { pr_err("Requested channel is not active!"); @@ -117,9 +117,9 @@ int rockchip_saradc_probe(struct udevice *dev) return 0; } -int rockchip_saradc_ofdata_to_platdata(struct udevice *dev) +int rockchip_saradc_of_to_plat(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); struct rockchip_saradc_priv *priv = dev_get_priv(dev); struct rockchip_saradc_data *data; @@ -179,6 +179,6 @@ U_BOOT_DRIVER(rockchip_saradc) = { .of_match = rockchip_saradc_ids, .ops = &rockchip_saradc_ops, .probe = rockchip_saradc_probe, - .ofdata_to_platdata = rockchip_saradc_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct rockchip_saradc_priv), + .of_to_plat = rockchip_saradc_of_to_plat, + .priv_auto = sizeof(struct rockchip_saradc_priv), }; diff --git a/drivers/adc/sandbox.c b/drivers/adc/sandbox.c index 1f32289f60..6e435462ab 100644 --- a/drivers/adc/sandbox.c +++ b/drivers/adc/sandbox.c @@ -135,9 +135,9 @@ int sandbox_adc_probe(struct udevice *dev) return 0; } -int sandbox_adc_ofdata_to_platdata(struct udevice *dev) +int sandbox_adc_of_to_plat(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); uc_pdata->data_mask = SANDBOX_ADC_DATA_MASK; uc_pdata->data_format = ADC_DATA_FORMAT_BIN; @@ -168,6 +168,6 @@ U_BOOT_DRIVER(sandbox_adc) = { .of_match = sandbox_adc_ids, .ops = &sandbox_adc_ops, .probe = sandbox_adc_probe, - .ofdata_to_platdata = sandbox_adc_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct sandbox_adc_priv), + .of_to_plat = sandbox_adc_of_to_plat, + .priv_auto = sizeof(struct sandbox_adc_priv), }; diff --git a/drivers/adc/stm32-adc-core.c b/drivers/adc/stm32-adc-core.c index f20c46fb36..6c176961f1 100644 --- a/drivers/adc/stm32-adc-core.c +++ b/drivers/adc/stm32-adc-core.c @@ -209,5 +209,5 @@ U_BOOT_DRIVER(stm32_adc_core) = { .id = UCLASS_SIMPLE_BUS, .of_match = stm32_adc_core_ids, .probe = stm32_adc_core_probe, - .priv_auto_alloc_size = sizeof(struct stm32_adc_common), + .priv_auto = sizeof(struct stm32_adc_common), }; diff --git a/drivers/adc/stm32-adc.c b/drivers/adc/stm32-adc.c index 3f0ed48846..ad8d1a32cd 100644 --- a/drivers/adc/stm32-adc.c +++ b/drivers/adc/stm32-adc.c @@ -80,7 +80,7 @@ static int stm32_adc_stop(struct udevice *dev) static int stm32_adc_start_channel(struct udevice *dev, int channel) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); struct stm32_adc_common *common = dev_get_priv(dev_get_parent(dev)); struct stm32_adc *adc = dev_get_priv(dev); int ret; @@ -164,7 +164,7 @@ static int stm32_adc_channel_data(struct udevice *dev, int channel, static int stm32_adc_chan_of_init(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); struct stm32_adc *adc = dev_get_priv(dev); u32 chans[STM32_ADC_CH_MAX]; unsigned int i, num_channels; @@ -206,7 +206,7 @@ static int stm32_adc_chan_of_init(struct udevice *dev) static int stm32_adc_probe(struct udevice *dev) { - struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); + struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); struct stm32_adc_common *common = dev_get_priv(dev_get_parent(dev)); struct stm32_adc *adc = dev_get_priv(dev); int offset; @@ -258,5 +258,5 @@ U_BOOT_DRIVER(stm32_adc) = { .of_match = stm32_adc_ids, .probe = stm32_adc_probe, .ops = &stm32_adc_ops, - .priv_auto_alloc_size = sizeof(struct stm32_adc), + .priv_auto = sizeof(struct stm32_adc), }; diff --git a/drivers/ata/ahci-uclass.c b/drivers/ata/ahci-uclass.c index 42bbff962b..c4c7a03fe7 100644 --- a/drivers/ata/ahci-uclass.c +++ b/drivers/ata/ahci-uclass.c @@ -11,5 +11,5 @@ UCLASS_DRIVER(ahci) = { .id = UCLASS_AHCI, .name = "ahci", - .per_device_auto_alloc_size = sizeof(struct ahci_uc_priv), + .per_device_auto = sizeof(struct ahci_uc_priv), }; diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 22bc0d3b10..2ef21ec508 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -172,7 +172,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv) #if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI) # ifdef CONFIG_DM_PCI struct udevice *dev = uc_priv->dev; - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); # else pci_dev_t pdev = uc_priv->dev; unsigned short vendor; @@ -474,7 +474,7 @@ static int ahci_init_one(struct ahci_uc_priv *uc_priv, pci_dev_t dev) pci_write_config_byte(dev, 0x41, 0xa1); #endif #else - struct scsi_platdata *plat = dev_get_uclass_platdata(dev); + struct scsi_plat *plat = dev_get_uclass_plat(dev); uc_priv->mmio_base = (void *)plat->base; #endif @@ -1163,14 +1163,14 @@ int ahci_bind_scsi(struct udevice *ahci_dev, struct udevice **devp) int ahci_probe_scsi(struct udevice *ahci_dev, ulong base) { struct ahci_uc_priv *uc_priv; - struct scsi_platdata *uc_plat; + struct scsi_plat *uc_plat; struct udevice *dev; int ret; device_find_first_child(ahci_dev, &dev); if (!dev) return -ENODEV; - uc_plat = dev_get_uclass_platdata(dev); + uc_plat = dev_get_uclass_plat(dev); uc_plat->base = base; uc_plat->max_lun = 1; uc_plat->max_id = 2; diff --git a/drivers/ata/dwc_ahci.c b/drivers/ata/dwc_ahci.c index ed0527c976..826fea71cc 100644 --- a/drivers/ata/dwc_ahci.c +++ b/drivers/ata/dwc_ahci.c @@ -29,7 +29,7 @@ static int dwc_ahci_bind(struct udevice *dev) return ahci_bind_scsi(dev, &scsi_dev); } -static int dwc_ahci_ofdata_to_platdata(struct udevice *dev) +static int dwc_ahci_of_to_plat(struct udevice *dev) { struct dwc_ahci_priv *priv = dev_get_priv(dev); fdt_addr_t addr; @@ -92,8 +92,8 @@ U_BOOT_DRIVER(dwc_ahci) = { .id = UCLASS_AHCI, .of_match = dwc_ahci_ids, .bind = dwc_ahci_bind, - .ofdata_to_platdata = dwc_ahci_ofdata_to_platdata, + .of_to_plat = dwc_ahci_of_to_plat, .ops = &scsi_ops, .probe = dwc_ahci_probe, - .priv_auto_alloc_size = sizeof(struct dwc_ahci_priv), + .priv_auto = sizeof(struct dwc_ahci_priv), }; diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c index 562e982e32..6d42548087 100644 --- a/drivers/ata/dwc_ahsata.c +++ b/drivers/ata/dwc_ahsata.c @@ -1019,7 +1019,7 @@ int dwc_ahsata_scan(struct udevice *dev) } } - desc = dev_get_uclass_platdata(blk); + desc = dev_get_uclass_plat(blk); ret = dwc_ahsata_scan_common(uc_priv, desc); if (ret) { debug("%s: Failed to scan bus\n", __func__); @@ -1054,7 +1054,7 @@ int dwc_ahsata_probe(struct udevice *dev) static ulong dwc_ahsata_read(struct udevice *blk, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct blk_desc *desc = dev_get_uclass_platdata(blk); + struct blk_desc *desc = dev_get_uclass_plat(blk); struct udevice *dev = dev_get_parent(blk); struct ahci_uc_priv *uc_priv; @@ -1065,7 +1065,7 @@ static ulong dwc_ahsata_read(struct udevice *blk, lbaint_t blknr, static ulong dwc_ahsata_write(struct udevice *blk, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct blk_desc *desc = dev_get_uclass_platdata(blk); + struct blk_desc *desc = dev_get_uclass_plat(blk); struct udevice *dev = dev_get_parent(blk); struct ahci_uc_priv *uc_priv; diff --git a/drivers/ata/fsl_sata.c b/drivers/ata/fsl_sata.c index 8c6726a621..e44db0a374 100644 --- a/drivers/ata/fsl_sata.c +++ b/drivers/ata/fsl_sata.c @@ -746,7 +746,7 @@ ulong sata_read(int dev, ulong blknr, lbaint_t blkcnt, void *buffer) static ulong sata_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct fsl_ata_priv *priv = dev_get_platdata(dev); + struct fsl_ata_priv *priv = dev_get_plat(dev); fsl_sata_t *sata = priv->fsl_sata; #endif u32 rc; @@ -768,7 +768,7 @@ ulong sata_write(int dev, ulong blknr, lbaint_t blkcnt, const void *buffer) static ulong sata_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct fsl_ata_priv *priv = dev_get_platdata(dev); + struct fsl_ata_priv *priv = dev_get_plat(dev); fsl_sata_t *sata = priv->fsl_sata; #endif u32 rc; @@ -808,8 +808,8 @@ int scan_sata(int dev) #else static int scan_sata(struct udevice *dev) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); - struct fsl_ata_priv *priv = dev_get_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); + struct fsl_ata_priv *priv = dev_get_plat(dev); fsl_sata_t *sata = priv->fsl_sata; #endif @@ -900,10 +900,10 @@ U_BOOT_DRIVER(sata_fsl_driver) = { .name = "sata_fsl_blk", .id = UCLASS_BLK, .ops = &sata_fsl_blk_ops, - .platdata_auto_alloc_size = sizeof(struct fsl_ata_priv), + .plat_auto = sizeof(struct fsl_ata_priv), }; -static int fsl_ata_ofdata_to_platdata(struct udevice *dev) +static int fsl_ata_of_to_plat(struct udevice *dev) { struct fsl_ata_priv *priv = dev_get_priv(dev); @@ -969,7 +969,7 @@ static int fsl_ata_probe(struct udevice *dev) continue; } - blk_priv = dev_get_platdata(blk); + blk_priv = dev_get_plat(blk); blk_priv->fsl_sata = priv->fsl_sata; /* Scan SATA port */ ret = scan_sata(blk); @@ -1026,9 +1026,9 @@ U_BOOT_DRIVER(fsl_ahci) = { .id = UCLASS_AHCI, .of_match = fsl_ata_ids, .ops = &sata_fsl_ahci_ops, - .ofdata_to_platdata = fsl_ata_ofdata_to_platdata, + .of_to_plat = fsl_ata_of_to_plat, .probe = fsl_ata_probe, .remove = fsl_ata_remove, - .priv_auto_alloc_size = sizeof(struct fsl_ata_priv), + .priv_auto = sizeof(struct fsl_ata_priv), }; #endif diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c index 4ad260a5bb..46b7677783 100644 --- a/drivers/ata/mtk_ahci.c +++ b/drivers/ata/mtk_ahci.c @@ -40,7 +40,7 @@ static int mtk_ahci_bind(struct udevice *dev) return ahci_bind_scsi(dev, &scsi_dev); } -static int mtk_ahci_ofdata_to_platdata(struct udevice *dev) +static int mtk_ahci_of_to_plat(struct udevice *dev) { struct mtk_ahci_priv *priv = dev_get_priv(dev); @@ -68,7 +68,8 @@ static int mtk_ahci_parse_property(struct ahci_uc_priv *hpriv, SYS_CFG_SATA_MSK, SYS_CFG_SATA_EN); } - ofnode_read_u32(dev->node, "ports-implemented", &hpriv->port_map); + ofnode_read_u32(dev_ofnode(dev), "ports-implemented", + &hpriv->port_map); return 0; } @@ -121,8 +122,8 @@ U_BOOT_DRIVER(mtk_ahci) = { .id = UCLASS_AHCI, .of_match = mtk_ahci_ids, .bind = mtk_ahci_bind, - .ofdata_to_platdata = mtk_ahci_ofdata_to_platdata, + .of_to_plat = mtk_ahci_of_to_plat, .ops = &scsi_ops, .probe = mtk_ahci_probe, - .priv_auto_alloc_size = sizeof(struct mtk_ahci_priv), + .priv_auto = sizeof(struct mtk_ahci_priv), }; diff --git a/drivers/ata/sata_ceva.c b/drivers/ata/sata_ceva.c index 77508aa5bc..87e6a90f74 100644 --- a/drivers/ata/sata_ceva.c +++ b/drivers/ata/sata_ceva.c @@ -199,7 +199,7 @@ static const struct udevice_id sata_ceva_ids[] = { { } }; -static int sata_ceva_ofdata_to_platdata(struct udevice *dev) +static int sata_ceva_of_to_plat(struct udevice *dev) { struct ceva_sata_priv *priv = dev_get_priv(dev); struct resource res_regs; @@ -233,7 +233,7 @@ U_BOOT_DRIVER(ceva_host_blk) = { .of_match = sata_ceva_ids, .bind = sata_ceva_bind, .ops = &scsi_ops, - .priv_auto_alloc_size = sizeof(struct ceva_sata_priv), + .priv_auto = sizeof(struct ceva_sata_priv), .probe = sata_ceva_probe, - .ofdata_to_platdata = sata_ceva_ofdata_to_platdata, + .of_to_plat = sata_ceva_of_to_plat, }; diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index b2b5c699ad..b78e311fc3 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -290,7 +290,7 @@ static int ata_wait_register(u32 *addr, u32 mask, u32 val, u32 timeout_msec) /* Cut from sata_mv in linux kernel */ static int mv_stop_edma_engine(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); int i; /* Disable eDMA. The disable bit auto clears. */ @@ -311,7 +311,7 @@ static int mv_stop_edma_engine(struct udevice *dev, int port) static int mv_start_edma_engine(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); u32 tmp; /* Check preconditions */ @@ -363,7 +363,7 @@ static int mv_start_edma_engine(struct udevice *dev, int port) static int mv_reset_channel(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); /* Make sure edma is stopped */ mv_stop_edma_engine(dev, port); @@ -378,7 +378,7 @@ static int mv_reset_channel(struct udevice *dev, int port) static void mv_reset_port(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); mv_reset_channel(dev, port); @@ -404,7 +404,7 @@ static void mv_reset_one_hc(void) static int probe_port(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); int tries, tries2, set15 = 0; u32 tmp; @@ -467,7 +467,7 @@ static int probe_port(struct udevice *dev, int port) /* Get request queue in pointer */ static int get_reqip(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); u32 tmp; tmp = in_le32(priv->regbase + EDMA_RQIPR) & EDMA_RQIPR_IPMASK; @@ -478,7 +478,7 @@ static int get_reqip(struct udevice *dev, int port) static void set_reqip(struct udevice *dev, int port, int reqin) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); u32 tmp; tmp = in_le32(priv->regbase + EDMA_RQIPR) & ~EDMA_RQIPR_IPMASK; @@ -497,7 +497,7 @@ static int get_next_reqip(struct udevice *dev, int port) /* Get response queue in pointer */ static int get_rspip(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); u32 tmp; tmp = in_le32(priv->regbase + EDMA_RSIPR) & EDMA_RSIPR_IPMASK; @@ -509,7 +509,7 @@ static int get_rspip(struct udevice *dev, int port) /* Get response queue out pointer */ static int get_rspop(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); u32 tmp; tmp = in_le32(priv->regbase + EDMA_RSOPR) & EDMA_RSOPR_OPMASK; @@ -526,7 +526,7 @@ static int get_next_rspop(struct udevice *dev, int port) /* Set response queue pointer */ static void set_rspop(struct udevice *dev, int port, int reqin) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); u32 tmp; tmp = in_le32(priv->regbase + EDMA_RSOPR) & ~EDMA_RSOPR_OPMASK; @@ -552,7 +552,7 @@ static int wait_dma_completion(struct udevice *dev, int port, int index, static void process_responses(struct udevice *dev, int port) { #ifdef DEBUG - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); #endif u32 tmp; u32 outind = get_rspop(dev, port); @@ -580,7 +580,7 @@ static int mv_ata_exec_ata_cmd(struct udevice *dev, int port, struct sata_fis_h2d *cfis, u8 *buffer, u32 len, u32 iswrite) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); struct crqb *req; int slot; u32 start; @@ -727,7 +727,7 @@ static u32 mv_sata_rw_cmd(struct udevice *dev, int port, lbaint_t start, static u32 ata_low_level_rw(struct udevice *dev, int port, lbaint_t blknr, lbaint_t blkcnt, void *buffer, int is_write) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); lbaint_t start, blks; u8 *addr; int max_blks; @@ -772,7 +772,7 @@ static int mv_ata_exec_ata_cmd_nondma(struct udevice *dev, int port, struct sata_fis_h2d *cfis, u8 *buffer, u32 len, u32 iswrite) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); int i; u16 *tp; @@ -823,7 +823,7 @@ static int mv_sata_identify(struct udevice *dev, int port, u16 *id) static void mv_sata_xfer_mode(struct udevice *dev, int port, u16 *id) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); priv->pio = id[ATA_ID_PIO_MODES]; priv->mwdma = id[ATA_ID_MWDMA_MODES]; @@ -834,7 +834,7 @@ static void mv_sata_xfer_mode(struct udevice *dev, int port, u16 *id) static void mv_sata_set_features(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); struct sata_fis_h2d cfis; u8 udma_cap; @@ -886,7 +886,7 @@ static void mvsata_ide_conf_mbus_windows(void) static int sata_mv_init_sata(struct udevice *dev, int port) { - struct mv_priv *priv = dev_get_platdata(dev); + struct mv_priv *priv = dev_get_plat(dev); debug("Initialize sata dev: %d\n", port); @@ -943,8 +943,8 @@ static int sata_mv_init_sata(struct udevice *dev, int port) static int sata_mv_scan_sata(struct udevice *dev, int port) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); - struct mv_priv *priv = dev_get_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); + struct mv_priv *priv = dev_get_plat(dev); unsigned char serial[ATA_ID_SERNO_LEN + 1]; unsigned char firmware[ATA_ID_FW_REV_LEN + 1]; unsigned char product[ATA_ID_PROD_LEN + 1]; @@ -1006,7 +1006,7 @@ static int sata_mv_scan_sata(struct udevice *dev, int port) static ulong sata_mv_read(struct udevice *blk, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct mv_priv *priv = dev_get_platdata(blk); + struct mv_priv *priv = dev_get_plat(blk); return ata_low_level_rw(blk, priv->dev_nr, blknr, blkcnt, buffer, READ_CMD); @@ -1015,7 +1015,7 @@ static ulong sata_mv_read(struct udevice *blk, lbaint_t blknr, static ulong sata_mv_write(struct udevice *blk, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct mv_priv *priv = dev_get_platdata(blk); + struct mv_priv *priv = dev_get_plat(blk); return ata_low_level_rw(blk, priv->dev_nr, blknr, blkcnt, (void *)buffer, WRITE_CMD); @@ -1030,7 +1030,7 @@ U_BOOT_DRIVER(sata_mv_driver) = { .name = "sata_mv_blk", .id = UCLASS_BLK, .ops = &sata_mv_blk_ops, - .platdata_auto_alloc_size = sizeof(struct mv_priv), + .plat_auto = sizeof(struct mv_priv), }; static int sata_mv_probe(struct udevice *dev) @@ -1055,7 +1055,7 @@ static int sata_mv_probe(struct udevice *dev) return ret; } - priv = dev_get_platdata(blk); + priv = dev_get_plat(blk); priv->dev_nr = i; /* Init SATA port */ diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index d5ba94c172..7e4e97d803 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c @@ -492,7 +492,7 @@ ulong sata_read(int dev, ulong blknr, lbaint_t blkcnt, void *buffer) static ulong sata_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct sil_sata_priv *priv = dev_get_platdata(dev); + struct sil_sata_priv *priv = dev_get_plat(dev); int port_number = priv->port_num; struct sil_sata *sata = priv->sil_sata_desc[port_number]; #endif @@ -517,7 +517,7 @@ ulong sata_write(int dev, ulong blknr, lbaint_t blkcnt, const void *buffer) ulong sata_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct sil_sata_priv *priv = dev_get_platdata(dev); + struct sil_sata_priv *priv = dev_get_plat(dev); int port_number = priv->port_num; struct sil_sata *sata = priv->sil_sata_desc[port_number]; #endif @@ -542,7 +542,7 @@ static int sil_init_sata(int dev) #else static int sil_init_sata(struct udevice *uc_dev, int dev) { - struct sil_sata_priv *priv = dev_get_platdata(uc_dev); + struct sil_sata_priv *priv = dev_get_plat(uc_dev); #endif struct sil_sata *sata; void *port; @@ -708,8 +708,8 @@ int scan_sata(int dev) #else static int scan_sata(struct udevice *blk_dev, int dev) { - struct blk_desc *desc = dev_get_uclass_platdata(blk_dev); - struct sil_sata_priv *priv = dev_get_platdata(blk_dev); + struct blk_desc *desc = dev_get_uclass_plat(blk_dev); + struct sil_sata_priv *priv = dev_get_plat(blk_dev); struct sil_sata *sata = priv->sil_sata_desc[dev]; #endif unsigned char serial[ATA_ID_SERNO_LEN + 1]; @@ -772,7 +772,7 @@ U_BOOT_DRIVER(sata_sil_driver) = { .name = "sata_sil_blk", .id = UCLASS_BLK, .ops = &sata_sil_blk_ops, - .platdata_auto_alloc_size = sizeof(struct sil_sata_priv), + .plat_auto = sizeof(struct sil_sata_priv), }; static int sil_unbind_device(struct udevice *dev) @@ -920,7 +920,7 @@ U_BOOT_DRIVER(sil_ahci_pci) = { .ops = &sata_sil_ops, .probe = sil_pci_probe, .remove = sil_pci_remove, - .priv_auto_alloc_size = sizeof(struct sil_sata_priv), + .priv_auto = sizeof(struct sil_sata_priv), }; U_BOOT_PCI_DEVICE(sil_ahci_pci, supported); diff --git a/drivers/axi/ihs_axi.c b/drivers/axi/ihs_axi.c index 3945511090..a7e9761fbf 100644 --- a/drivers/axi/ihs_axi.c +++ b/drivers/axi/ihs_axi.c @@ -291,6 +291,6 @@ U_BOOT_DRIVER(ihs_axi_bus) = { .id = UCLASS_AXI, .of_match = ihs_axi_ids, .ops = &ihs_axi_ops, - .priv_auto_alloc_size = sizeof(struct ihs_axi_priv), + .priv_auto = sizeof(struct ihs_axi_priv), .probe = ihs_axi_probe, }; diff --git a/drivers/axi/sandbox_store.c b/drivers/axi/sandbox_store.c index 42bcae6af2..ef349a50b7 100644 --- a/drivers/axi/sandbox_store.c +++ b/drivers/axi/sandbox_store.c @@ -119,7 +119,7 @@ U_BOOT_DRIVER(sandbox_axi_store) = { .id = UCLASS_AXI_EMUL, .of_match = sandbox_store_ids, .ops = &sandbox_store_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_store_priv), + .priv_auto = sizeof(struct sandbox_store_priv), .probe = sandbox_store_probe, .remove = sandbox_store_remove, }; diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 2fb9f6b765..d0d91db540 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -79,7 +79,7 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum) ret = blk_get_device(if_type, devnum, &dev); if (ret) return NULL; - desc = dev_get_uclass_platdata(dev); + desc = dev_get_uclass_plat(dev); return desc; } @@ -114,7 +114,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum) if (ret) return NULL; uclass_foreach_dev(dev, uc) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__, if_type, devnum, dev->name, desc->if_type, desc->devnum); @@ -154,7 +154,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev) if (device_get_uclass_id(child_dev) != UCLASS_BLK) continue; - return dev_get_uclass_platdata(child_dev); + return dev_get_uclass_plat(child_dev); } debug("%s: No block device found\n", __func__); @@ -184,7 +184,7 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp) if (ret) return ret; uclass_foreach_dev(dev, uc) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__, if_type, devnum, dev->name, desc->if_type, desc->devnum); @@ -368,7 +368,7 @@ int blk_first_device(int if_type, struct udevice **devp) if (!*devp) return -ENODEV; do { - desc = dev_get_uclass_platdata(*devp); + desc = dev_get_uclass_plat(*devp); if (desc->if_type == if_type) return 0; ret = uclass_find_next_device(devp); @@ -384,7 +384,7 @@ int blk_next_device(struct udevice **devp) struct blk_desc *desc; int ret, if_type; - desc = dev_get_uclass_platdata(*devp); + desc = dev_get_uclass_plat(*devp); if_type = desc->if_type; do { ret = uclass_find_next_device(devp); @@ -392,7 +392,7 @@ int blk_next_device(struct udevice **devp) return ret; if (!*devp) return -ENODEV; - desc = dev_get_uclass_platdata(*devp); + desc = dev_get_uclass_plat(*devp); if (desc->if_type == if_type) return 0; } while (1); @@ -408,7 +408,7 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp) if (ret) return ret; uclass_foreach_dev(dev, uc) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__, if_type, devnum, dev->name, desc->if_type, desc->devnum); @@ -516,7 +516,7 @@ int blk_find_max_devnum(enum if_type if_type) if (ret) return ret; uclass_foreach_dev(dev, uc) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); if (desc->if_type == if_type && desc->devnum > max_devnum) max_devnum = desc->devnum; @@ -548,7 +548,7 @@ static int blk_claim_devnum(enum if_type if_type, int devnum) if (ret) return ret; uclass_foreach_dev(dev, uc) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); if (desc->if_type == if_type && desc->devnum == devnum) { int next = blk_next_free_devnum(if_type); @@ -583,7 +583,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name, ret = device_bind_driver(parent, drv_name, name, &dev); if (ret) return ret; - desc = dev_get_uclass_platdata(dev); + desc = dev_get_uclass_plat(dev); desc->if_type = if_type; desc->blksz = blksz; desc->log2blksz = LOG2(desc->blksz); @@ -629,7 +629,7 @@ int blk_unbind_all(int if_type) if (ret) return ret; uclass_foreach_dev_safe(dev, next, uc) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); if (desc->if_type == if_type) { ret = device_remove(dev, DM_REMOVE_NORMAL); @@ -648,7 +648,7 @@ static int blk_post_probe(struct udevice *dev) { if (IS_ENABLED(CONFIG_PARTITIONS) && IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE)) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); part_init(desc); } @@ -660,5 +660,5 @@ UCLASS_DRIVER(blk) = { .id = UCLASS_BLK, .name = "blk", .post_probe = blk_post_probe, - .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc), + .per_device_plat_auto = sizeof(struct blk_desc), }; diff --git a/drivers/block/ide.c b/drivers/block/ide.c index a766b5cf03..43a0776099 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -940,7 +940,7 @@ ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, #endif { #ifdef CONFIG_BLK - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); #endif int device = block_dev->devnum; ulong n = 0; @@ -1067,7 +1067,7 @@ ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, #endif { #ifdef CONFIG_BLK - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); #endif int device = block_dev->devnum; ulong n = 0; @@ -1160,7 +1160,7 @@ int ide_device_present(int dev) #ifdef CONFIG_BLK static int ide_blk_probe(struct udevice *udev) { - struct blk_desc *desc = dev_get_uclass_platdata(udev); + struct blk_desc *desc = dev_get_uclass_plat(udev); /* fill in device vendor/product/rev strings */ strncpy(desc->vendor, ide_dev_desc[desc->devnum].vendor, diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c index cca2237136..34c26cda47 100644 --- a/drivers/block/sandbox.c +++ b/drivers/block/sandbox.c @@ -34,8 +34,8 @@ static unsigned long host_block_read(struct udevice *dev, unsigned long start, lbaint_t blkcnt, void *buffer) { - struct host_block_dev *host_dev = dev_get_platdata(dev); - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct host_block_dev *host_dev = dev_get_plat(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); #else static unsigned long host_block_read(struct blk_desc *block_dev, @@ -65,8 +65,8 @@ static unsigned long host_block_write(struct udevice *dev, unsigned long start, lbaint_t blkcnt, const void *buffer) { - struct host_block_dev *host_dev = dev_get_platdata(dev); - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct host_block_dev *host_dev = dev_get_plat(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); #else static unsigned long host_block_write(struct blk_desc *block_dev, unsigned long start, lbaint_t blkcnt, @@ -133,7 +133,7 @@ int host_dev_bind(int devnum, char *filename) if (ret) goto err_file; - host_dev = dev_get_platdata(dev); + host_dev = dev_get_plat(dev); host_dev->fd = fd; host_dev->filename = fname; @@ -202,7 +202,7 @@ int host_get_dev_err(int devnum, struct blk_desc **blk_devp) ret = blk_get_device(IF_TYPE_HOST, devnum, &dev); if (ret) return ret; - *blk_devp = dev_get_uclass_platdata(dev); + *blk_devp = dev_get_uclass_plat(dev); #else struct host_block_dev *host_dev = find_host_device(devnum); @@ -228,7 +228,7 @@ U_BOOT_DRIVER(sandbox_host_blk) = { .name = "sandbox_host_blk", .id = UCLASS_BLK, .ops = &sandbox_host_blk_ops, - .platdata_auto_alloc_size = sizeof(struct host_block_dev), + .plat_auto = sizeof(struct host_block_dev), }; #else U_BOOT_LEGACY_BLK(sandbox_host) = { diff --git a/drivers/bootcount/bootcount.c b/drivers/bootcount/bootcount.c index e8db8542f9..343b8a3441 100644 --- a/drivers/bootcount/bootcount.c +++ b/drivers/bootcount/bootcount.c @@ -136,7 +136,7 @@ static const struct udevice_id bootcount_mem_ids[] = { U_BOOT_DRIVER(bootcount_mem) = { .name = "bootcount-mem", .id = UCLASS_BOOTCOUNT, - .priv_auto_alloc_size = sizeof(struct bootcount_mem_priv), + .priv_auto = sizeof(struct bootcount_mem_priv), .probe = bootcount_mem_probe, .of_match = bootcount_mem_ids, .ops = &bootcount_mem_ops, diff --git a/drivers/bootcount/i2c-eeprom.c b/drivers/bootcount/i2c-eeprom.c index a3aa0cf559..709be094b1 100644 --- a/drivers/bootcount/i2c-eeprom.c +++ b/drivers/bootcount/i2c-eeprom.c @@ -89,7 +89,7 @@ static const struct udevice_id bootcount_i2c_eeprom_ids[] = { U_BOOT_DRIVER(bootcount_spi_flash) = { .name = "bootcount-i2c-eeprom", .id = UCLASS_BOOTCOUNT, - .priv_auto_alloc_size = sizeof(struct bootcount_i2c_eeprom_priv), + .priv_auto = sizeof(struct bootcount_i2c_eeprom_priv), .probe = bootcount_i2c_eeprom_probe, .of_match = bootcount_i2c_eeprom_ids, .ops = &bootcount_i2c_eeprom_ops, diff --git a/drivers/bootcount/rtc.c b/drivers/bootcount/rtc.c index 076a8bb2be..483caaa80d 100644 --- a/drivers/bootcount/rtc.c +++ b/drivers/bootcount/rtc.c @@ -83,7 +83,7 @@ static const struct udevice_id bootcount_rtc_ids[] = { U_BOOT_DRIVER(bootcount_rtc) = { .name = "bootcount-rtc", .id = UCLASS_BOOTCOUNT, - .priv_auto_alloc_size = sizeof(struct bootcount_rtc_priv), + .priv_auto = sizeof(struct bootcount_rtc_priv), .probe = bootcount_rtc_probe, .of_match = bootcount_rtc_ids, .ops = &bootcount_rtc_ops, diff --git a/drivers/bootcount/spi-flash.c b/drivers/bootcount/spi-flash.c index 7cd388e661..03050e6661 100644 --- a/drivers/bootcount/spi-flash.c +++ b/drivers/bootcount/spi-flash.c @@ -118,7 +118,7 @@ static const struct udevice_id bootcount_spi_flash_ids[] = { U_BOOT_DRIVER(bootcount_spi_flash) = { .name = "bootcount-spi-flash", .id = UCLASS_BOOTCOUNT, - .priv_auto_alloc_size = sizeof(struct bootcount_spi_flash_priv), + .priv_auto = sizeof(struct bootcount_spi_flash_priv), .probe = bootcount_spi_flash_probe, .of_match = bootcount_spi_flash_ids, .ops = &bootcount_spi_flash_ops, diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index 07a33c6287..d742ed333b 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -5,6 +5,19 @@ menu "Bus devices" +config TI_PWMSS + bool + default y if ARCH_OMAP2PLUS && PWM_TI_EHRPWM + help + PWM Subsystem driver support for AM33xx SOC. + +config TI_SYSC + bool "TI sysc interconnect target module driver" + depends on ARCH_OMAP2PLUS + help + Generic driver for Texas Instruments interconnect target module + found on many TI SoCs. + config UNIPHIER_SYSTEM_BUS bool "UniPhier System Bus driver" depends on ARCH_UNIPHIER diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile index 0b97fc1f8b..a2e71c7b3b 100644 --- a/drivers/bus/Makefile +++ b/drivers/bus/Makefile @@ -3,4 +3,6 @@ # Makefile for the bus drivers. # +obj-$(CONFIG_TI_PWMSS) += ti-pwmss.o +obj-$(CONFIG_TI_SYSC) += ti-sysc.o obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o diff --git a/drivers/bus/ti-pwmss.c b/drivers/bus/ti-pwmss.c new file mode 100644 index 0000000000..265b4cf83b --- /dev/null +++ b/drivers/bus/ti-pwmss.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Pulse-Width Modulation Subsystem (pwmss) + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#include <common.h> +#include <dm.h> + +static const struct udevice_id ti_pwmss_ids[] = { + {.compatible = "ti,am33xx-pwmss"}, + {} +}; + +U_BOOT_DRIVER(ti_pwmss) = { + .name = "ti_pwmss", + .id = UCLASS_SIMPLE_BUS, + .of_match = ti_pwmss_ids, + .bind = dm_scan_fdt_dev, +}; diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c new file mode 100644 index 0000000000..4e3d610300 --- /dev/null +++ b/drivers/bus/ti-sysc.c @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Texas Instruments sysc interconnect target driver + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#include <common.h> +#include <clk.h> +#include <dm.h> +#include <dm/device_compat.h> + +enum ti_sysc_clocks { + TI_SYSC_FCK, + TI_SYSC_ICK, + TI_SYSC_MAX_CLOCKS, +}; + +static const char *const clock_names[] = {"fck", "ick"}; + +struct ti_sysc_priv { + int clocks_count; + struct clk clocks[TI_SYSC_MAX_CLOCKS]; +}; + +static const struct udevice_id ti_sysc_ids[] = { + {.compatible = "ti,sysc-omap2"}, + {.compatible = "ti,sysc-omap4"}, + {.compatible = "ti,sysc-omap4-simple"}, + {.compatible = "ti,sysc-omap3430-sr"}, + {.compatible = "ti,sysc-omap3630-sr"}, + {.compatible = "ti,sysc-omap4-sr"}, + {.compatible = "ti,sysc-omap3-sham"}, + {.compatible = "ti,sysc-omap-aes"}, + {.compatible = "ti,sysc-mcasp"}, + {.compatible = "ti,sysc-usb-host-fs"}, + {} +}; + +static int ti_sysc_get_one_clock(struct udevice *dev, enum ti_sysc_clocks index) +{ + struct ti_sysc_priv *priv = dev_get_priv(dev); + const char *name; + int err; + + switch (index) { + case TI_SYSC_FCK: + break; + case TI_SYSC_ICK: + break; + default: + return -EINVAL; + } + + name = clock_names[index]; + + err = clk_get_by_name(dev, name, &priv->clocks[index]); + if (err) { + if (err == -ENODATA) + return 0; + + dev_err(dev, "failed to get %s clock\n", name); + return err; + } + + return 0; +} + +static int ti_sysc_put_clocks(struct udevice *dev) +{ + struct ti_sysc_priv *priv = dev_get_priv(dev); + int err; + + err = clk_release_all(priv->clocks, priv->clocks_count); + if (err) + dev_err(dev, "failed to release all clocks\n"); + + return err; +} + +static int ti_sysc_get_clocks(struct udevice *dev) +{ + struct ti_sysc_priv *priv = dev_get_priv(dev); + int i, err; + + for (i = 0; i < TI_SYSC_MAX_CLOCKS; i++) { + err = ti_sysc_get_one_clock(dev, i); + if (!err) + priv->clocks_count++; + else if (err != -ENOENT) + return err; + } + + return 0; +} + +static int ti_sysc_child_post_remove(struct udevice *dev) +{ + struct ti_sysc_priv *priv = dev_get_priv(dev->parent); + int i, err; + + for (i = 0; i < priv->clocks_count; i++) { + err = clk_disable(&priv->clocks[i]); + if (err) { + dev_err(dev->parent, "failed to disable %s clock\n", + clock_names[i]); + return err; + } + } + + return 0; +} + +static int ti_sysc_child_pre_probe(struct udevice *dev) +{ + struct ti_sysc_priv *priv = dev_get_priv(dev->parent); + int i, err; + + for (i = 0; i < priv->clocks_count; i++) { + err = clk_enable(&priv->clocks[i]); + if (err) { + dev_err(dev->parent, "failed to enable %s clock\n", + clock_names[i]); + return err; + } + } + + return 0; +} + +static int ti_sysc_remove(struct udevice *dev) +{ + return ti_sysc_put_clocks(dev); +} + +static int ti_sysc_probe(struct udevice *dev) +{ + int err; + + err = ti_sysc_get_clocks(dev); + if (err) + goto clocks_err; + + return 0; + +clocks_err: + ti_sysc_put_clocks(dev); + return err; +} + +UCLASS_DRIVER(ti_sysc) = { + .id = UCLASS_SIMPLE_BUS, + .name = "ti_sysc", + .post_bind = dm_scan_fdt_dev +}; + +U_BOOT_DRIVER(ti_sysc) = { + .name = "ti_sysc", + .id = UCLASS_SIMPLE_BUS, + .of_match = ti_sysc_ids, + .probe = ti_sysc_probe, + .remove = ti_sysc_remove, + .child_pre_probe = ti_sysc_child_pre_probe, + .child_post_remove = ti_sysc_child_post_remove, + .priv_auto = sizeof(struct ti_sysc_priv) +}; diff --git a/drivers/button/button-gpio.c b/drivers/button/button-gpio.c index 985ae7f5a7..dbb000622c 100644 --- a/drivers/button/button-gpio.c +++ b/drivers/button/button-gpio.c @@ -31,7 +31,7 @@ static enum button_state_t button_gpio_get_state(struct udevice *dev) static int button_gpio_probe(struct udevice *dev) { - struct button_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct button_gpio_priv *priv = dev_get_priv(dev); int ret; @@ -83,7 +83,7 @@ static int button_gpio_bind(struct udevice *parent) node, &dev); if (ret) return ret; - uc_plat = dev_get_uclass_platdata(dev); + uc_plat = dev_get_uclass_plat(dev); uc_plat->label = label; } @@ -105,7 +105,7 @@ U_BOOT_DRIVER(button_gpio) = { .id = UCLASS_BUTTON, .of_match = button_gpio_ids, .ops = &button_gpio_ops, - .priv_auto_alloc_size = sizeof(struct button_gpio_priv), + .priv_auto = sizeof(struct button_gpio_priv), .bind = button_gpio_bind, .probe = button_gpio_probe, .remove = button_gpio_remove, diff --git a/drivers/button/button-uclass.c b/drivers/button/button-uclass.c index 1c742c265c..e06d3eb7da 100644 --- a/drivers/button/button-uclass.c +++ b/drivers/button/button-uclass.c @@ -16,7 +16,7 @@ int button_get_by_label(const char *label, struct udevice **devp) struct uclass *uc; uclass_id_foreach_dev(UCLASS_BUTTON, dev, uc) { - struct button_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Ignore the top-level button node */ if (uc_plat->label && !strcmp(label, uc_plat->label)) @@ -39,5 +39,5 @@ enum button_state_t button_get_state(struct udevice *dev) UCLASS_DRIVER(button) = { .id = UCLASS_BUTTON, .name = "button", - .per_device_platdata_auto_alloc_size = sizeof(struct button_uc_plat), + .per_device_plat_auto = sizeof(struct button_uc_plat), }; diff --git a/drivers/cache/cache-v5l2.c b/drivers/cache/cache-v5l2.c index 51c074bfe2..cb9ebbb4f9 100644 --- a/drivers/cache/cache-v5l2.c +++ b/drivers/cache/cache-v5l2.c @@ -73,7 +73,7 @@ struct v5l2_plat { static int v5l2_enable(struct udevice *dev) { - struct v5l2_plat *plat = dev_get_platdata(dev); + struct v5l2_plat *plat = dev_get_plat(dev); volatile struct l2cache *regs = plat->regs; if (regs) @@ -84,7 +84,7 @@ static int v5l2_enable(struct udevice *dev) static int v5l2_disable(struct udevice *dev) { - struct v5l2_plat *plat = dev_get_platdata(dev); + struct v5l2_plat *plat = dev_get_plat(dev); volatile struct l2cache *regs = plat->regs; u8 hart = gd->arch.boot_hart; void __iomem *cctlcmd = (void __iomem *)CCTL_CMD_REG(regs, hart); @@ -104,9 +104,9 @@ static int v5l2_disable(struct udevice *dev) return 0; } -static int v5l2_ofdata_to_platdata(struct udevice *dev) +static int v5l2_of_to_plat(struct udevice *dev) { - struct v5l2_plat *plat = dev_get_platdata(dev); + struct v5l2_plat *plat = dev_get_plat(dev); struct l2cache *regs; regs = (struct l2cache *)dev_read_addr(dev); @@ -130,7 +130,7 @@ static int v5l2_ofdata_to_platdata(struct udevice *dev) static int v5l2_probe(struct udevice *dev) { - struct v5l2_plat *plat = dev_get_platdata(dev); + struct v5l2_plat *plat = dev_get_plat(dev); struct l2cache *regs = plat->regs; u32 ctl_val; @@ -180,9 +180,9 @@ U_BOOT_DRIVER(v5l2_cache) = { .name = "v5l2_cache", .id = UCLASS_CACHE, .of_match = v5l2_cache_ids, - .ofdata_to_platdata = v5l2_ofdata_to_platdata, + .of_to_plat = v5l2_of_to_plat, .probe = v5l2_probe, - .platdata_auto_alloc_size = sizeof(struct v5l2_plat), + .plat_auto = sizeof(struct v5l2_plat), .ops = &v5l2_cache_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 4dfbad7986..db06f276ec 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -98,14 +98,6 @@ config CLK_STM32F This clock driver adds support for RCC clock management for STM32F4 and STM32F7 SoCs. -config CLK_TI_SCI - bool "TI System Control Interface (TI SCI) clock driver" - depends on CLK && TI_SCI_PROTOCOL && OF_CONTROL - help - This enables the clock driver support over TI System Control Interface - available on some new TI's SoCs. If you wish to use clock resources - managed by the TI System Controller, say Y here. Otherwise, say N. - config CLK_HSDK bool "Enable cgu clock driver for HSDK boards" depends on CLK && TARGET_HSDK @@ -179,6 +171,7 @@ source "drivers/clk/renesas/Kconfig" source "drivers/clk/sunxi/Kconfig" source "drivers/clk/sifive/Kconfig" source "drivers/clk/tegra/Kconfig" +source "drivers/clk/ti/Kconfig" source "drivers/clk/uniphier/Kconfig" config ICS8N3QV01 diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index d1e295ac7c..f8383e523d 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o obj-y += analogbits/ obj-y += imx/ obj-y += tegra/ +obj-y += ti/ obj-$(CONFIG_ARCH_ASPEED) += aspeed/ obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ obj-$(CONFIG_ARCH_MTMIPS) += mtmips/ @@ -47,6 +48,5 @@ obj-$(CONFIG_SANDBOX) += clk_sandbox.o obj-$(CONFIG_SANDBOX) += clk_sandbox_test.o obj-$(CONFIG_SANDBOX_CLK_CCF) += clk_sandbox_ccf.o obj-$(CONFIG_STM32H7) += clk_stm32h7.o -obj-$(CONFIG_CLK_TI_SCI) += clk-ti-sci.o obj-$(CONFIG_CLK_VERSAL) += clk_versal.o obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o diff --git a/drivers/clk/altera/clk-agilex.c b/drivers/clk/altera/clk-agilex.c index a539889d5b..bac1d98e19 100644 --- a/drivers/clk/altera/clk-agilex.c +++ b/drivers/clk/altera/clk-agilex.c @@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR; -struct socfpga_clk_platdata { +struct socfpga_clk_plat { void __iomem *regs; }; @@ -25,20 +25,20 @@ struct socfpga_clk_platdata { * function to write the bypass register which requires a poll of the * busy bit */ -static void clk_write_bypass_mainpll(struct socfpga_clk_platdata *plat, u32 val) +static void clk_write_bypass_mainpll(struct socfpga_clk_plat *plat, u32 val) { CM_REG_WRITEL(plat, val, CLKMGR_MAINPLL_BYPASS); cm_wait_for_fsm(); } -static void clk_write_bypass_perpll(struct socfpga_clk_platdata *plat, u32 val) +static void clk_write_bypass_perpll(struct socfpga_clk_plat *plat, u32 val) { CM_REG_WRITEL(plat, val, CLKMGR_PERPLL_BYPASS); cm_wait_for_fsm(); } /* function to write the ctrl register which requires a poll of the busy bit */ -static void clk_write_ctrl(struct socfpga_clk_platdata *plat, u32 val) +static void clk_write_ctrl(struct socfpga_clk_plat *plat, u32 val) { CM_REG_WRITEL(plat, val, CLKMGR_CTRL); cm_wait_for_fsm(); @@ -108,7 +108,7 @@ static const struct { }, }; -static int membus_wait_for_req(struct socfpga_clk_platdata *plat, u32 pll, +static int membus_wait_for_req(struct socfpga_clk_plat *plat, u32 pll, int timeout) { int cnt = 0; @@ -133,7 +133,7 @@ static int membus_wait_for_req(struct socfpga_clk_platdata *plat, u32 pll, return 0; } -static int membus_write_pll(struct socfpga_clk_platdata *plat, u32 pll, +static int membus_write_pll(struct socfpga_clk_plat *plat, u32 pll, u32 addr_offset, u32 wdat, int timeout) { u32 addr; @@ -154,7 +154,7 @@ static int membus_write_pll(struct socfpga_clk_platdata *plat, u32 pll, return membus_wait_for_req(plat, pll, timeout); } -static int membus_read_pll(struct socfpga_clk_platdata *plat, u32 pll, +static int membus_read_pll(struct socfpga_clk_plat *plat, u32 pll, u32 addr_offset, u32 *rdata, int timeout) { u32 addr; @@ -184,7 +184,7 @@ static int membus_read_pll(struct socfpga_clk_platdata *plat, u32 pll, return 0; } -static void membus_pll_configs(struct socfpga_clk_platdata *plat, u32 pll) +static void membus_pll_configs(struct socfpga_clk_plat *plat, u32 pll) { int i; u32 rdata; @@ -236,7 +236,7 @@ static u32 calc_vocalib_pll(u32 pllm, u32 pllglob) static void clk_basic_init(struct udevice *dev, const struct cm_config * const cfg) { - struct socfpga_clk_platdata *plat = dev_get_platdata(dev); + struct socfpga_clk_plat *plat = dev_get_plat(dev); u32 vcocalib; if (!cfg) @@ -342,7 +342,7 @@ static void clk_basic_init(struct udevice *dev, CM_REG_READL(plat, CLKMGR_CTRL) & ~CLKMGR_CTRL_BOOTMODE); } -static u64 clk_get_vco_clk_hz(struct socfpga_clk_platdata *plat, +static u64 clk_get_vco_clk_hz(struct socfpga_clk_plat *plat, u32 pllglob_reg, u32 pllm_reg) { u64 fref, arefdiv, mdiv, reg, vco; @@ -375,26 +375,26 @@ static u64 clk_get_vco_clk_hz(struct socfpga_clk_platdata *plat, return vco; } -static u64 clk_get_main_vco_clk_hz(struct socfpga_clk_platdata *plat) +static u64 clk_get_main_vco_clk_hz(struct socfpga_clk_plat *plat) { return clk_get_vco_clk_hz(plat, CLKMGR_MAINPLL_PLLGLOB, CLKMGR_MAINPLL_PLLM); } -static u64 clk_get_per_vco_clk_hz(struct socfpga_clk_platdata *plat) +static u64 clk_get_per_vco_clk_hz(struct socfpga_clk_plat *plat) { return clk_get_vco_clk_hz(plat, CLKMGR_PERPLL_PLLGLOB, CLKMGR_PERPLL_PLLM); } -static u32 clk_get_5_1_clk_src(struct socfpga_clk_platdata *plat, u64 reg) +static u32 clk_get_5_1_clk_src(struct socfpga_clk_plat *plat, u64 reg) { u32 clksrc = CM_REG_READL(plat, reg); return (clksrc & CLKMGR_CLKSRC_MASK) >> CLKMGR_CLKSRC_OFFSET; } -static u64 clk_get_clksrc_hz(struct socfpga_clk_platdata *plat, u32 clksrc_reg, +static u64 clk_get_clksrc_hz(struct socfpga_clk_plat *plat, u32 clksrc_reg, u32 main_reg, u32 per_reg) { u64 clock; @@ -431,7 +431,7 @@ static u64 clk_get_clksrc_hz(struct socfpga_clk_platdata *plat, u32 clksrc_reg, return clock; } -static u64 clk_get_mpu_clk_hz(struct socfpga_clk_platdata *plat) +static u64 clk_get_mpu_clk_hz(struct socfpga_clk_plat *plat) { u64 clock = clk_get_clksrc_hz(plat, CLKMGR_MAINPLL_MPUCLK, CLKMGR_MAINPLL_PLLC0, @@ -443,14 +443,14 @@ static u64 clk_get_mpu_clk_hz(struct socfpga_clk_platdata *plat) return clock; } -static u32 clk_get_l3_main_clk_hz(struct socfpga_clk_platdata *plat) +static u32 clk_get_l3_main_clk_hz(struct socfpga_clk_plat *plat) { return clk_get_clksrc_hz(plat, CLKMGR_MAINPLL_NOCCLK, CLKMGR_MAINPLL_PLLC1, CLKMGR_PERPLL_PLLC1); } -static u32 clk_get_l4_main_clk_hz(struct socfpga_clk_platdata *plat) +static u32 clk_get_l4_main_clk_hz(struct socfpga_clk_plat *plat) { u64 clock = clk_get_l3_main_clk_hz(plat); @@ -461,7 +461,7 @@ static u32 clk_get_l4_main_clk_hz(struct socfpga_clk_platdata *plat) return clock; } -static u32 clk_get_sdmmc_clk_hz(struct socfpga_clk_platdata *plat) +static u32 clk_get_sdmmc_clk_hz(struct socfpga_clk_plat *plat) { u64 clock = clk_get_clksrc_hz(plat, CLKMGR_ALTR_SDMMCCTR, CLKMGR_MAINPLL_PLLC3, @@ -473,7 +473,7 @@ static u32 clk_get_sdmmc_clk_hz(struct socfpga_clk_platdata *plat) return clock / 4; } -static u32 clk_get_l4_sp_clk_hz(struct socfpga_clk_platdata *plat) +static u32 clk_get_l4_sp_clk_hz(struct socfpga_clk_plat *plat) { u64 clock = clk_get_l3_main_clk_hz(plat); @@ -484,7 +484,7 @@ static u32 clk_get_l4_sp_clk_hz(struct socfpga_clk_platdata *plat) return clock; } -static u32 clk_get_l4_mp_clk_hz(struct socfpga_clk_platdata *plat) +static u32 clk_get_l4_mp_clk_hz(struct socfpga_clk_plat *plat) { u64 clock = clk_get_l3_main_clk_hz(plat); @@ -495,7 +495,7 @@ static u32 clk_get_l4_mp_clk_hz(struct socfpga_clk_platdata *plat) return clock; } -static u32 clk_get_l4_sys_free_clk_hz(struct socfpga_clk_platdata *plat) +static u32 clk_get_l4_sys_free_clk_hz(struct socfpga_clk_plat *plat) { if (CM_REG_READL(plat, CLKMGR_STAT) & CLKMGR_STAT_BOOTMODE) return clk_get_l3_main_clk_hz(plat) / 2; @@ -503,7 +503,7 @@ static u32 clk_get_l4_sys_free_clk_hz(struct socfpga_clk_platdata *plat) return clk_get_l3_main_clk_hz(plat) / 4; } -static u32 clk_get_emac_clk_hz(struct socfpga_clk_platdata *plat, u32 emac_id) +static u32 clk_get_emac_clk_hz(struct socfpga_clk_plat *plat, u32 emac_id) { bool emacsel_a; u32 ctl; @@ -585,7 +585,7 @@ static u32 clk_get_emac_clk_hz(struct socfpga_clk_platdata *plat, u32 emac_id) static ulong socfpga_clk_get_rate(struct clk *clk) { - struct socfpga_clk_platdata *plat = dev_get_platdata(clk->dev); + struct socfpga_clk_plat *plat = dev_get_plat(clk->dev); switch (clk->id) { case AGILEX_MPU_CLK: @@ -628,9 +628,9 @@ static int socfpga_clk_probe(struct udevice *dev) return 0; } -static int socfpga_clk_ofdata_to_platdata(struct udevice *dev) +static int socfpga_clk_of_to_plat(struct udevice *dev) { - struct socfpga_clk_platdata *plat = dev_get_platdata(dev); + struct socfpga_clk_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -657,6 +657,6 @@ U_BOOT_DRIVER(socfpga_agilex_clk) = { .of_match = socfpga_clk_match, .ops = &socfpga_clk_ops, .probe = socfpga_clk_probe, - .ofdata_to_platdata = socfpga_clk_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct socfpga_clk_platdata), + .of_to_plat = socfpga_clk_of_to_plat, + .plat_auto = sizeof(struct socfpga_clk_plat), }; diff --git a/drivers/clk/altera/clk-arria10.c b/drivers/clk/altera/clk-arria10.c index 732ed4d79b..1812152d56 100644 --- a/drivers/clk/altera/clk-arria10.c +++ b/drivers/clk/altera/clk-arria10.c @@ -24,7 +24,7 @@ enum socfpga_a10_clk_type { SOCFPGA_A10_CLK_UNKNOWN_CLK, }; -struct socfpga_a10_clk_platdata { +struct socfpga_a10_clk_plat { enum socfpga_a10_clk_type type; struct clk_bulk clks; u32 regs; @@ -43,7 +43,7 @@ struct socfpga_a10_clk_platdata { static int socfpga_a10_clk_get_upstream(struct clk *clk, struct clk **upclk) { - struct socfpga_a10_clk_platdata *plat = dev_get_platdata(clk->dev); + struct socfpga_a10_clk_plat *plat = dev_get_plat(clk->dev); u32 reg, maxval; if (plat->clks.count == 0) @@ -84,7 +84,7 @@ static int socfpga_a10_clk_get_upstream(struct clk *clk, struct clk **upclk) static int socfpga_a10_clk_endisable(struct clk *clk, bool enable) { - struct socfpga_a10_clk_platdata *plat = dev_get_platdata(clk->dev); + struct socfpga_a10_clk_plat *plat = dev_get_plat(clk->dev); struct clk *upclk = NULL; int ret; @@ -120,7 +120,7 @@ static int socfpga_a10_clk_disable(struct clk *clk) static ulong socfpga_a10_clk_get_rate(struct clk *clk) { - struct socfpga_a10_clk_platdata *plat = dev_get_platdata(clk->dev); + struct socfpga_a10_clk_plat *plat = dev_get_plat(clk->dev); struct clk *upclk = NULL; ulong rate = 0, reg, numer, denom; int ret; @@ -190,7 +190,7 @@ static struct clk_ops socfpga_a10_clk_ops = { */ static void socfpga_a10_handoff_workaround(struct udevice *dev) { - struct socfpga_a10_clk_platdata *plat = dev_get_platdata(dev); + struct socfpga_a10_clk_plat *plat = dev_get_plat(dev); const void *fdt = gd->fdt_blob; struct clk_bulk *bulk = &plat->clks; int i, ret, offset = dev_of_offset(dev); @@ -274,8 +274,8 @@ static int socfpga_a10_clk_bind(struct udevice *dev) static int socfpga_a10_clk_probe(struct udevice *dev) { - struct socfpga_a10_clk_platdata *plat = dev_get_platdata(dev); - struct socfpga_a10_clk_platdata *pplat; + struct socfpga_a10_clk_plat *plat = dev_get_plat(dev); + struct socfpga_a10_clk_plat *pplat; struct udevice *pdev; const void *fdt = gd->fdt_blob; int offset = dev_of_offset(dev); @@ -291,7 +291,7 @@ static int socfpga_a10_clk_probe(struct udevice *dev) if (!pdev) return -ENODEV; - pplat = dev_get_platdata(pdev); + pplat = dev_get_plat(pdev); if (!pplat) return -EINVAL; @@ -319,9 +319,9 @@ static int socfpga_a10_clk_probe(struct udevice *dev) return 0; } -static int socfpga_a10_ofdata_to_platdata(struct udevice *dev) +static int socfpga_a10_of_to_plat(struct udevice *dev) { - struct socfpga_a10_clk_platdata *plat = dev_get_platdata(dev); + struct socfpga_a10_clk_plat *plat = dev_get_plat(dev); unsigned int divreg[3], gatereg[2]; int ret; @@ -357,7 +357,7 @@ U_BOOT_DRIVER(socfpga_a10_clk) = { .ops = &socfpga_a10_clk_ops, .bind = socfpga_a10_clk_bind, .probe = socfpga_a10_clk_probe, - .ofdata_to_platdata = socfpga_a10_ofdata_to_platdata, + .of_to_plat = socfpga_a10_of_to_plat, - .platdata_auto_alloc_size = sizeof(struct socfpga_a10_clk_platdata), + .plat_auto = sizeof(struct socfpga_a10_clk_plat), }; diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c index aab7d14deb..a090671625 100644 --- a/drivers/clk/aspeed/clk_ast2500.c +++ b/drivers/clk/aspeed/clk_ast2500.c @@ -491,7 +491,7 @@ struct clk_ops ast2500_clk_ops = { .enable = ast2500_clk_enable, }; -static int ast2500_clk_ofdata_to_platdata(struct udevice *dev) +static int ast2500_clk_of_to_plat(struct udevice *dev) { struct ast2500_clk_priv *priv = dev_get_priv(dev); @@ -523,8 +523,8 @@ U_BOOT_DRIVER(aspeed_ast2500_scu) = { .name = "aspeed_ast2500_scu", .id = UCLASS_CLK, .of_match = ast2500_clk_ids, - .priv_auto_alloc_size = sizeof(struct ast2500_clk_priv), + .priv_auto = sizeof(struct ast2500_clk_priv), .ops = &ast2500_clk_ops, .bind = ast2500_clk_bind, - .ofdata_to_platdata = ast2500_clk_ofdata_to_platdata, + .of_to_plat = ast2500_clk_of_to_plat, }; diff --git a/drivers/clk/at91/compat.c b/drivers/clk/at91/compat.c index 9563285674..e514f26656 100644 --- a/drivers/clk/at91/compat.c +++ b/drivers/clk/at91/compat.c @@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR; -struct pmc_platdata { +struct pmc_plat { struct at91_pmc *reg_base; struct regmap *regmap_sfr; }; @@ -45,7 +45,7 @@ U_BOOT_DRIVER(at91_pmc) = { static int at91_pmc_core_probe(struct udevice *dev) { - struct pmc_platdata *plat = dev_get_platdata(dev); + struct pmc_plat *plat = dev_get_plat(dev); dev = dev_get_parent(dev); @@ -62,34 +62,30 @@ static int at91_pmc_core_probe(struct udevice *dev) */ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) { - const void *fdt = gd->fdt_blob; - int offset = dev_of_offset(dev); + ofnode parent = dev_ofnode(dev); + ofnode node; bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC); const char *name; int ret; - for (offset = fdt_first_subnode(fdt, offset); - offset > 0; - offset = fdt_next_subnode(fdt, offset)) { - if (pre_reloc_only && - !ofnode_pre_reloc(offset_to_ofnode(offset))) + ofnode_for_each_subnode(node, parent) { + if (pre_reloc_only && !ofnode_pre_reloc(node)) continue; /* * If this node has "compatible" property, this is not * a clock sub-node, but a normal device. skip. */ - fdt_get_property(fdt, offset, "compatible", &ret); - if (ret >= 0) + if (ofnode_read_prop(node, "compatible", NULL)) continue; if (ret != -FDT_ERR_NOTFOUND) return ret; - name = fdt_get_name(fdt, offset, NULL); + name = ofnode_get_name(node); if (!name) return -EINVAL; - ret = device_bind_driver_to_node(dev, drv_name, name, - offset_to_ofnode(offset), NULL); + ret = device_bind_driver_to_node(dev, drv_name, name, node, + NULL); if (ret) return ret; } @@ -119,7 +115,7 @@ int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args) int at91_clk_probe(struct udevice *dev) { struct udevice *dev_periph_container, *dev_pmc; - struct pmc_platdata *plat = dev_get_platdata(dev); + struct pmc_plat *plat = dev_get_plat(dev); dev_periph_container = dev_get_parent(dev); dev_pmc = dev_get_parent(dev_periph_container); @@ -195,7 +191,7 @@ U_BOOT_DRIVER(at91_master_clk) = { /* Main osc clock specific code. */ static int main_osc_clk_enable(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; if (readl(&pmc->sr) & AT91_PMC_MOSCSELS) @@ -229,14 +225,14 @@ U_BOOT_DRIVER(at91sam9x5_main_osc_clk) = { .id = UCLASS_CLK, .of_match = main_osc_clk_match, .probe = main_osc_clk_probe, - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .plat_auto = sizeof(struct pmc_plat), .ops = &main_osc_clk_ops, }; /* PLLA clock specific code. */ static int plla_clk_enable(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; if (readl(&pmc->sr) & AT91_PMC_LOCKA) @@ -270,7 +266,7 @@ U_BOOT_DRIVER(at91_plla_clk) = { .id = UCLASS_CLK, .of_match = plla_clk_match, .probe = plla_clk_probe, - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .plat_auto = sizeof(struct pmc_plat), .ops = &plla_clk_ops, }; @@ -282,7 +278,7 @@ static int at91_plladiv_clk_enable(struct clk *clk) static ulong at91_plladiv_clk_get_rate(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; struct clk source; ulong clk_rate; @@ -301,7 +297,7 @@ static ulong at91_plladiv_clk_get_rate(struct clk *clk) static ulong at91_plladiv_clk_set_rate(struct clk *clk, ulong rate) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; struct clk source; ulong parent_rate; @@ -344,7 +340,7 @@ U_BOOT_DRIVER(at91_plladiv_clk) = { .id = UCLASS_CLK, .of_match = at91_plladiv_clk_match, .probe = at91_plladiv_clk_probe, - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .plat_auto = sizeof(struct pmc_plat), .ops = &at91_plladiv_clk_ops, }; @@ -405,7 +401,7 @@ static ulong system_clk_set_rate(struct clk *clk, ulong rate) static int system_clk_enable(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; u32 mask; @@ -441,7 +437,7 @@ U_BOOT_DRIVER(system_clk) = { .name = "system-clk", .id = UCLASS_CLK, .probe = at91_clk_probe, - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .plat_auto = sizeof(struct pmc_plat), .ops = &system_clk_ops, }; @@ -487,7 +483,7 @@ U_BOOT_DRIVER(sam9x5_periph_clk) = { static int periph_clk_enable(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; enum periph_clk_type clk_type; void *addr; @@ -540,7 +536,7 @@ static struct clk_ops periph_clk_ops = { U_BOOT_DRIVER(clk_periph) = { .name = "periph-clk", .id = UCLASS_CLK, - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .plat_auto = sizeof(struct pmc_plat), .probe = at91_clk_probe, .ops = &periph_clk_ops, }; @@ -556,7 +552,7 @@ U_BOOT_DRIVER(clk_periph) = { static int utmi_clk_enable(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; struct clk clk_dev; ulong clk_rate; @@ -642,9 +638,9 @@ static struct clk_ops utmi_clk_ops = { .get_rate = utmi_clk_get_rate, }; -static int utmi_clk_ofdata_to_platdata(struct udevice *dev) +static int utmi_clk_of_to_plat(struct udevice *dev) { - struct pmc_platdata *plat = dev_get_platdata(dev); + struct pmc_plat *plat = dev_get_plat(dev); struct udevice *syscon; uclass_get_device_by_phandle(UCLASS_SYSCON, dev, @@ -671,8 +667,8 @@ U_BOOT_DRIVER(at91sam9x5_utmi_clk) = { .id = UCLASS_CLK, .of_match = utmi_clk_match, .probe = utmi_clk_probe, - .ofdata_to_platdata = utmi_clk_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .of_to_plat = utmi_clk_of_to_plat, + .plat_auto = sizeof(struct pmc_plat), .ops = &utmi_clk_ops, }; @@ -685,7 +681,7 @@ U_BOOT_DRIVER(at91sam9x5_utmi_clk) = { static ulong sama5d4_h32mx_clk_get_rate(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; ulong rate = gd->arch.mck_rate_hz; @@ -717,7 +713,7 @@ U_BOOT_DRIVER(sama5d4_h32mx_clk) = { .id = UCLASS_CLK, .of_match = sama5d4_h32mx_clk_match, .probe = sama5d4_h32mx_clk_probe, - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .plat_auto = sizeof(struct pmc_plat), .ops = &sama5d4_h32mx_clk_ops, }; @@ -758,7 +754,7 @@ struct generic_clk_priv { static ulong generic_clk_get_rate(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; struct clk parent; ulong clk_rate; @@ -786,7 +782,7 @@ static ulong generic_clk_get_rate(struct clk *clk) static ulong generic_clk_set_rate(struct clk *clk, ulong rate) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; struct generic_clk_priv *priv = dev_get_priv(clk->dev); struct clk parent, best_parent; @@ -857,7 +853,7 @@ static struct clk_ops generic_clk_ops = { .set_rate = generic_clk_set_rate, }; -static int generic_clk_ofdata_to_platdata(struct udevice *dev) +static int generic_clk_of_to_plat(struct udevice *dev) { struct generic_clk_priv *priv = dev_get_priv(dev); u32 cells[GENERATED_SOURCE_MAX]; @@ -879,9 +875,9 @@ U_BOOT_DRIVER(generic_clk) = { .name = "generic-clk", .id = UCLASS_CLK, .probe = at91_clk_probe, - .ofdata_to_platdata = generic_clk_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct generic_clk_priv), - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .of_to_plat = generic_clk_of_to_plat, + .priv_auto = sizeof(struct generic_clk_priv), + .plat_auto = sizeof(struct pmc_plat), .ops = &generic_clk_ops, }; @@ -899,7 +895,7 @@ struct at91_usb_clk_priv { static ulong at91_usb_clk_get_rate(struct clk *clk) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; struct clk source; u32 tmp, usbdiv; @@ -920,7 +916,7 @@ static ulong at91_usb_clk_get_rate(struct clk *clk) static ulong at91_usb_clk_set_rate(struct clk *clk, ulong rate) { - struct pmc_platdata *plat = dev_get_platdata(clk->dev); + struct pmc_plat *plat = dev_get_plat(clk->dev); struct at91_pmc *pmc = plat->reg_base; struct at91_usb_clk_priv *priv = dev_get_priv(clk->dev); struct clk source, best_source; @@ -981,7 +977,7 @@ static struct clk_ops at91_usb_clk_ops = { .set_rate = at91_usb_clk_set_rate, }; -static int at91_usb_clk_ofdata_to_platdata(struct udevice *dev) +static int at91_usb_clk_of_to_plat(struct udevice *dev) { struct at91_usb_clk_priv *priv = dev_get_priv(dev); u32 cells[AT91_USB_CLK_SOURCE_MAX]; @@ -1015,9 +1011,9 @@ U_BOOT_DRIVER(at91_usb_clk) = { .id = UCLASS_CLK, .of_match = at91_usb_clk_match, .probe = at91_usb_clk_probe, - .ofdata_to_platdata = at91_usb_clk_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct at91_usb_clk_priv), - .platdata_auto_alloc_size = sizeof(struct pmc_platdata), + .of_to_plat = at91_usb_clk_of_to_plat, + .priv_auto = sizeof(struct at91_usb_clk_priv), + .plat_auto = sizeof(struct pmc_plat), .ops = &at91_usb_clk_ops, }; diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c index dd62dc5510..34ce611a98 100644 --- a/drivers/clk/at91/sckc.c +++ b/drivers/clk/at91/sckc.c @@ -165,7 +165,7 @@ U_BOOT_DRIVER(at91_sckc) = { .name = UBOOT_DM_CLK_AT91_SCKC, .id = UCLASS_CLK, .of_match = sam9x60_sckc_ids, - .priv_auto_alloc_size = sizeof(struct sam9x60_sckc) * 2, + .priv_auto = sizeof(struct sam9x60_sckc) * 2, .ops = &sam9x60_sckc_ops, .probe = at91_sam9x60_sckc_probe, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/clk/clk-cdce9xx.c b/drivers/clk/clk-cdce9xx.c index fd47872ab9..6634b7b799 100644 --- a/drivers/clk/clk-cdce9xx.c +++ b/drivers/clk/clk-cdce9xx.c @@ -251,6 +251,6 @@ U_BOOT_DRIVER(cdce9xx_clk) = { .id = UCLASS_CLK, .of_match = cdce9xx_clk_of_match, .probe = cdce9xx_clk_probe, - .priv_auto_alloc_size = sizeof(struct cdce9xx_clk_data), + .priv_auto = sizeof(struct cdce9xx_clk_data), .ops = &cdce9xx_clk_ops, }; diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 8f59d7fb72..9df50a5e72 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -28,8 +28,8 @@ #define UBOOT_DM_CLK_CCF_DIVIDER "ccf_clk_divider" -static unsigned int _get_table_div(const struct clk_div_table *table, - unsigned int val) +unsigned int clk_divider_get_table_div(const struct clk_div_table *table, + unsigned int val) { const struct clk_div_table *clkt; @@ -49,7 +49,7 @@ static unsigned int _get_div(const struct clk_div_table *table, if (flags & CLK_DIVIDER_MAX_AT_ZERO) return val ? val : clk_div_mask(width) + 1; if (table) - return _get_table_div(table, val); + return clk_divider_get_table_div(table, val); return val + 1; } @@ -89,8 +89,8 @@ static ulong clk_divider_recalc_rate(struct clk *clk) divider->flags, divider->width); } -static bool _is_valid_table_div(const struct clk_div_table *table, - unsigned int div) +bool clk_divider_is_valid_table_div(const struct clk_div_table *table, + unsigned int div) { const struct clk_div_table *clkt; @@ -100,18 +100,18 @@ static bool _is_valid_table_div(const struct clk_div_table *table, return false; } -static bool _is_valid_div(const struct clk_div_table *table, unsigned int div, - unsigned long flags) +bool clk_divider_is_valid_div(const struct clk_div_table *table, + unsigned int div, unsigned long flags) { if (flags & CLK_DIVIDER_POWER_OF_TWO) return is_power_of_2(div); if (table) - return _is_valid_table_div(table, div); + return clk_divider_is_valid_table_div(table, div); return true; } -static unsigned int _get_table_val(const struct clk_div_table *table, - unsigned int div) +unsigned int clk_divider_get_table_val(const struct clk_div_table *table, + unsigned int div) { const struct clk_div_table *clkt; @@ -131,7 +131,7 @@ static unsigned int _get_val(const struct clk_div_table *table, if (flags & CLK_DIVIDER_MAX_AT_ZERO) return (div == clk_div_mask(width) + 1) ? 0 : div; if (table) - return _get_table_val(table, div); + return clk_divider_get_table_val(table, div); return div - 1; } int divider_get_val(unsigned long rate, unsigned long parent_rate, @@ -142,7 +142,7 @@ int divider_get_val(unsigned long rate, unsigned long parent_rate, div = DIV_ROUND_UP_ULL((u64)parent_rate, rate); - if (!_is_valid_div(table, div, flags)) + if (!clk_divider_is_valid_div(table, div, flags)) return -EINVAL; value = _get_val(table, div, flags, width); diff --git a/drivers/clk/clk-hsdk-cgu.c b/drivers/clk/clk-hsdk-cgu.c index 3eb93a55fc..449b430e23 100644 --- a/drivers/clk/clk-hsdk-cgu.c +++ b/drivers/clk/clk-hsdk-cgu.c @@ -774,6 +774,6 @@ U_BOOT_DRIVER(hsdk_cgu_clk) = { .id = UCLASS_CLK, .of_match = hsdk_cgu_clk_id, .probe = hsdk_cgu_clk_probe, - .priv_auto_alloc_size = sizeof(struct hsdk_cgu_clk), + .priv_auto = sizeof(struct hsdk_cgu_clk), .ops = &hsdk_cgu_ops, }; diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index ac954a34d2..b75056718b 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -345,7 +345,7 @@ int clk_set_defaults(struct udevice *dev, int stage) { int ret; - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; /* If this not in SPL and pre-reloc state, don't take any action. */ @@ -523,6 +523,21 @@ long long clk_get_parent_rate(struct clk *clk) return pclk->rate; } +ulong clk_round_rate(struct clk *clk, ulong rate) +{ + const struct clk_ops *ops; + + debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate); + if (!clk_valid(clk)) + return 0; + + ops = clk_dev_ops(clk->dev); + if (!ops->round_rate) + return -ENOSYS; + + return ops->round_rate(clk, rate); +} + ulong clk_set_rate(struct clk *clk, ulong rate) { const struct clk_ops *ops; diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 319808d433..1efb7fe9f3 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -36,7 +36,7 @@ int clk_register(struct clk *clk, const char *drv_name, return -ENOENT; } - ret = device_bind(parent, drv, name, NULL, -1, &clk->dev); + ret = device_bind(parent, drv, name, NULL, ofnode_null(), &clk->dev); if (ret) { printf("%s: CLK: %s driver bind error [%d]!\n", __func__, name, ret); @@ -44,8 +44,10 @@ int clk_register(struct clk *clk, const char *drv_name, } clk->enable_count = 0; + /* Store back pointer to clk from udevice */ - clk->dev->uclass_priv = clk; + /* FIXME: This is not allowed...should be allocated by driver model */ + dev_set_uclass_priv(clk->dev, clk); return 0; } @@ -65,7 +67,7 @@ const char *clk_hw_get_name(const struct clk *hw) bool clk_dev_binded(struct clk *clk) { - if (clk->dev && (clk->dev->flags & DM_FLAG_BOUND)) + if (clk->dev && (dev_get_flags(clk->dev) & DM_FLAG_BOUND)) return true; return false; diff --git a/drivers/clk/clk_bcm6345.c b/drivers/clk/clk_bcm6345.c index b850b9fc06..8c22ed2f43 100644 --- a/drivers/clk/clk_bcm6345.c +++ b/drivers/clk/clk_bcm6345.c @@ -70,5 +70,5 @@ U_BOOT_DRIVER(clk_bcm6345) = { .of_match = bcm6345_clk_ids, .ops = &bcm6345_clk_ops, .probe = bcm63xx_clk_probe, - .priv_auto_alloc_size = sizeof(struct bcm6345_clk_priv), + .priv_auto = sizeof(struct bcm6345_clk_priv), }; diff --git a/drivers/clk/clk_boston.c b/drivers/clk/clk_boston.c index 2318dcf6a4..2e81777b70 100644 --- a/drivers/clk/clk_boston.c +++ b/drivers/clk/clk_boston.c @@ -28,7 +28,7 @@ static uint32_t ext_field(uint32_t val, uint32_t mask) static ulong clk_boston_get_rate(struct clk *clk) { - struct clk_boston *state = dev_get_platdata(clk->dev); + struct clk_boston *state = dev_get_plat(clk->dev); uint32_t in_rate, mul, div; uint mmcmdiv; int err; @@ -58,9 +58,9 @@ const struct clk_ops clk_boston_ops = { .get_rate = clk_boston_get_rate, }; -static int clk_boston_ofdata_to_platdata(struct udevice *dev) +static int clk_boston_of_to_plat(struct udevice *dev) { - struct clk_boston *state = dev_get_platdata(dev); + struct clk_boston *state = dev_get_plat(dev); struct udevice *syscon; int err; @@ -91,7 +91,7 @@ U_BOOT_DRIVER(clk_boston) = { .name = "boston_clock", .id = UCLASS_CLK, .of_match = clk_boston_match, - .ofdata_to_platdata = clk_boston_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct clk_boston), + .of_to_plat = clk_boston_of_to_plat, + .plat_auto = sizeof(struct clk_boston), .ops = &clk_boston_ops, }; diff --git a/drivers/clk/clk_fixed_factor.c b/drivers/clk/clk_fixed_factor.c index cf9c4ae367..e51f94a937 100644 --- a/drivers/clk/clk_fixed_factor.c +++ b/drivers/clk/clk_fixed_factor.c @@ -18,7 +18,7 @@ struct clk_fixed_factor { }; #define to_clk_fixed_factor(dev) \ - ((struct clk_fixed_factor *)dev_get_platdata(dev)) + ((struct clk_fixed_factor *)dev_get_plat(dev)) static ulong clk_fixed_factor_get_rate(struct clk *clk) { @@ -38,7 +38,7 @@ const struct clk_ops clk_fixed_factor_ops = { .get_rate = clk_fixed_factor_get_rate, }; -static int clk_fixed_factor_ofdata_to_platdata(struct udevice *dev) +static int clk_fixed_factor_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) int err; @@ -66,7 +66,7 @@ U_BOOT_DRIVER(clk_fixed_factor) = { .name = "fixed_factor_clock", .id = UCLASS_CLK, .of_match = clk_fixed_factor_match, - .ofdata_to_platdata = clk_fixed_factor_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct clk_fixed_factor), + .of_to_plat = clk_fixed_factor_of_to_plat, + .plat_auto = sizeof(struct clk_fixed_factor), .ops = &clk_fixed_factor_ops, }; diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c index f86b4a0e92..3c5a83c523 100644 --- a/drivers/clk/clk_fixed_rate.c +++ b/drivers/clk/clk_fixed_rate.c @@ -6,6 +6,7 @@ #include <common.h> #include <clk-uclass.h> #include <dm.h> +#include <dm/device-internal.h> #include <linux/clk-provider.h> static ulong clk_fixed_rate_get_rate(struct clk *clk) @@ -24,7 +25,7 @@ const struct clk_ops clk_fixed_rate_ops = { .enable = dummy_enable, }; -static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev) +static int clk_fixed_rate_of_to_plat(struct udevice *dev) { struct clk *clk = &to_clk_fixed_rate(dev)->clk; #if !CONFIG_IS_ENABLED(OF_PLATDATA) @@ -32,7 +33,8 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev) dev_read_u32_default(dev, "clock-frequency", 0); #endif /* Make fixed rate clock accessible from higher level struct clk */ - dev->uclass_priv = clk; + /* FIXME: This is not allowed */ + dev_set_uclass_priv(dev, clk); clk->dev = dev; clk->enable_count = 0; @@ -50,8 +52,8 @@ U_BOOT_DRIVER(fixed_clock) = { .name = "fixed_clock", .id = UCLASS_CLK, .of_match = clk_fixed_rate_match, - .ofdata_to_platdata = clk_fixed_rate_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct clk_fixed_rate), + .of_to_plat = clk_fixed_rate_of_to_plat, + .plat_auto = sizeof(struct clk_fixed_rate), .ops = &clk_fixed_rate_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/clk_octeon.c b/drivers/clk/clk_octeon.c index fd559e05fc..ce274549da 100644 --- a/drivers/clk/clk_octeon.c +++ b/drivers/clk/clk_octeon.c @@ -68,5 +68,5 @@ U_BOOT_DRIVER(clk_octeon) = { .of_match = octeon_clk_ids, .ops = &octeon_clk_ops, .probe = octeon_clk_probe, - .priv_auto_alloc_size = sizeof(struct octeon_clk_priv), + .priv_auto = sizeof(struct octeon_clk_priv), }; diff --git a/drivers/clk/clk_pic32.c b/drivers/clk/clk_pic32.c index dc46de2a7c..5a10d4640d 100644 --- a/drivers/clk/clk_pic32.c +++ b/drivers/clk/clk_pic32.c @@ -423,5 +423,5 @@ U_BOOT_DRIVER(pic32_clk) = { .of_match = pic32_clk_ids, .ops = &pic32_pic32_clk_ops, .probe = pic32_clk_probe, - .priv_auto_alloc_size = sizeof(struct pic32_clk_priv), + .priv_auto = sizeof(struct pic32_clk_priv), }; diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c index 0ff1b49633..b28b67b448 100644 --- a/drivers/clk/clk_sandbox.c +++ b/drivers/clk/clk_sandbox.c @@ -30,6 +30,22 @@ static ulong sandbox_clk_get_rate(struct clk *clk) return priv->rate[clk->id]; } +static ulong sandbox_clk_round_rate(struct clk *clk, ulong rate) +{ + struct sandbox_clk_priv *priv = dev_get_priv(clk->dev); + + if (!priv->probed) + return -ENODEV; + + if (clk->id >= SANDBOX_CLK_ID_COUNT) + return -EINVAL; + + if (!rate) + return -EINVAL; + + return rate; +} + static ulong sandbox_clk_set_rate(struct clk *clk, ulong rate) { struct sandbox_clk_priv *priv = dev_get_priv(clk->dev); @@ -103,6 +119,7 @@ static int sandbox_clk_free(struct clk *clk) } static struct clk_ops sandbox_clk_ops = { + .round_rate = sandbox_clk_round_rate, .get_rate = sandbox_clk_get_rate, .set_rate = sandbox_clk_set_rate, .enable = sandbox_clk_enable, @@ -130,7 +147,7 @@ U_BOOT_DRIVER(sandbox_clk) = { .of_match = sandbox_clk_ids, .ops = &sandbox_clk_ops, .probe = sandbox_clk_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_clk_priv), + .priv_auto = sizeof(struct sandbox_clk_priv), }; ulong sandbox_clk_query_rate(struct udevice *dev, int id) diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c index 873383856f..c4e4481508 100644 --- a/drivers/clk/clk_sandbox_test.c +++ b/drivers/clk/clk_sandbox_test.c @@ -86,6 +86,16 @@ ulong sandbox_clk_test_get_rate(struct udevice *dev, int id) return clk_get_rate(sbct->clkps[id]); } +ulong sandbox_clk_test_round_rate(struct udevice *dev, int id, ulong rate) +{ + struct sandbox_clk_test *sbct = dev_get_priv(dev); + + if (id < 0 || id >= SANDBOX_CLK_TEST_ID_COUNT) + return -EINVAL; + + return clk_round_rate(sbct->clkps[id], rate); +} + ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate) { struct sandbox_clk_test *sbct = dev_get_priv(dev); @@ -189,5 +199,5 @@ U_BOOT_DRIVER(sandbox_clk_test) = { .id = UCLASS_MISC, .of_match = sandbox_clk_test_ids, .probe = sandbox_clk_test_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_clk_test), + .priv_auto = sizeof(struct sandbox_clk_test), }; diff --git a/drivers/clk/clk_stm32f.c b/drivers/clk/clk_stm32f.c index 93722f74ae..7e67895ab7 100644 --- a/drivers/clk/clk_stm32f.c +++ b/drivers/clk/clk_stm32f.c @@ -726,6 +726,6 @@ U_BOOT_DRIVER(stm32fx_clk) = { .id = UCLASS_CLK, .ops = &stm32_clk_ops, .probe = stm32_clk_probe, - .priv_auto_alloc_size = sizeof(struct stm32_clk), + .priv_auto = sizeof(struct stm32_clk), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/clk_stm32h7.c b/drivers/clk/clk_stm32h7.c index edf90ee00f..0171fe8c11 100644 --- a/drivers/clk/clk_stm32h7.c +++ b/drivers/clk/clk_stm32h7.c @@ -868,6 +868,6 @@ U_BOOT_DRIVER(stm32h7_clk) = { .id = UCLASS_CLK, .ops = &stm32_clk_ops, .probe = stm32_clk_probe, - .priv_auto_alloc_size = sizeof(struct stm32_clk), + .priv_auto = sizeof(struct stm32_clk), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c index c8840b9e5f..5bea2b60b9 100644 --- a/drivers/clk/clk_stm32mp1.c +++ b/drivers/clk/clk_stm32mp1.c @@ -2253,7 +2253,7 @@ int soc_clk_dump(void) int ret; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(stm32mp1_clock), + DM_DRIVER_GET(stm32mp1_clock), &dev); if (ret) return ret; @@ -2332,6 +2332,6 @@ U_BOOT_DRIVER(stm32mp1_clock) = { .name = "stm32mp1_clk", .id = UCLASS_CLK, .ops = &stm32mp1_clk_ops, - .priv_auto_alloc_size = sizeof(struct stm32mp1_clk_priv), + .priv_auto = sizeof(struct stm32mp1_clk_priv), .probe = stm32mp1_clk_probe, }; diff --git a/drivers/clk/clk_versal.c b/drivers/clk/clk_versal.c index d93b860aed..908bc7519c 100644 --- a/drivers/clk/clk_versal.c +++ b/drivers/clk/clk_versal.c @@ -734,5 +734,5 @@ U_BOOT_DRIVER(versal_clk) = { .of_match = versal_clk_ids, .probe = versal_clk_probe, .ops = &versal_clk_ops, - .priv_auto_alloc_size = sizeof(struct versal_clk_priv), + .priv_auto = sizeof(struct versal_clk_priv), }; diff --git a/drivers/clk/clk_vexpress_osc.c b/drivers/clk/clk_vexpress_osc.c index b48319bba6..3b1e0208d4 100644 --- a/drivers/clk/clk_vexpress_osc.c +++ b/drivers/clk/clk_vexpress_osc.c @@ -107,6 +107,6 @@ U_BOOT_DRIVER(vexpress_osc_clk) = { .id = UCLASS_CLK, .of_match = vexpress_osc_clk_ids, .ops = &vexpress_osc_clk_ops, - .priv_auto_alloc_size = sizeof(struct vexpress_osc_clk_priv), + .priv_auto = sizeof(struct vexpress_osc_clk_priv), .probe = vexpress_osc_clk_probe, }; diff --git a/drivers/clk/clk_zynq.c b/drivers/clk/clk_zynq.c index a699a3664c..bf32d8317a 100644 --- a/drivers/clk/clk_zynq.c +++ b/drivers/clk/clk_zynq.c @@ -485,6 +485,6 @@ U_BOOT_DRIVER(zynq_clk) = { .id = UCLASS_CLK, .of_match = zynq_clk_ids, .ops = &zynq_clk_ops, - .priv_auto_alloc_size = sizeof(struct zynq_clk_priv), + .priv_auto = sizeof(struct zynq_clk_priv), .probe = zynq_clk_probe, }; diff --git a/drivers/clk/clk_zynqmp.c b/drivers/clk/clk_zynqmp.c index 7795119756..e8acca0066 100644 --- a/drivers/clk/clk_zynqmp.c +++ b/drivers/clk/clk_zynqmp.c @@ -617,7 +617,7 @@ int soc_clk_dump(void) int i, ret; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(zynqmp_clk), &dev); + DM_DRIVER_GET(zynqmp_clk), &dev); if (ret) return ret; @@ -715,5 +715,5 @@ U_BOOT_DRIVER(zynqmp_clk) = { .of_match = zynqmp_clk_ids, .probe = zynqmp_clk_probe, .ops = &zynqmp_clk_ops, - .priv_auto_alloc_size = sizeof(struct zynqmp_clk_priv), + .priv_auto = sizeof(struct zynqmp_clk_priv), }; diff --git a/drivers/clk/exynos/clk-exynos7420.c b/drivers/clk/exynos/clk-exynos7420.c index 4a023ea736..7d869eb02b 100644 --- a/drivers/clk/exynos/clk-exynos7420.c +++ b/drivers/clk/exynos/clk-exynos7420.c @@ -199,7 +199,7 @@ U_BOOT_DRIVER(exynos7420_clk_topc) = { .id = UCLASS_CLK, .of_match = exynos7420_clk_topc_compat, .probe = exynos7420_clk_topc_probe, - .priv_auto_alloc_size = sizeof(struct exynos7420_clk_topc_priv), + .priv_auto = sizeof(struct exynos7420_clk_topc_priv), .ops = &exynos7420_clk_topc_ops, }; @@ -213,7 +213,7 @@ U_BOOT_DRIVER(exynos7420_clk_top0) = { .id = UCLASS_CLK, .of_match = exynos7420_clk_top0_compat, .probe = exynos7420_clk_top0_probe, - .priv_auto_alloc_size = sizeof(struct exynos7420_clk_top0_priv), + .priv_auto = sizeof(struct exynos7420_clk_top0_priv), .ops = &exynos7420_clk_top0_ops, }; diff --git a/drivers/clk/ics8n3qv01.c b/drivers/clk/ics8n3qv01.c index 76b27ad7fd..6bc1b8ba9d 100644 --- a/drivers/clk/ics8n3qv01.c +++ b/drivers/clk/ics8n3qv01.c @@ -226,5 +226,5 @@ U_BOOT_DRIVER(ics8n3qv01) = { .ops = &ics8n3qv01_ops, .of_match = ics8n3qv01_ids, .probe = ics8n3qv01_probe, - .priv_auto_alloc_size = sizeof(struct ics8n3qv01_priv), + .priv_auto = sizeof(struct ics8n3qv01_priv), }; diff --git a/drivers/clk/imx/clk-imx8.c b/drivers/clk/imx/clk-imx8.c index 27a652a625..8484613eed 100644 --- a/drivers/clk/imx/clk-imx8.c +++ b/drivers/clk/imx/clk-imx8.c @@ -51,7 +51,7 @@ int soc_clk_dump(void) int i, ret; ret = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(imx8_clk), &dev); + DM_DRIVER_GET(imx8_clk), &dev); if (ret) return ret; diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c index 0246149107..259ea33595 100644 --- a/drivers/clk/mediatek/clk-mt7622.c +++ b/drivers/clk/mediatek/clk-mt7622.c @@ -716,7 +716,7 @@ U_BOOT_DRIVER(mtk_clk_apmixedsys) = { .id = UCLASS_CLK, .of_match = mt7622_apmixed_compat, .probe = mt7622_apmixedsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -726,7 +726,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen) = { .id = UCLASS_CLK, .of_match = mt7622_topckgen_compat, .probe = mt7622_topckgen_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -736,7 +736,7 @@ U_BOOT_DRIVER(mtk_clk_infracfg) = { .id = UCLASS_CLK, .of_match = mt7622_infracfg_compat, .probe = mt7622_infracfg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -746,7 +746,7 @@ U_BOOT_DRIVER(mtk_clk_pericfg) = { .id = UCLASS_CLK, .of_match = mt7622_pericfg_compat, .probe = mt7622_pericfg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -757,7 +757,7 @@ U_BOOT_DRIVER(mtk_clk_pciesys) = { .of_match = mt7622_pciesys_compat, .probe = mt7622_pciesys_probe, .bind = mt7622_pciesys_bind, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; @@ -767,7 +767,7 @@ U_BOOT_DRIVER(mtk_clk_ethsys) = { .of_match = mt7622_ethsys_compat, .probe = mt7622_ethsys_probe, .bind = mt7622_ethsys_bind, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; @@ -776,7 +776,7 @@ U_BOOT_DRIVER(mtk_clk_sgmiisys) = { .id = UCLASS_CLK, .of_match = mt7622_sgmiisys_compat, .probe = mt7622_sgmiisys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; @@ -785,6 +785,6 @@ U_BOOT_DRIVER(mtk_clk_ssusbsys) = { .id = UCLASS_CLK, .of_match = mt7622_ssusbsys_compat, .probe = mt7622_ssusbsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7623.c b/drivers/clk/mediatek/clk-mt7623.c index a15fb45e8e..0c7411ee81 100644 --- a/drivers/clk/mediatek/clk-mt7623.c +++ b/drivers/clk/mediatek/clk-mt7623.c @@ -859,7 +859,7 @@ U_BOOT_DRIVER(mtk_clk_apmixedsys) = { .id = UCLASS_CLK, .of_match = mt7623_apmixed_compat, .probe = mt7623_apmixedsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -869,7 +869,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen) = { .id = UCLASS_CLK, .of_match = mt7623_topckgen_compat, .probe = mt7623_topckgen_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -879,7 +879,7 @@ U_BOOT_DRIVER(mtk_clk_infracfg) = { .id = UCLASS_CLK, .of_match = mt7623_infracfg_compat, .probe = mt7623_infracfg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -889,7 +889,7 @@ U_BOOT_DRIVER(mtk_clk_pericfg) = { .id = UCLASS_CLK, .of_match = mt7623_pericfg_compat, .probe = mt7623_pericfg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -900,7 +900,7 @@ U_BOOT_DRIVER(mtk_clk_hifsys) = { .of_match = mt7623_hifsys_compat, .probe = mt7623_hifsys_probe, .bind = mt7623_ethsys_hifsys_bind, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; @@ -910,6 +910,6 @@ U_BOOT_DRIVER(mtk_clk_ethsys) = { .of_match = mt7623_ethsys_compat, .probe = mt7623_ethsys_probe, .bind = mt7623_ethsys_hifsys_bind, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7629.c b/drivers/clk/mediatek/clk-mt7629.c index 5b2aa5f200..31b6fa0225 100644 --- a/drivers/clk/mediatek/clk-mt7629.c +++ b/drivers/clk/mediatek/clk-mt7629.c @@ -704,7 +704,7 @@ U_BOOT_DRIVER(mtk_clk_apmixedsys) = { .id = UCLASS_CLK, .of_match = mt7629_apmixed_compat, .probe = mt7629_apmixedsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -714,7 +714,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen) = { .id = UCLASS_CLK, .of_match = mt7629_topckgen_compat, .probe = mt7629_topckgen_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -724,7 +724,7 @@ U_BOOT_DRIVER(mtk_clk_infracfg) = { .id = UCLASS_CLK, .of_match = mt7629_infracfg_compat, .probe = mt7629_infracfg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -734,7 +734,7 @@ U_BOOT_DRIVER(mtk_clk_pericfg) = { .id = UCLASS_CLK, .of_match = mt7629_pericfg_compat, .probe = mt7629_pericfg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -745,7 +745,7 @@ U_BOOT_DRIVER(mtk_clk_ethsys) = { .of_match = mt7629_ethsys_compat, .probe = mt7629_ethsys_probe, .bind = mt7629_ethsys_bind, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; @@ -754,7 +754,7 @@ U_BOOT_DRIVER(mtk_clk_sgmiisys) = { .id = UCLASS_CLK, .of_match = mt7629_sgmiisys_compat, .probe = mt7629_sgmiisys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; @@ -763,6 +763,6 @@ U_BOOT_DRIVER(mtk_clk_ssusbsys) = { .id = UCLASS_CLK, .of_match = mt7629_ssusbsys_compat, .probe = mt7629_ssusbsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; diff --git a/drivers/clk/mediatek/clk-mt8512.c b/drivers/clk/mediatek/clk-mt8512.c index ad254d1cce..193e069cb0 100644 --- a/drivers/clk/mediatek/clk-mt8512.c +++ b/drivers/clk/mediatek/clk-mt8512.c @@ -838,7 +838,7 @@ U_BOOT_DRIVER(mtk_clk_apmixedsys) = { .id = UCLASS_CLK, .of_match = mt8512_apmixed_compat, .probe = mt8512_apmixedsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -848,7 +848,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen) = { .id = UCLASS_CLK, .of_match = mt8512_topckgen_compat, .probe = mt8512_topckgen_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -858,7 +858,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen_cg) = { .id = UCLASS_CLK, .of_match = mt8512_topckgen_cg_compat, .probe = mt8512_topckgen_cg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -868,7 +868,7 @@ U_BOOT_DRIVER(mtk_clk_infracfg) = { .id = UCLASS_CLK, .of_match = mt8512_infracfg_compat, .probe = mt8512_infracfg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8516.c b/drivers/clk/mediatek/clk-mt8516.c index cd1db25783..29f70620e0 100644 --- a/drivers/clk/mediatek/clk-mt8516.c +++ b/drivers/clk/mediatek/clk-mt8516.c @@ -777,7 +777,7 @@ U_BOOT_DRIVER(mtk_clk_apmixedsys) = { .id = UCLASS_CLK, .of_match = mt8516_apmixed_compat, .probe = mt8516_apmixedsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -787,7 +787,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen) = { .id = UCLASS_CLK, .of_match = mt8516_topckgen_compat, .probe = mt8516_topckgen_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -797,7 +797,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen_cg) = { .id = UCLASS_CLK, .of_match = mt8516_topckgen_cg_compat, .probe = mt8516_topckgen_cg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8518.c b/drivers/clk/mediatek/clk-mt8518.c index 985a0c1de5..2386514837 100644 --- a/drivers/clk/mediatek/clk-mt8518.c +++ b/drivers/clk/mediatek/clk-mt8518.c @@ -1533,7 +1533,7 @@ U_BOOT_DRIVER(mtk_clk_apmixedsys) = { .id = UCLASS_CLK, .of_match = mt8518_apmixed_compat, .probe = mt8518_apmixedsys_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -1543,7 +1543,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen) = { .id = UCLASS_CLK, .of_match = mt8518_topckgen_compat, .probe = mt8518_topckgen_probe, - .priv_auto_alloc_size = sizeof(struct mtk_clk_priv), + .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -1553,7 +1553,7 @@ U_BOOT_DRIVER(mtk_clk_topckgen_cg) = { .id = UCLASS_CLK, .of_match = mt8518_topckgen_cg_compat, .probe = mt8518_topckgen_cg_probe, - .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .priv_auto = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 388471b03a..d43b8a0648 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -296,7 +296,7 @@ static ulong mtk_topckgen_get_factor_rate(struct clk *clk, u32 off) switch (fdiv->flags & CLK_PARENT_MASK) { case CLK_PARENT_APMIXED: rate = mtk_clk_find_parent_rate(clk, fdiv->parent, - DM_GET_DRIVER(mtk_clk_apmixedsys)); + DM_DRIVER_GET(mtk_clk_apmixedsys)); break; case CLK_PARENT_TOPCKGEN: rate = mtk_clk_find_parent_rate(clk, fdiv->parent, NULL); @@ -474,11 +474,11 @@ static ulong mtk_clk_gate_get_rate(struct clk *clk) switch (gate->flags & CLK_PARENT_MASK) { case CLK_PARENT_APMIXED: return mtk_clk_find_parent_rate(clk, gate->parent, - DM_GET_DRIVER(mtk_clk_apmixedsys)); + DM_DRIVER_GET(mtk_clk_apmixedsys)); break; case CLK_PARENT_TOPCKGEN: return mtk_clk_find_parent_rate(clk, gate->parent, - DM_GET_DRIVER(mtk_clk_topckgen)); + DM_DRIVER_GET(mtk_clk_topckgen)); break; default: diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c index 6ef8b418d7..d6da59d269 100644 --- a/drivers/clk/meson/axg.c +++ b/drivers/clk/meson/axg.c @@ -289,7 +289,7 @@ static int meson_clk_probe(struct udevice *dev) { struct meson_clk *priv = dev_get_priv(dev); - priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node); + priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev))); if (IS_ERR(priv->map)) return PTR_ERR(priv->map); @@ -320,7 +320,7 @@ U_BOOT_DRIVER(meson_clk_axg) = { .name = "meson_clk_axg", .id = UCLASS_CLK, .of_match = meson_clk_ids, - .priv_auto_alloc_size = sizeof(struct meson_clk), + .priv_auto = sizeof(struct meson_clk), .ops = &meson_clk_ops, .probe = meson_clk_probe, }; diff --git a/drivers/clk/meson/g12a-ao.c b/drivers/clk/meson/g12a-ao.c index 7a0abea77c..0148529e04 100644 --- a/drivers/clk/meson/g12a-ao.c +++ b/drivers/clk/meson/g12a-ao.c @@ -56,7 +56,7 @@ static int meson_clk_probe(struct udevice *dev) { struct meson_clk *priv = dev_get_priv(dev); - priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node); + priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev))); if (IS_ERR(priv->map)) return PTR_ERR(priv->map); @@ -77,7 +77,7 @@ U_BOOT_DRIVER(meson_clk_axg) = { .name = "meson_clk_g12a_ao", .id = UCLASS_CLK, .of_match = meson_clk_ids, - .priv_auto_alloc_size = sizeof(struct meson_clk), + .priv_auto = sizeof(struct meson_clk), .ops = &meson_clk_ops, .probe = meson_clk_probe, }; diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c index bf2f357435..5058db1a47 100644 --- a/drivers/clk/meson/g12a.c +++ b/drivers/clk/meson/g12a.c @@ -979,7 +979,7 @@ static int meson_clk_probe(struct udevice *dev) { struct meson_clk *priv = dev_get_priv(dev); - priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node); + priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev))); if (IS_ERR(priv->map)) return PTR_ERR(priv->map); @@ -1014,7 +1014,7 @@ U_BOOT_DRIVER(meson_clk_g12a) = { .name = "meson_clk_g12a", .id = UCLASS_CLK, .of_match = meson_clk_ids, - .priv_auto_alloc_size = sizeof(struct meson_clk), + .priv_auto = sizeof(struct meson_clk), .ops = &meson_clk_ops, .probe = meson_clk_probe, }; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index b9353c053e..e379540dee 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -885,7 +885,7 @@ static int meson_clk_probe(struct udevice *dev) { struct meson_clk *priv = dev_get_priv(dev); - priv->map = syscon_node_to_regmap(dev_get_parent(dev)->node); + priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev))); if (IS_ERR(priv->map)) return PTR_ERR(priv->map); @@ -919,7 +919,7 @@ U_BOOT_DRIVER(meson_clk) = { .name = "meson_clk", .id = UCLASS_CLK, .of_match = meson_clk_ids, - .priv_auto_alloc_size = sizeof(struct meson_clk), + .priv_auto = sizeof(struct meson_clk), .ops = &meson_clk_ops, .probe = meson_clk_probe, }; diff --git a/drivers/clk/mpc83xx_clk.c b/drivers/clk/mpc83xx_clk.c index 8d96ec767a..c5ced1f132 100644 --- a/drivers/clk/mpc83xx_clk.c +++ b/drivers/clk/mpc83xx_clk.c @@ -389,7 +389,7 @@ U_BOOT_DRIVER(mpc83xx_clk) = { .of_match = mpc83xx_clk_match, .ops = &mpc83xx_clk_ops, .probe = mpc83xx_clk_probe, - .priv_auto_alloc_size = sizeof(struct mpc83xx_clk_priv), + .priv_auto = sizeof(struct mpc83xx_clk_priv), .bind = mpc83xx_clk_bind, }; diff --git a/drivers/clk/mtmips/clk-mt7628.c b/drivers/clk/mtmips/clk-mt7628.c index 35780de8c4..4d3ac847d1 100644 --- a/drivers/clk/mtmips/clk-mt7628.c +++ b/drivers/clk/mtmips/clk-mt7628.c @@ -153,6 +153,6 @@ U_BOOT_DRIVER(mt7628_clk) = { .id = UCLASS_CLK, .of_match = mt7628_clk_ids, .probe = mt7628_clk_probe, - .priv_auto_alloc_size = sizeof(struct mt7628_clk_priv), + .priv_auto = sizeof(struct mt7628_clk_priv), .ops = &mt7628_clk_ops, }; diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c index 223da22c1b..0132fcb7e6 100644 --- a/drivers/clk/mvebu/armada-37xx-periph.c +++ b/drivers/clk/mvebu/armada-37xx-periph.c @@ -624,6 +624,6 @@ U_BOOT_DRIVER(armada_37xx_periph_clk) = { .id = UCLASS_CLK, .of_match = armada_37xx_periph_clk_ids, .ops = &armada_37xx_periph_clk_ops, - .priv_auto_alloc_size = sizeof(struct a37xx_periphclk), + .priv_auto = sizeof(struct a37xx_periphclk), .probe = armada_37xx_periph_clk_probe, }; diff --git a/drivers/clk/mvebu/armada-37xx-tbg.c b/drivers/clk/mvebu/armada-37xx-tbg.c index 233926e9b6..b1c0852e89 100644 --- a/drivers/clk/mvebu/armada-37xx-tbg.c +++ b/drivers/clk/mvebu/armada-37xx-tbg.c @@ -150,6 +150,6 @@ U_BOOT_DRIVER(armada_37xx_tbg_clk) = { .id = UCLASS_CLK, .of_match = armada_37xx_tbg_clk_ids, .ops = &armada_37xx_tbg_clk_ops, - .priv_auto_alloc_size = sizeof(struct a37xx_tbgclk), + .priv_auto = sizeof(struct a37xx_tbgclk), .probe = armada_37xx_tbg_clk_probe, }; diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c index 1999c87a33..96ab7fed1f 100644 --- a/drivers/clk/owl/clk_owl.c +++ b/drivers/clk/owl/clk_owl.c @@ -161,6 +161,6 @@ U_BOOT_DRIVER(clk_owl) = { .id = UCLASS_CLK, .of_match = owl_clk_ids, .ops = &owl_clk_ops, - .priv_auto_alloc_size = sizeof(struct owl_clk_priv), + .priv_auto = sizeof(struct owl_clk_priv), .probe = owl_clk_probe, }; diff --git a/drivers/clk/renesas/r8a774a1-cpg-mssr.c b/drivers/clk/renesas/r8a774a1-cpg-mssr.c index 6997054b30..1c54eca6c0 100644 --- a/drivers/clk/renesas/r8a774a1-cpg-mssr.c +++ b/drivers/clk/renesas/r8a774a1-cpg-mssr.c @@ -336,7 +336,7 @@ U_BOOT_DRIVER(clk_r8a774a1) = { .name = "clk_r8a774a1", .id = UCLASS_CLK, .of_match = r8a774a1_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a774b1-cpg-mssr.c b/drivers/clk/renesas/r8a774b1-cpg-mssr.c index 7b6947b5b9..03851d0b5a 100644 --- a/drivers/clk/renesas/r8a774b1-cpg-mssr.c +++ b/drivers/clk/renesas/r8a774b1-cpg-mssr.c @@ -329,7 +329,7 @@ U_BOOT_DRIVER(clk_r8a774b1) = { .name = "clk_r8a774b1", .id = UCLASS_CLK, .of_match = r8a774b1_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a774c0-cpg-mssr.c b/drivers/clk/renesas/r8a774c0-cpg-mssr.c index c9f0f7221d..37a7123f73 100644 --- a/drivers/clk/renesas/r8a774c0-cpg-mssr.c +++ b/drivers/clk/renesas/r8a774c0-cpg-mssr.c @@ -301,7 +301,7 @@ U_BOOT_DRIVER(clk_r8a774c0) = { .name = "clk_r8a774c0", .id = UCLASS_CLK, .of_match = r8a774c0_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a774e1-cpg-mssr.c b/drivers/clk/renesas/r8a774e1-cpg-mssr.c index 6cce007aa1..c969ec6888 100644 --- a/drivers/clk/renesas/r8a774e1-cpg-mssr.c +++ b/drivers/clk/renesas/r8a774e1-cpg-mssr.c @@ -351,7 +351,7 @@ U_BOOT_DRIVER(clk_r8a774e1) = { .name = "clk_r8a774e1", .id = UCLASS_CLK, .of_match = r8a774e1_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a7790-cpg-mssr.c b/drivers/clk/renesas/r8a7790-cpg-mssr.c index 7451f53ba3..09e7dbd3a3 100644 --- a/drivers/clk/renesas/r8a7790-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7790-cpg-mssr.c @@ -283,7 +283,7 @@ U_BOOT_DRIVER(clk_r8a7790) = { .name = "clk_r8a7790", .id = UCLASS_CLK, .of_match = r8a7790_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen2_clk_priv), + .priv_auto = sizeof(struct gen2_clk_priv), .ops = &gen2_clk_ops, .probe = gen2_clk_probe, .remove = gen2_clk_remove, diff --git a/drivers/clk/renesas/r8a7791-cpg-mssr.c b/drivers/clk/renesas/r8a7791-cpg-mssr.c index 25fd489609..675ac83a61 100644 --- a/drivers/clk/renesas/r8a7791-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7791-cpg-mssr.c @@ -289,7 +289,7 @@ U_BOOT_DRIVER(clk_r8a7791) = { .name = "clk_r8a7791", .id = UCLASS_CLK, .of_match = r8a7791_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen2_clk_priv), + .priv_auto = sizeof(struct gen2_clk_priv), .ops = &gen2_clk_ops, .probe = gen2_clk_probe, .remove = gen2_clk_remove, diff --git a/drivers/clk/renesas/r8a7792-cpg-mssr.c b/drivers/clk/renesas/r8a7792-cpg-mssr.c index d47ab99e88..d2225a3ff5 100644 --- a/drivers/clk/renesas/r8a7792-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7792-cpg-mssr.c @@ -235,7 +235,7 @@ U_BOOT_DRIVER(clk_r8a7792) = { .name = "clk_r8a7792", .id = UCLASS_CLK, .of_match = r8a7792_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen2_clk_priv), + .priv_auto = sizeof(struct gen2_clk_priv), .ops = &gen2_clk_ops, .probe = gen2_clk_probe, .remove = gen2_clk_remove, diff --git a/drivers/clk/renesas/r8a7794-cpg-mssr.c b/drivers/clk/renesas/r8a7794-cpg-mssr.c index 7093e0d42c..1fcac9b59d 100644 --- a/drivers/clk/renesas/r8a7794-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7794-cpg-mssr.c @@ -264,7 +264,7 @@ U_BOOT_DRIVER(clk_r8a7794) = { .name = "clk_r8a7794", .id = UCLASS_CLK, .of_match = r8a7794_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen2_clk_priv), + .priv_auto = sizeof(struct gen2_clk_priv), .ops = &gen2_clk_ops, .probe = gen2_clk_probe, .remove = gen2_clk_remove, diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c index dcd96ad017..101f6583fa 100644 --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c @@ -373,7 +373,7 @@ U_BOOT_DRIVER(clk_r8a7795) = { .name = "clk_r8a7795", .id = UCLASS_CLK, .of_match = r8a7795_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a7796-cpg-mssr.c b/drivers/clk/renesas/r8a7796-cpg-mssr.c index 89dc141239..3c17bcbb18 100644 --- a/drivers/clk/renesas/r8a7796-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7796-cpg-mssr.c @@ -351,7 +351,7 @@ U_BOOT_DRIVER(clk_r8a7796) = { .name = "clk_r8a7796", .id = UCLASS_CLK, .of_match = r8a7796_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a77965-cpg-mssr.c b/drivers/clk/renesas/r8a77965-cpg-mssr.c index 6ed88295c9..5f37f6285f 100644 --- a/drivers/clk/renesas/r8a77965-cpg-mssr.c +++ b/drivers/clk/renesas/r8a77965-cpg-mssr.c @@ -349,7 +349,7 @@ U_BOOT_DRIVER(clk_r8a77965) = { .name = "clk_r8a77965", .id = UCLASS_CLK, .of_match = r8a77965_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a77970-cpg-mssr.c b/drivers/clk/renesas/r8a77970-cpg-mssr.c index df07120171..bafe4bbb09 100644 --- a/drivers/clk/renesas/r8a77970-cpg-mssr.c +++ b/drivers/clk/renesas/r8a77970-cpg-mssr.c @@ -226,7 +226,7 @@ U_BOOT_DRIVER(clk_r8a77970) = { .name = "clk_r8a77970", .id = UCLASS_CLK, .of_match = r8a77970_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a77980-cpg-mssr.c b/drivers/clk/renesas/r8a77980-cpg-mssr.c index c8d7a9469b..a202005121 100644 --- a/drivers/clk/renesas/r8a77980-cpg-mssr.c +++ b/drivers/clk/renesas/r8a77980-cpg-mssr.c @@ -249,7 +249,7 @@ U_BOOT_DRIVER(clk_r8a77980) = { .name = "clk_r8a77980", .id = UCLASS_CLK, .of_match = r8a77980_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a77990-cpg-mssr.c b/drivers/clk/renesas/r8a77990-cpg-mssr.c index 357e7b534d..5cc9270869 100644 --- a/drivers/clk/renesas/r8a77990-cpg-mssr.c +++ b/drivers/clk/renesas/r8a77990-cpg-mssr.c @@ -308,7 +308,7 @@ U_BOOT_DRIVER(clk_r8a77990) = { .name = "clk_r8a77990", .id = UCLASS_CLK, .of_match = r8a77990_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/renesas/r8a77995-cpg-mssr.c b/drivers/clk/renesas/r8a77995-cpg-mssr.c index d62aeba635..eef154bc82 100644 --- a/drivers/clk/renesas/r8a77995-cpg-mssr.c +++ b/drivers/clk/renesas/r8a77995-cpg-mssr.c @@ -247,7 +247,7 @@ U_BOOT_DRIVER(clk_r8a77995) = { .name = "clk_r8a77995", .id = UCLASS_CLK, .of_match = r8a77995_clk_ids, - .priv_auto_alloc_size = sizeof(struct gen3_clk_priv), + .priv_auto = sizeof(struct gen3_clk_priv), .ops = &gen3_clk_ops, .probe = gen3_clk_probe, .remove = gen3_clk_remove, diff --git a/drivers/clk/rockchip/clk_px30.c b/drivers/clk/rockchip/clk_px30.c index 71916dbf3b..a2a5939d4b 100644 --- a/drivers/clk/rockchip/clk_px30.c +++ b/drivers/clk/rockchip/clk_px30.c @@ -15,6 +15,7 @@ #include <asm/arch-rockchip/cru_px30.h> #include <asm/arch-rockchip/hardware.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/px30-cru.h> #include <linux/bitops.h> @@ -1432,7 +1433,7 @@ static int px30_clk_probe(struct udevice *dev) return 0; } -static int px30_clk_ofdata_to_platdata(struct udevice *dev) +static int px30_clk_of_to_plat(struct udevice *dev) { struct px30_clk_priv *priv = dev_get_priv(dev); @@ -1458,7 +1459,7 @@ static int px30_clk_bind(struct udevice *dev) glb_srst_fst); priv->glb_srst_snd_value = offsetof(struct px30_cru, glb_srst_snd); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -1480,8 +1481,8 @@ U_BOOT_DRIVER(rockchip_px30_cru) = { .name = "rockchip_px30_cru", .id = UCLASS_CLK, .of_match = px30_clk_ids, - .priv_auto_alloc_size = sizeof(struct px30_clk_priv), - .ofdata_to_platdata = px30_clk_ofdata_to_platdata, + .priv_auto = sizeof(struct px30_clk_priv), + .of_to_plat = px30_clk_of_to_plat, .ops = &px30_clk_ops, .bind = px30_clk_bind, .probe = px30_clk_probe, @@ -1609,7 +1610,7 @@ static int px30_pmuclk_probe(struct udevice *dev) return 0; } -static int px30_pmuclk_ofdata_to_platdata(struct udevice *dev) +static int px30_pmuclk_of_to_plat(struct udevice *dev) { struct px30_pmuclk_priv *priv = dev_get_priv(dev); @@ -1627,8 +1628,8 @@ U_BOOT_DRIVER(rockchip_px30_pmucru) = { .name = "rockchip_px30_pmucru", .id = UCLASS_CLK, .of_match = px30_pmuclk_ids, - .priv_auto_alloc_size = sizeof(struct px30_pmuclk_priv), - .ofdata_to_platdata = px30_pmuclk_ofdata_to_platdata, + .priv_auto = sizeof(struct px30_pmuclk_priv), + .of_to_plat = px30_pmuclk_of_to_plat, .ops = &px30_pmuclk_ops, .probe = px30_pmuclk_probe, }; diff --git a/drivers/clk/rockchip/clk_rk3036.c b/drivers/clk/rockchip/clk_rk3036.c index 274572f70c..026858459e 100644 --- a/drivers/clk/rockchip/clk_rk3036.c +++ b/drivers/clk/rockchip/clk_rk3036.c @@ -14,6 +14,7 @@ #include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk3036.h> #include <asm/arch-rockchip/hardware.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rk3036-cru.h> #include <linux/delay.h> @@ -318,7 +319,7 @@ static struct clk_ops rk3036_clk_ops = { .set_rate = rk3036_clk_set_rate, }; -static int rk3036_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3036_clk_of_to_plat(struct udevice *dev) { struct rk3036_clk_priv *priv = dev_get_priv(dev); @@ -353,7 +354,7 @@ static int rk3036_clk_bind(struct udevice *dev) cru_glb_srst_fst_value); priv->glb_srst_snd_value = offsetof(struct rk3036_cru, cru_glb_srst_snd_value); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -375,8 +376,8 @@ U_BOOT_DRIVER(rockchip_rk3036_cru) = { .name = "clk_rk3036", .id = UCLASS_CLK, .of_match = rk3036_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3036_clk_priv), - .ofdata_to_platdata = rk3036_clk_ofdata_to_platdata, + .priv_auto = sizeof(struct rk3036_clk_priv), + .of_to_plat = rk3036_clk_of_to_plat, .ops = &rk3036_clk_ops, .bind = rk3036_clk_bind, .probe = rk3036_clk_probe, diff --git a/drivers/clk/rockchip/clk_rk3128.c b/drivers/clk/rockchip/clk_rk3128.c index 61f823e254..d5b2b63dd7 100644 --- a/drivers/clk/rockchip/clk_rk3128.c +++ b/drivers/clk/rockchip/clk_rk3128.c @@ -15,6 +15,7 @@ #include <asm/arch-rockchip/cru_rk3128.h> #include <asm/arch-rockchip/hardware.h> #include <bitfield.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rk3128-cru.h> #include <linux/delay.h> @@ -546,7 +547,7 @@ static struct clk_ops rk3128_clk_ops = { .set_rate = rk3128_clk_set_rate, }; -static int rk3128_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3128_clk_of_to_plat(struct udevice *dev) { struct rk3128_clk_priv *priv = dev_get_priv(dev); @@ -581,7 +582,7 @@ static int rk3128_clk_bind(struct udevice *dev) cru_glb_srst_fst_value); priv->glb_srst_snd_value = offsetof(struct rk3128_cru, cru_glb_srst_snd_value); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } return 0; @@ -597,8 +598,8 @@ U_BOOT_DRIVER(rockchip_rk3128_cru) = { .name = "clk_rk3128", .id = UCLASS_CLK, .of_match = rk3128_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3128_clk_priv), - .ofdata_to_platdata = rk3128_clk_ofdata_to_platdata, + .priv_auto = sizeof(struct rk3128_clk_priv), + .of_to_plat = rk3128_clk_of_to_plat, .ops = &rk3128_clk_ops, .bind = rk3128_clk_bind, .probe = rk3128_clk_probe, diff --git a/drivers/clk/rockchip/clk_rk3188.c b/drivers/clk/rockchip/clk_rk3188.c index aacc8cf2d1..1b62d8d289 100644 --- a/drivers/clk/rockchip/clk_rk3188.c +++ b/drivers/clk/rockchip/clk_rk3188.c @@ -538,7 +538,7 @@ static struct clk_ops rk3188_clk_ops = { .set_rate = rk3188_clk_set_rate, }; -static int rk3188_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3188_clk_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3188_clk_priv *priv = dev_get_priv(dev); @@ -561,7 +561,7 @@ static int rk3188_clk_probe(struct udevice *dev) #ifdef CONFIG_SPL_BUILD #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3188_clk_plat *plat = dev_get_platdata(dev); + struct rk3188_clk_plat *plat = dev_get_plat(dev); priv->cru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]); #endif @@ -593,7 +593,7 @@ static int rk3188_clk_bind(struct udevice *dev) cru_glb_srst_fst_value); priv->glb_srst_snd_value = offsetof(struct rk3188_cru, cru_glb_srst_snd_value); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -616,10 +616,10 @@ U_BOOT_DRIVER(rockchip_rk3188_cru) = { .name = "rockchip_rk3188_cru", .id = UCLASS_CLK, .of_match = rk3188_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3188_clk_priv), - .platdata_auto_alloc_size = sizeof(struct rk3188_clk_plat), + .priv_auto = sizeof(struct rk3188_clk_priv), + .plat_auto = sizeof(struct rk3188_clk_plat), .ops = &rk3188_clk_ops, .bind = rk3188_clk_bind, - .ofdata_to_platdata = rk3188_clk_ofdata_to_platdata, + .of_to_plat = rk3188_clk_of_to_plat, .probe = rk3188_clk_probe, }; diff --git a/drivers/clk/rockchip/clk_rk322x.c b/drivers/clk/rockchip/clk_rk322x.c index 054b2fd349..dbef606d88 100644 --- a/drivers/clk/rockchip/clk_rk322x.c +++ b/drivers/clk/rockchip/clk_rk322x.c @@ -14,6 +14,7 @@ #include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rk322x.h> #include <asm/arch-rockchip/hardware.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rk3228-cru.h> #include <linux/bitops.h> @@ -475,7 +476,7 @@ static struct clk_ops rk322x_clk_ops = { .set_parent = rk322x_clk_set_parent, }; -static int rk322x_clk_ofdata_to_platdata(struct udevice *dev) +static int rk322x_clk_of_to_plat(struct udevice *dev) { struct rk322x_clk_priv *priv = dev_get_priv(dev); @@ -510,7 +511,7 @@ static int rk322x_clk_bind(struct udevice *dev) cru_glb_srst_fst_value); priv->glb_srst_snd_value = offsetof(struct rk322x_cru, cru_glb_srst_snd_value); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -532,8 +533,8 @@ U_BOOT_DRIVER(rockchip_rk322x_cru) = { .name = "clk_rk322x", .id = UCLASS_CLK, .of_match = rk322x_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk322x_clk_priv), - .ofdata_to_platdata = rk322x_clk_ofdata_to_platdata, + .priv_auto = sizeof(struct rk322x_clk_priv), + .of_to_plat = rk322x_clk_of_to_plat, .ops = &rk322x_clk_ops, .bind = rk322x_clk_bind, .probe = rk322x_clk_probe, diff --git a/drivers/clk/rockchip/clk_rk3288.c b/drivers/clk/rockchip/clk_rk3288.c index a1dd642eef..6226d55658 100644 --- a/drivers/clk/rockchip/clk_rk3288.c +++ b/drivers/clk/rockchip/clk_rk3288.c @@ -954,7 +954,7 @@ static struct clk_ops rk3288_clk_ops = { #endif }; -static int rk3288_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3288_clk_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3288_clk_priv *priv = dev_get_priv(dev); @@ -975,7 +975,7 @@ static int rk3288_clk_probe(struct udevice *dev) return PTR_ERR(priv->grf); #ifdef CONFIG_SPL_BUILD #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3288_clk_plat *plat = dev_get_platdata(dev); + struct rk3288_clk_plat *plat = dev_get_plat(dev); priv->cru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]); #endif @@ -1018,7 +1018,7 @@ static int rk3288_clk_bind(struct udevice *dev) cru_glb_srst_fst_value); priv->glb_srst_snd_value = offsetof(struct rockchip_cru, cru_glb_srst_snd_value); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -1040,10 +1040,10 @@ U_BOOT_DRIVER(rockchip_rk3288_cru) = { .name = "rockchip_rk3288_cru", .id = UCLASS_CLK, .of_match = rk3288_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3288_clk_priv), - .platdata_auto_alloc_size = sizeof(struct rk3288_clk_plat), + .priv_auto = sizeof(struct rk3288_clk_priv), + .plat_auto = sizeof(struct rk3288_clk_plat), .ops = &rk3288_clk_ops, .bind = rk3288_clk_bind, - .ofdata_to_platdata = rk3288_clk_ofdata_to_platdata, + .of_to_plat = rk3288_clk_of_to_plat, .probe = rk3288_clk_probe, }; diff --git a/drivers/clk/rockchip/clk_rk3308.c b/drivers/clk/rockchip/clk_rk3308.c index d3633b6979..a05efcfbab 100644 --- a/drivers/clk/rockchip/clk_rk3308.c +++ b/drivers/clk/rockchip/clk_rk3308.c @@ -15,6 +15,7 @@ #include <asm/arch/cru_rk3308.h> #include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/hardware.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rk3308-cru.h> #include <linux/bitops.h> @@ -1019,7 +1020,7 @@ static int rk3308_clk_probe(struct udevice *dev) return ret; } -static int rk3308_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3308_clk_of_to_plat(struct udevice *dev) { struct rk3308_clk_priv *priv = dev_get_priv(dev); @@ -1045,7 +1046,7 @@ static int rk3308_clk_bind(struct udevice *dev) glb_srst_fst); priv->glb_srst_snd_value = offsetof(struct rk3308_cru, glb_srst_snd); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -1067,8 +1068,8 @@ U_BOOT_DRIVER(rockchip_rk3308_cru) = { .name = "rockchip_rk3308_cru", .id = UCLASS_CLK, .of_match = rk3308_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3308_clk_priv), - .ofdata_to_platdata = rk3308_clk_ofdata_to_platdata, + .priv_auto = sizeof(struct rk3308_clk_priv), + .of_to_plat = rk3308_clk_of_to_plat, .ops = &rk3308_clk_ops, .bind = rk3308_clk_bind, .probe = rk3308_clk_probe, diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c index bf4f1069ea..b825ff4cf8 100644 --- a/drivers/clk/rockchip/clk_rk3328.c +++ b/drivers/clk/rockchip/clk_rk3328.c @@ -16,6 +16,7 @@ #include <asm/arch-rockchip/hardware.h> #include <asm/arch-rockchip/grf_rk3328.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rk3328-cru.h> #include <linux/bitops.h> @@ -797,7 +798,7 @@ static int rk3328_clk_probe(struct udevice *dev) return 0; } -static int rk3328_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3328_clk_of_to_plat(struct udevice *dev) { struct rk3328_clk_priv *priv = dev_get_priv(dev); @@ -823,7 +824,7 @@ static int rk3328_clk_bind(struct udevice *dev) glb_srst_fst_value); priv->glb_srst_snd_value = offsetof(struct rk3328_cru, glb_srst_snd_value); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -845,8 +846,8 @@ U_BOOT_DRIVER(rockchip_rk3328_cru) = { .name = "rockchip_rk3328_cru", .id = UCLASS_CLK, .of_match = rk3328_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3328_clk_priv), - .ofdata_to_platdata = rk3328_clk_ofdata_to_platdata, + .priv_auto = sizeof(struct rk3328_clk_priv), + .of_to_plat = rk3328_clk_of_to_plat, .ops = &rk3328_clk_ops, .bind = rk3328_clk_bind, .probe = rk3328_clk_probe, diff --git a/drivers/clk/rockchip/clk_rk3368.c b/drivers/clk/rockchip/clk_rk3368.c index d1804c6e16..780b49ccd8 100644 --- a/drivers/clk/rockchip/clk_rk3368.c +++ b/drivers/clk/rockchip/clk_rk3368.c @@ -19,6 +19,7 @@ #include <asm/arch-rockchip/cru_rk3368.h> #include <asm/arch-rockchip/hardware.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rk3368-cru.h> #include <linux/delay.h> @@ -582,7 +583,7 @@ static int rk3368_clk_probe(struct udevice *dev) { struct rk3368_clk_priv __maybe_unused *priv = dev_get_priv(dev); #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3368_clk_plat *plat = dev_get_platdata(dev); + struct rk3368_clk_plat *plat = dev_get_plat(dev); priv->cru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]); #endif @@ -593,7 +594,7 @@ static int rk3368_clk_probe(struct udevice *dev) return 0; } -static int rk3368_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3368_clk_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3368_clk_priv *priv = dev_get_priv(dev); @@ -621,7 +622,7 @@ static int rk3368_clk_bind(struct udevice *dev) glb_srst_fst_val); priv->glb_srst_snd_value = offsetof(struct rk3368_cru, glb_srst_snd_val); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -643,11 +644,11 @@ U_BOOT_DRIVER(rockchip_rk3368_cru) = { .name = "rockchip_rk3368_cru", .id = UCLASS_CLK, .of_match = rk3368_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3368_clk_priv), + .priv_auto = sizeof(struct rk3368_clk_priv), #if CONFIG_IS_ENABLED(OF_PLATDATA) - .platdata_auto_alloc_size = sizeof(struct rk3368_clk_plat), + .plat_auto = sizeof(struct rk3368_clk_plat), #endif - .ofdata_to_platdata = rk3368_clk_ofdata_to_platdata, + .of_to_plat = rk3368_clk_of_to_plat, .ops = &rk3368_clk_ops, .bind = rk3368_clk_bind, .probe = rk3368_clk_probe, diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index 3fd863e7bd..55ebac7057 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -18,6 +18,7 @@ #include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru.h> #include <asm/arch-rockchip/hardware.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rk3399-cru.h> #include <linux/bitops.h> @@ -1378,7 +1379,7 @@ static int rk3399_clk_probe(struct udevice *dev) bool init_clocks = false; #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3399_clk_plat *plat = dev_get_platdata(dev); + struct rk3399_clk_plat *plat = dev_get_plat(dev); priv->cru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]); #endif @@ -1398,7 +1399,7 @@ static int rk3399_clk_probe(struct udevice *dev) return 0; } -static int rk3399_clk_ofdata_to_platdata(struct udevice *dev) +static int rk3399_clk_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3399_clk_priv *priv = dev_get_priv(dev); @@ -1425,7 +1426,7 @@ static int rk3399_clk_bind(struct udevice *dev) glb_srst_fst_value); priv->glb_srst_snd_value = offsetof(struct rockchip_cru, glb_srst_snd_value); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -1447,13 +1448,13 @@ U_BOOT_DRIVER(clk_rk3399) = { .name = "rockchip_rk3399_cru", .id = UCLASS_CLK, .of_match = rk3399_clk_ids, - .priv_auto_alloc_size = sizeof(struct rk3399_clk_priv), - .ofdata_to_platdata = rk3399_clk_ofdata_to_platdata, + .priv_auto = sizeof(struct rk3399_clk_priv), + .of_to_plat = rk3399_clk_of_to_plat, .ops = &rk3399_clk_ops, .bind = rk3399_clk_bind, .probe = rk3399_clk_probe, #if CONFIG_IS_ENABLED(OF_PLATDATA) - .platdata_auto_alloc_size = sizeof(struct rk3399_clk_plat), + .plat_auto = sizeof(struct rk3399_clk_plat), #endif }; @@ -1599,7 +1600,7 @@ static int rk3399_pmuclk_probe(struct udevice *dev) #endif #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3399_pmuclk_plat *plat = dev_get_platdata(dev); + struct rk3399_pmuclk_plat *plat = dev_get_plat(dev); priv->pmucru = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]); #endif @@ -1610,7 +1611,7 @@ static int rk3399_pmuclk_probe(struct udevice *dev) return 0; } -static int rk3399_pmuclk_ofdata_to_platdata(struct udevice *dev) +static int rk3399_pmuclk_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3399_pmuclk_priv *priv = dev_get_priv(dev); @@ -1642,12 +1643,12 @@ U_BOOT_DRIVER(rockchip_rk3399_pmuclk) = { .name = "rockchip_rk3399_pmucru", .id = UCLASS_CLK, .of_match = rk3399_pmuclk_ids, - .priv_auto_alloc_size = sizeof(struct rk3399_pmuclk_priv), - .ofdata_to_platdata = rk3399_pmuclk_ofdata_to_platdata, + .priv_auto = sizeof(struct rk3399_pmuclk_priv), + .of_to_plat = rk3399_pmuclk_of_to_plat, .ops = &rk3399_pmuclk_ops, .probe = rk3399_pmuclk_probe, .bind = rk3399_pmuclk_bind, #if CONFIG_IS_ENABLED(OF_PLATDATA) - .platdata_auto_alloc_size = sizeof(struct rk3399_pmuclk_plat), + .plat_auto = sizeof(struct rk3399_pmuclk_plat), #endif }; diff --git a/drivers/clk/rockchip/clk_rv1108.c b/drivers/clk/rockchip/clk_rv1108.c index aa1d98ca2a..1e22db0cb7 100644 --- a/drivers/clk/rockchip/clk_rv1108.c +++ b/drivers/clk/rockchip/clk_rv1108.c @@ -16,6 +16,7 @@ #include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/cru_rv1108.h> #include <asm/arch-rockchip/hardware.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dt-bindings/clock/rv1108-cru.h> #include <linux/delay.h> @@ -662,7 +663,7 @@ static void rkclk_init(struct rv1108_cru *cru) aclk_bus, aclk_peri, hclk_peri, pclk_peri); } -static int rv1108_clk_ofdata_to_platdata(struct udevice *dev) +static int rv1108_clk_of_to_plat(struct udevice *dev) { struct rv1108_clk_priv *priv = dev_get_priv(dev); @@ -697,7 +698,7 @@ static int rv1108_clk_bind(struct udevice *dev) glb_srst_fst_val); priv->glb_srst_snd_value = offsetof(struct rv1108_cru, glb_srst_snd_val); - sys_child->priv = priv; + dev_set_priv(sys_child, priv); } #if CONFIG_IS_ENABLED(RESET_ROCKCHIP) @@ -719,9 +720,9 @@ U_BOOT_DRIVER(clk_rv1108) = { .name = "clk_rv1108", .id = UCLASS_CLK, .of_match = rv1108_clk_ids, - .priv_auto_alloc_size = sizeof(struct rv1108_clk_priv), + .priv_auto = sizeof(struct rv1108_clk_priv), .ops = &rv1108_clk_ops, .bind = rv1108_clk_bind, - .ofdata_to_platdata = rv1108_clk_ofdata_to_platdata, + .of_to_plat = rv1108_clk_of_to_plat, .probe = rv1108_clk_probe, }; diff --git a/drivers/clk/sifive/fu540-prci.c b/drivers/clk/sifive/fu540-prci.c index 1b4d81d4f0..b3882d0b77 100644 --- a/drivers/clk/sifive/fu540-prci.c +++ b/drivers/clk/sifive/fu540-prci.c @@ -537,7 +537,7 @@ static int __prci_consumer_reset(const char *rst_name, bool trigger) int ret; ret = uclass_get_device_by_driver(UCLASS_RESET, - DM_GET_DRIVER(sifive_reset), + DM_DRIVER_GET(sifive_reset), &dev); if (ret) { dev_err(dev, "Reset driver not found: %d\n", ret); @@ -807,6 +807,6 @@ U_BOOT_DRIVER(sifive_fu540_prci) = { .of_match = sifive_fu540_prci_ids, .probe = sifive_fu540_prci_probe, .ops = &sifive_fu540_prci_ops, - .priv_auto_alloc_size = sizeof(struct __prci_data), + .priv_auto = sizeof(struct __prci_data), .bind = sifive_fu540_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index 67507c5ab1..1b5de86e20 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -79,7 +79,7 @@ U_BOOT_DRIVER(clk_sun4i_a10) = { .name = "sun4i_a10_ccu", .id = UCLASS_CLK, .of_match = a10_ccu_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = a10_clk_bind, diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index d11a4b5f03..184f61ab23 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -66,7 +66,7 @@ U_BOOT_DRIVER(clk_sun5i_a10s) = { .name = "sun5i_a10s_ccu", .id = UCLASS_CLK, .of_match = a10s_ccu_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = a10s_clk_bind, diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index 4d562bfe42..5750514a74 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -82,7 +82,7 @@ U_BOOT_DRIVER(clk_sun8i_a23) = { .name = "sun8i_a23_ccu", .id = UCLASS_CLK, .of_match = a23_clk_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = a23_clk_bind, diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index 4a9454eebe..9226112f4a 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -99,7 +99,7 @@ U_BOOT_DRIVER(clk_sun6i_a31) = { .name = "sun6i_a31_ccu", .id = UCLASS_CLK, .of_match = a31_clk_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = a31_clk_bind, diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index d96cb1aac1..0553ffa439 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -87,7 +87,7 @@ U_BOOT_DRIVER(clk_sun50i_a64) = { .name = "sun50i_a64_ccu", .id = UCLASS_CLK, .of_match = a64_ccu_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = a64_clk_bind, diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index 80d7407037..68973d528e 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -94,7 +94,7 @@ U_BOOT_DRIVER(clk_sun9i_a80) = { .name = "sun9i_a80_ccu", .id = UCLASS_CLK, .of_match = a80_ccu_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = a80_clk_bind, diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index d6f23ddc77..880c7d7599 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -84,7 +84,7 @@ U_BOOT_DRIVER(clk_sun8i_a83t) = { .name = "sun8i_a83t_ccu", .id = UCLASS_CLK, .of_match = a83t_clk_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = a83t_clk_bind, diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index 7e844f4ff1..f81633b92d 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -102,7 +102,7 @@ U_BOOT_DRIVER(clk_sun8i_h3) = { .name = "sun8i_h3_ccu", .id = UCLASS_CLK, .of_match = h3_ccu_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = h3_clk_bind, diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index a1cb8952d3..ac8656fe89 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -95,7 +95,7 @@ U_BOOT_DRIVER(clk_sun50i_h6) = { .name = "sun50i_h6_ccu", .id = UCLASS_CLK, .of_match = h6_ccu_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = h6_clk_bind, diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index ac360b2beb..ee1e86d22e 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -107,7 +107,7 @@ U_BOOT_DRIVER(clk_sun8i_r40) = { .name = "sun8i_r40_ccu", .id = UCLASS_CLK, .of_match = r40_clk_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = r40_clk_bind, diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index f3fc06ab31..29622199fd 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -65,7 +65,7 @@ U_BOOT_DRIVER(clk_sun8i_v3s) = { .name = "sun8i_v3s_ccu", .id = UCLASS_CLK, .of_match = v3s_clk_ids, - .priv_auto_alloc_size = sizeof(struct ccu_priv), + .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, .bind = v3s_clk_bind, diff --git a/drivers/clk/ti/Kconfig b/drivers/clk/ti/Kconfig new file mode 100644 index 0000000000..2dc86d44a9 --- /dev/null +++ b/drivers/clk/ti/Kconfig @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> +# + +config CLK_TI_AM3_DPLL + bool "TI AM33XX Digital Phase-Locked Loop (DPLL) clock drivers" + depends on CLK && OF_CONTROL + help + This enables the DPLL clock drivers support on AM33XX SoCs. The DPLL + provides all interface clocks and functional clocks to the processor. + +config CLK_TI_CTRL + bool "TI OMAP4 clock controller" + depends on CLK && OF_CONTROL + help + This enables the clock controller driver support on TI's SoCs. + +config CLK_TI_DIVIDER + bool "TI divider clock driver" + depends on CLK && OF_CONTROL && CLK_CCF + help + This enables the divider clock driver support on TI's SoCs. + +config CLK_TI_GATE + bool "TI gate clock driver" + depends on CLK && OF_CONTROL + help + This enables the gate clock driver support on TI's SoCs. + +config CLK_TI_MUX + bool "TI mux clock driver" + depends on CLK && OF_CONTROL && CLK_CCF + help + This enables the mux clock driver support on TI's SoCs. + +config CLK_TI_SCI + bool "TI System Control Interface (TI SCI) clock driver" + depends on CLK && TI_SCI_PROTOCOL && OF_CONTROL + help + This enables the clock driver support over TI System Control Interface + available on some new TI's SoCs. If you wish to use clock resources + managed by the TI System Controller, say Y here. Otherwise, say N. diff --git a/drivers/clk/ti/Makefile b/drivers/clk/ti/Makefile new file mode 100644 index 0000000000..9f56b47736 --- /dev/null +++ b/drivers/clk/ti/Makefile @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> +# + +obj-$(CONFIG_ARCH_OMAP2PLUS) += clk.o omap4-cm.o + +obj-$(CONFIG_CLK_TI_AM3_DPLL) += clk-am3-dpll.o clk-am3-dpll-x2.o +obj-$(CONFIG_CLK_TI_CTRL) += clk-ctrl.o +obj-$(CONFIG_CLK_TI_DIVIDER) += clk-divider.o +obj-$(CONFIG_CLK_TI_GATE) += clk-gate.o +obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o +obj-$(CONFIG_CLK_TI_SCI) += clk-sci.o diff --git a/drivers/clk/ti/clk-am3-dpll-x2.c b/drivers/clk/ti/clk-am3-dpll-x2.c new file mode 100644 index 0000000000..3cf279d6a3 --- /dev/null +++ b/drivers/clk/ti/clk-am3-dpll-x2.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * TI DPLL x2 clock support + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + * + * Loosely based on Linux kernel drivers/clk/ti/dpll.c + */ + +#include <common.h> +#include <clk-uclass.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <linux/clk-provider.h> + +struct clk_ti_am3_dpll_x2_priv { + struct clk parent; +}; + +static ulong clk_ti_am3_dpll_x2_get_rate(struct clk *clk) +{ + struct clk_ti_am3_dpll_x2_priv *priv = dev_get_priv(clk->dev); + unsigned long rate; + + rate = clk_get_rate(&priv->parent); + if (IS_ERR_VALUE(rate)) + return rate; + + rate *= 2; + dev_dbg(clk->dev, "rate=%ld\n", rate); + return rate; +} + +const struct clk_ops clk_ti_am3_dpll_x2_ops = { + .get_rate = clk_ti_am3_dpll_x2_get_rate, +}; + +static int clk_ti_am3_dpll_x2_remove(struct udevice *dev) +{ + struct clk_ti_am3_dpll_x2_priv *priv = dev_get_priv(dev); + int err; + + err = clk_release_all(&priv->parent, 1); + if (err) { + dev_err(dev, "failed to release parent clock\n"); + return err; + } + + return 0; +} + +static int clk_ti_am3_dpll_x2_probe(struct udevice *dev) +{ + struct clk_ti_am3_dpll_x2_priv *priv = dev_get_priv(dev); + int err; + + err = clk_get_by_index(dev, 0, &priv->parent); + if (err) { + dev_err(dev, "%s: failed to get parent clock\n", __func__); + return err; + } + + return 0; +} + +static const struct udevice_id clk_ti_am3_dpll_x2_of_match[] = { + {.compatible = "ti,am3-dpll-x2-clock"}, + {} +}; + +U_BOOT_DRIVER(clk_ti_am3_dpll_x2) = { + .name = "ti_am3_dpll_x2_clock", + .id = UCLASS_CLK, + .of_match = clk_ti_am3_dpll_x2_of_match, + .probe = clk_ti_am3_dpll_x2_probe, + .remove = clk_ti_am3_dpll_x2_remove, + .priv_auto = sizeof(struct clk_ti_am3_dpll_x2_priv), + .ops = &clk_ti_am3_dpll_x2_ops, +}; diff --git a/drivers/clk/ti/clk-am3-dpll.c b/drivers/clk/ti/clk-am3-dpll.c new file mode 100644 index 0000000000..7916a24538 --- /dev/null +++ b/drivers/clk/ti/clk-am3-dpll.c @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * TI DPLL clock support + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + * + * Loosely based on Linux kernel drivers/clk/ti/dpll.c + */ + +#include <common.h> +#include <clk.h> +#include <clk-uclass.h> +#include <div64.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <hang.h> +#include <asm/arch/clock.h> +#include <asm/arch/sys_proto.h> +#include <asm/io.h> + +struct clk_ti_am3_dpll_drv_data { + ulong max_rate; +}; + +struct clk_ti_am3_dpll_priv { + fdt_addr_t clkmode_reg; + fdt_addr_t idlest_reg; + fdt_addr_t clksel_reg; + struct clk clk_bypass; + struct clk clk_ref; + u16 last_rounded_mult; + u8 last_rounded_div; + ulong max_rate; +}; + +static ulong clk_ti_am3_dpll_round_rate(struct clk *clk, ulong rate) +{ + struct clk_ti_am3_dpll_priv *priv = dev_get_priv(clk->dev); + ulong ret, ref_rate, r; + int m, d, err_min, err; + int mult = INT_MAX, div = INT_MAX; + + if (priv->max_rate && rate > priv->max_rate) { + dev_warn(clk->dev, "%ld is to high a rate, lowered to %ld\n", + rate, priv->max_rate); + rate = priv->max_rate; + } + + ret = -EFAULT; + err = rate; + err_min = rate; + ref_rate = clk_get_rate(&priv->clk_ref); + for (d = 1; err_min && d <= 128; d++) { + for (m = 2; m <= 2047; m++) { + r = (ref_rate * m) / d; + err = abs(r - rate); + if (err < err_min) { + err_min = err; + ret = r; + mult = m; + div = d; + + if (err == 0) + break; + } else if (r > rate) { + break; + } + } + } + + priv->last_rounded_mult = mult; + priv->last_rounded_div = div; + dev_dbg(clk->dev, "rate=%ld, best_rate=%ld, mult=%d, div=%d\n", rate, + ret, mult, div); + return ret; +} + +static ulong clk_ti_am3_dpll_set_rate(struct clk *clk, ulong rate) +{ + struct clk_ti_am3_dpll_priv *priv = dev_get_priv(clk->dev); + u32 v; + ulong round_rate; + + round_rate = clk_ti_am3_dpll_round_rate(clk, rate); + if (IS_ERR_VALUE(round_rate)) + return round_rate; + + v = readl(priv->clksel_reg); + + /* enter bypass mode */ + clrsetbits_le32(priv->clkmode_reg, CM_CLKMODE_DPLL_DPLL_EN_MASK, + DPLL_EN_MN_BYPASS << CM_CLKMODE_DPLL_EN_SHIFT); + + /* wait for bypass mode */ + if (!wait_on_value(ST_DPLL_CLK_MASK, 0, + (void *)priv->idlest_reg, LDELAY)) + dev_err(clk->dev, "failed bypassing dpll\n"); + + /* set M & N */ + v &= ~CM_CLKSEL_DPLL_M_MASK; + v |= (priv->last_rounded_mult << CM_CLKSEL_DPLL_M_SHIFT) & + CM_CLKSEL_DPLL_M_MASK; + + v &= ~CM_CLKSEL_DPLL_N_MASK; + v |= ((priv->last_rounded_div - 1) << CM_CLKSEL_DPLL_N_SHIFT) & + CM_CLKSEL_DPLL_N_MASK; + + writel(v, priv->clksel_reg); + + /* lock dpll */ + clrsetbits_le32(priv->clkmode_reg, CM_CLKMODE_DPLL_DPLL_EN_MASK, + DPLL_EN_LOCK << CM_CLKMODE_DPLL_EN_SHIFT); + + /* wait till the dpll locks */ + if (!wait_on_value(ST_DPLL_CLK_MASK, ST_DPLL_CLK_MASK, + (void *)priv->idlest_reg, LDELAY)) { + dev_err(clk->dev, "failed locking dpll\n"); + hang(); + } + + return round_rate; +} + +static ulong clk_ti_am3_dpll_get_rate(struct clk *clk) +{ + struct clk_ti_am3_dpll_priv *priv = dev_get_priv(clk->dev); + u64 rate; + u32 m, n, v; + + /* Return bypass rate if DPLL is bypassed */ + v = readl(priv->clkmode_reg); + v &= CM_CLKMODE_DPLL_EN_MASK; + v >>= CM_CLKMODE_DPLL_EN_SHIFT; + + switch (v) { + case DPLL_EN_MN_BYPASS: + case DPLL_EN_LOW_POWER_BYPASS: + case DPLL_EN_FAST_RELOCK_BYPASS: + rate = clk_get_rate(&priv->clk_bypass); + dev_dbg(clk->dev, "rate=%lld\n", rate); + return rate; + } + + v = readl(priv->clksel_reg); + m = v & CM_CLKSEL_DPLL_M_MASK; + m >>= CM_CLKSEL_DPLL_M_SHIFT; + n = v & CM_CLKSEL_DPLL_N_MASK; + n >>= CM_CLKSEL_DPLL_N_SHIFT; + + rate = clk_get_rate(&priv->clk_ref) * m; + do_div(rate, n + 1); + dev_dbg(clk->dev, "rate=%lld\n", rate); + return rate; +} + +const struct clk_ops clk_ti_am3_dpll_ops = { + .round_rate = clk_ti_am3_dpll_round_rate, + .get_rate = clk_ti_am3_dpll_get_rate, + .set_rate = clk_ti_am3_dpll_set_rate, +}; + +static int clk_ti_am3_dpll_remove(struct udevice *dev) +{ + struct clk_ti_am3_dpll_priv *priv = dev_get_priv(dev); + int err; + + err = clk_release_all(&priv->clk_bypass, 1); + if (err) { + dev_err(dev, "failed to release bypass clock\n"); + return err; + } + + err = clk_release_all(&priv->clk_ref, 1); + if (err) { + dev_err(dev, "failed to release reference clock\n"); + return err; + } + + return 0; +} + +static int clk_ti_am3_dpll_probe(struct udevice *dev) +{ + struct clk_ti_am3_dpll_priv *priv = dev_get_priv(dev); + int err; + + err = clk_get_by_index(dev, 0, &priv->clk_ref); + if (err) { + dev_err(dev, "failed to get reference clock\n"); + return err; + } + + err = clk_get_by_index(dev, 1, &priv->clk_bypass); + if (err) { + dev_err(dev, "failed to get bypass clock\n"); + return err; + } + + return 0; +} + +static int clk_ti_am3_dpll_of_to_plat(struct udevice *dev) +{ + struct clk_ti_am3_dpll_priv *priv = dev_get_priv(dev); + struct clk_ti_am3_dpll_drv_data *data = + (struct clk_ti_am3_dpll_drv_data *)dev_get_driver_data(dev); + + priv->max_rate = data->max_rate; + + priv->clkmode_reg = dev_read_addr_index(dev, 0); + if (priv->clkmode_reg == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get clkmode register\n"); + return -EINVAL; + } + + dev_dbg(dev, "clkmode_reg=0x%08lx\n", priv->clkmode_reg); + + priv->idlest_reg = dev_read_addr_index(dev, 1); + if (priv->idlest_reg == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get idlest register\n"); + return -EINVAL; + } + + dev_dbg(dev, "idlest_reg=0x%08lx\n", priv->idlest_reg); + + priv->clksel_reg = dev_read_addr_index(dev, 2); + if (priv->clksel_reg == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get clksel register\n"); + return -EINVAL; + } + + dev_dbg(dev, "clksel_reg=0x%08lx\n", priv->clksel_reg); + + return 0; +} + +static const struct clk_ti_am3_dpll_drv_data dpll_no_gate_data = { + .max_rate = 1000000000 +}; + +static const struct clk_ti_am3_dpll_drv_data dpll_no_gate_j_type_data = { + .max_rate = 2000000000 +}; + +static const struct clk_ti_am3_dpll_drv_data dpll_core_data = { + .max_rate = 1000000000 +}; + +static const struct udevice_id clk_ti_am3_dpll_of_match[] = { + {.compatible = "ti,am3-dpll-core-clock", + .data = (ulong)&dpll_core_data}, + {.compatible = "ti,am3-dpll-no-gate-clock", + .data = (ulong)&dpll_no_gate_data}, + {.compatible = "ti,am3-dpll-no-gate-j-type-clock", + .data = (ulong)&dpll_no_gate_j_type_data}, + {} +}; + +U_BOOT_DRIVER(clk_ti_am3_dpll) = { + .name = "ti_am3_dpll_clock", + .id = UCLASS_CLK, + .of_match = clk_ti_am3_dpll_of_match, + .ofdata_to_platdata = clk_ti_am3_dpll_of_to_plat, + .probe = clk_ti_am3_dpll_probe, + .remove = clk_ti_am3_dpll_remove, + .priv_auto = sizeof(struct clk_ti_am3_dpll_priv), + .ops = &clk_ti_am3_dpll_ops, +}; diff --git a/drivers/clk/ti/clk-ctrl.c b/drivers/clk/ti/clk-ctrl.c new file mode 100644 index 0000000000..940e8d6caf --- /dev/null +++ b/drivers/clk/ti/clk-ctrl.c @@ -0,0 +1,154 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * OMAP clock controller support + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#include <common.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <clk-uclass.h> +#include <asm/arch-am33xx/clock.h> + +struct clk_ti_ctrl_offs { + fdt_addr_t start; + fdt_size_t end; +}; + +struct clk_ti_ctrl_priv { + int offs_num; + struct clk_ti_ctrl_offs *offs; +}; + +static int clk_ti_ctrl_check_offs(struct clk *clk, fdt_addr_t offs) +{ + struct clk_ti_ctrl_priv *priv = dev_get_priv(clk->dev); + int i; + + for (i = 0; i < priv->offs_num; i++) { + if (offs >= priv->offs[i].start && offs <= priv->offs[i].end) + return 0; + } + + return -EFAULT; +} + +static int clk_ti_ctrl_disable(struct clk *clk) +{ + struct clk_ti_ctrl_priv *priv = dev_get_priv(clk->dev); + u32 *clk_modules[2] = { }; + fdt_addr_t offs; + int err; + + offs = priv->offs[0].start + clk->id; + err = clk_ti_ctrl_check_offs(clk, offs); + if (err) { + dev_err(clk->dev, "invalid offset: 0x%lx\n", offs); + return err; + } + + clk_modules[0] = (u32 *)(offs); + dev_dbg(clk->dev, "module address=%p\n", clk_modules[0]); + do_disable_clocks(NULL, clk_modules, 1); + return 0; +} + +static int clk_ti_ctrl_enable(struct clk *clk) +{ + struct clk_ti_ctrl_priv *priv = dev_get_priv(clk->dev); + u32 *clk_modules[2] = { }; + fdt_addr_t offs; + int err; + + offs = priv->offs[0].start + clk->id; + err = clk_ti_ctrl_check_offs(clk, offs); + if (err) { + dev_err(clk->dev, "invalid offset: 0x%lx\n", offs); + return err; + } + + clk_modules[0] = (u32 *)(offs); + dev_dbg(clk->dev, "module address=%p\n", clk_modules[0]); + do_enable_clocks(NULL, clk_modules, 1); + return 0; +} + +static ulong clk_ti_ctrl_get_rate(struct clk *clk) +{ + return 0; +} + +static int clk_ti_ctrl_of_xlate(struct clk *clk, + struct ofnode_phandle_args *args) +{ + if (args->args_count != 2) { + dev_err(clk->dev, "invaild args_count: %d\n", args->args_count); + return -EINVAL; + } + + if (args->args_count) + clk->id = args->args[0]; + else + clk->id = 0; + + dev_dbg(clk->dev, "name=%s, id=%ld\n", clk->dev->name, clk->id); + return 0; +} + +static int clk_ti_ctrl_of_to_plat(struct udevice *dev) +{ + struct clk_ti_ctrl_priv *priv = dev_get_priv(dev); + fdt_size_t fdt_size; + int i, size; + + size = dev_read_size(dev, "reg"); + if (size < 0) { + dev_err(dev, "failed to get 'reg' size\n"); + return size; + } + + priv->offs_num = size / 2 / sizeof(u32); + dev_dbg(dev, "size=%d, regs_num=%d\n", size, priv->offs_num); + + priv->offs = kmalloc_array(priv->offs_num, sizeof(*priv->offs), + GFP_KERNEL); + if (!priv->offs) + return -ENOMEM; + + for (i = 0; i < priv->offs_num; i++) { + priv->offs[i].start = + dev_read_addr_size_index(dev, i, &fdt_size); + if (priv->offs[i].start == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get offset %d\n", i); + return -EINVAL; + } + + priv->offs[i].end = priv->offs[i].start + fdt_size; + dev_dbg(dev, "start=0x%08lx, end=0x%08lx\n", + priv->offs[i].start, priv->offs[i].end); + } + + return 0; +} + +static struct clk_ops clk_ti_ctrl_ops = { + .of_xlate = clk_ti_ctrl_of_xlate, + .enable = clk_ti_ctrl_enable, + .disable = clk_ti_ctrl_disable, + .get_rate = clk_ti_ctrl_get_rate, +}; + +static const struct udevice_id clk_ti_ctrl_ids[] = { + {.compatible = "ti,clkctrl"}, + {}, +}; + +U_BOOT_DRIVER(clk_ti_ctrl) = { + .name = "ti_ctrl_clk", + .id = UCLASS_CLK, + .of_match = clk_ti_ctrl_ids, + .ofdata_to_platdata = clk_ti_ctrl_of_to_plat, + .ops = &clk_ti_ctrl_ops, + .priv_auto = sizeof(struct clk_ti_ctrl_priv), +}; diff --git a/drivers/clk/ti/clk-divider.c b/drivers/clk/ti/clk-divider.c new file mode 100644 index 0000000000..a862637785 --- /dev/null +++ b/drivers/clk/ti/clk-divider.c @@ -0,0 +1,381 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * TI divider clock support + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + * + * Loosely based on Linux kernel drivers/clk/ti/divider.c + */ + +#include <common.h> +#include <clk.h> +#include <clk-uclass.h> +#include <div64.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <asm/io.h> +#include <linux/clk-provider.h> +#include <linux/kernel.h> +#include <linux/log2.h> +#include "clk.h" + +/* + * The reverse of DIV_ROUND_UP: The maximum number which + * divided by m is r + */ +#define MULT_ROUND_UP(r, m) ((r) * (m) + (m) - 1) + +struct clk_ti_divider_priv { + struct clk parent; + fdt_addr_t reg; + const struct clk_div_table *table; + u8 shift; + u8 flags; + u8 div_flags; + s8 latch; + u16 min; + u16 max; + u16 mask; +}; + +static unsigned int _get_div(const struct clk_div_table *table, ulong flags, + unsigned int val) +{ + if (flags & CLK_DIVIDER_ONE_BASED) + return val; + + if (flags & CLK_DIVIDER_POWER_OF_TWO) + return 1 << val; + + if (table) + return clk_divider_get_table_div(table, val); + + return val + 1; +} + +static unsigned int _get_val(const struct clk_div_table *table, ulong flags, + unsigned int div) +{ + if (flags & CLK_DIVIDER_ONE_BASED) + return div; + + if (flags & CLK_DIVIDER_POWER_OF_TWO) + return __ffs(div); + + if (table) + return clk_divider_get_table_val(table, div); + + return div - 1; +} + +static int _div_round_up(const struct clk_div_table *table, ulong parent_rate, + ulong rate) +{ + const struct clk_div_table *clkt; + int up = INT_MAX; + int div = DIV_ROUND_UP_ULL((u64)parent_rate, rate); + + for (clkt = table; clkt->div; clkt++) { + if (clkt->div == div) + return clkt->div; + else if (clkt->div < div) + continue; + + if ((clkt->div - div) < (up - div)) + up = clkt->div; + } + + return up; +} + +static int _div_round(const struct clk_div_table *table, ulong parent_rate, + ulong rate) +{ + if (table) + return _div_round_up(table, parent_rate, rate); + + return DIV_ROUND_UP(parent_rate, rate); +} + +static int clk_ti_divider_best_div(struct clk *clk, ulong rate, + ulong *best_parent_rate) +{ + struct clk_ti_divider_priv *priv = dev_get_priv(clk->dev); + ulong parent_rate, parent_round_rate, max_div; + ulong best_rate, r; + int i, best_div = 0; + + parent_rate = clk_get_rate(&priv->parent); + if (IS_ERR_VALUE(parent_rate)) + return parent_rate; + + if (!rate) + rate = 1; + + if (!(clk->flags & CLK_SET_RATE_PARENT)) { + best_div = _div_round(priv->table, parent_rate, rate); + if (best_div == 0) + best_div = 1; + + if (best_div > priv->max) + best_div = priv->max; + + *best_parent_rate = parent_rate; + return best_div; + } + + max_div = min(ULONG_MAX / rate, (ulong)priv->max); + for (best_rate = 0, i = 1; i <= max_div; i++) { + if (!clk_divider_is_valid_div(priv->table, priv->div_flags, i)) + continue; + + /* + * It's the most ideal case if the requested rate can be + * divided from parent clock without needing to change + * parent rate, so return the divider immediately. + */ + if ((rate * i) == parent_rate) { + *best_parent_rate = parent_rate; + dev_dbg(clk->dev, "rate=%ld, best_rate=%ld, div=%d\n", + rate, rate, i); + return i; + } + + parent_round_rate = clk_round_rate(&priv->parent, + MULT_ROUND_UP(rate, i)); + if (IS_ERR_VALUE(parent_round_rate)) + continue; + + r = DIV_ROUND_UP(parent_round_rate, i); + if (r <= rate && r > best_rate) { + best_div = i; + best_rate = r; + *best_parent_rate = parent_round_rate; + if (best_rate == rate) + break; + } + } + + if (best_div == 0) { + best_div = priv->max; + parent_round_rate = clk_round_rate(&priv->parent, 1); + if (IS_ERR_VALUE(parent_round_rate)) + return parent_round_rate; + } + + dev_dbg(clk->dev, "rate=%ld, best_rate=%ld, div=%d\n", rate, best_rate, + best_div); + + return best_div; +} + +static ulong clk_ti_divider_round_rate(struct clk *clk, ulong rate) +{ + ulong parent_rate; + int div; + + div = clk_ti_divider_best_div(clk, rate, &parent_rate); + if (div < 0) + return div; + + return DIV_ROUND_UP(parent_rate, div); +} + +static ulong clk_ti_divider_set_rate(struct clk *clk, ulong rate) +{ + struct clk_ti_divider_priv *priv = dev_get_priv(clk->dev); + ulong parent_rate; + int div; + u32 val, v; + + div = clk_ti_divider_best_div(clk, rate, &parent_rate); + if (div < 0) + return div; + + if (clk->flags & CLK_SET_RATE_PARENT) { + parent_rate = clk_set_rate(&priv->parent, parent_rate); + if (IS_ERR_VALUE(parent_rate)) + return parent_rate; + } + + val = _get_val(priv->table, priv->div_flags, div); + + v = readl(priv->reg); + v &= ~(priv->mask << priv->shift); + v |= val << priv->shift; + writel(v, priv->reg); + clk_ti_latch(priv->reg, priv->latch); + + return clk_get_rate(clk); +} + +static ulong clk_ti_divider_get_rate(struct clk *clk) +{ + struct clk_ti_divider_priv *priv = dev_get_priv(clk->dev); + ulong rate, parent_rate; + unsigned int div; + u32 v; + + parent_rate = clk_get_rate(&priv->parent); + if (IS_ERR_VALUE(parent_rate)) + return parent_rate; + + v = readl(priv->reg) >> priv->shift; + v &= priv->mask; + + div = _get_div(priv->table, priv->div_flags, v); + if (!div) { + if (!(priv->div_flags & CLK_DIVIDER_ALLOW_ZERO)) + dev_warn(clk->dev, + "zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n"); + return parent_rate; + } + + rate = DIV_ROUND_UP(parent_rate, div); + dev_dbg(clk->dev, "rate=%ld\n", rate); + return rate; +} + +static int clk_ti_divider_request(struct clk *clk) +{ + struct clk_ti_divider_priv *priv = dev_get_priv(clk->dev); + + clk->flags = priv->flags; + return 0; +} + +const struct clk_ops clk_ti_divider_ops = { + .request = clk_ti_divider_request, + .round_rate = clk_ti_divider_round_rate, + .get_rate = clk_ti_divider_get_rate, + .set_rate = clk_ti_divider_set_rate +}; + +static int clk_ti_divider_remove(struct udevice *dev) +{ + struct clk_ti_divider_priv *priv = dev_get_priv(dev); + int err; + + err = clk_release_all(&priv->parent, 1); + if (err) { + dev_err(dev, "failed to release parent clock\n"); + return err; + } + + return 0; +} + +static int clk_ti_divider_probe(struct udevice *dev) +{ + struct clk_ti_divider_priv *priv = dev_get_priv(dev); + int err; + + err = clk_get_by_index(dev, 0, &priv->parent); + if (err) { + dev_err(dev, "failed to get parent clock\n"); + return err; + } + + return 0; +} + +static int clk_ti_divider_of_to_plat(struct udevice *dev) +{ + struct clk_ti_divider_priv *priv = dev_get_priv(dev); + struct clk_div_table *table = NULL; + u32 val, valid_div; + u32 min_div = 0; + u32 max_val, max_div = 0; + u16 mask; + int i, div_num; + + priv->reg = dev_read_addr(dev); + dev_dbg(dev, "reg=0x%08lx\n", priv->reg); + priv->shift = dev_read_u32_default(dev, "ti,bit-shift", 0); + priv->latch = dev_read_s32_default(dev, "ti,latch-bit", -EINVAL); + if (dev_read_bool(dev, "ti,index-starts-at-one")) + priv->div_flags |= CLK_DIVIDER_ONE_BASED; + + if (dev_read_bool(dev, "ti,index-power-of-two")) + priv->div_flags |= CLK_DIVIDER_POWER_OF_TWO; + + if (dev_read_bool(dev, "ti,set-rate-parent")) + priv->flags |= CLK_SET_RATE_PARENT; + + if (dev_read_prop(dev, "ti,dividers", &div_num)) { + div_num /= sizeof(u32); + + /* Determine required size for divider table */ + for (i = 0, valid_div = 0; i < div_num; i++) { + dev_read_u32_index(dev, "ti,dividers", i, &val); + if (val) + valid_div++; + } + + if (!valid_div) { + dev_err(dev, "no valid dividers\n"); + return -EINVAL; + } + + table = calloc(valid_div + 1, sizeof(*table)); + if (!table) + return -ENOMEM; + + for (i = 0, valid_div = 0; i < div_num; i++) { + dev_read_u32_index(dev, "ti,dividers", i, &val); + if (!val) + continue; + + table[valid_div].div = val; + table[valid_div].val = i; + valid_div++; + if (val > max_div) + max_div = val; + + if (!min_div || val < min_div) + min_div = val; + } + + max_val = max_div; + } else { + /* Divider table not provided, determine min/max divs */ + min_div = dev_read_u32_default(dev, "ti,min-div", 1); + if (dev_read_u32(dev, "ti,max-div", &max_div)) { + dev_err(dev, "missing 'max-div' property\n"); + return -EFAULT; + } + + max_val = max_div; + if (!(priv->div_flags & CLK_DIVIDER_ONE_BASED) && + !(priv->div_flags & CLK_DIVIDER_POWER_OF_TWO)) + max_val--; + } + + priv->table = table; + priv->min = min_div; + priv->max = max_div; + + if (priv->div_flags & CLK_DIVIDER_POWER_OF_TWO) + mask = fls(max_val) - 1; + else + mask = max_val; + + priv->mask = (1 << fls(mask)) - 1; + return 0; +} + +static const struct udevice_id clk_ti_divider_of_match[] = { + {.compatible = "ti,divider-clock"}, + {} +}; + +U_BOOT_DRIVER(clk_ti_divider) = { + .name = "ti_divider_clock", + .id = UCLASS_CLK, + .of_match = clk_ti_divider_of_match, + .ofdata_to_platdata = clk_ti_divider_of_to_plat, + .probe = clk_ti_divider_probe, + .remove = clk_ti_divider_remove, + .priv_auto = sizeof(struct clk_ti_divider_priv), + .ops = &clk_ti_divider_ops, +}; diff --git a/drivers/clk/ti/clk-gate.c b/drivers/clk/ti/clk-gate.c new file mode 100644 index 0000000000..236eaed6df --- /dev/null +++ b/drivers/clk/ti/clk-gate.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * TI gate clock support + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + * + * Loosely based on Linux kernel drivers/clk/ti/gate.c + */ + +#include <common.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <clk-uclass.h> +#include <asm/io.h> +#include <linux/clk-provider.h> + +struct clk_ti_gate_priv { + fdt_addr_t reg; + u8 enable_bit; + u32 flags; + bool invert_enable; +}; + +static int clk_ti_gate_disable(struct clk *clk) +{ + struct clk_ti_gate_priv *priv = dev_get_priv(clk->dev); + u32 v; + + v = readl(priv->reg); + if (priv->invert_enable) + v |= (1 << priv->enable_bit); + else + v &= ~(1 << priv->enable_bit); + + writel(v, priv->reg); + /* No OCP barrier needed here since it is a disable operation */ + return 0; +} + +static int clk_ti_gate_enable(struct clk *clk) +{ + struct clk_ti_gate_priv *priv = dev_get_priv(clk->dev); + u32 v; + + v = readl(priv->reg); + if (priv->invert_enable) + v &= ~(1 << priv->enable_bit); + else + v |= (1 << priv->enable_bit); + + writel(v, priv->reg); + /* OCP barrier */ + v = readl(priv->reg); + return 0; +} + +static int clk_ti_gate_of_to_plat(struct udevice *dev) +{ + struct clk_ti_gate_priv *priv = dev_get_priv(dev); + + priv->reg = dev_read_addr(dev); + if (priv->reg == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get control register\n"); + return -EINVAL; + } + + dev_dbg(dev, "reg=0x%08lx\n", priv->reg); + priv->enable_bit = dev_read_u32_default(dev, "ti,bit-shift", 0); + if (dev_read_bool(dev, "ti,set-rate-parent")) + priv->flags |= CLK_SET_RATE_PARENT; + + priv->invert_enable = dev_read_bool(dev, "ti,set-bit-to-disable"); + return 0; +} + +static struct clk_ops clk_ti_gate_ops = { + .enable = clk_ti_gate_enable, + .disable = clk_ti_gate_disable, +}; + +static const struct udevice_id clk_ti_gate_of_match[] = { + { .compatible = "ti,gate-clock" }, + { }, +}; + +U_BOOT_DRIVER(clk_ti_gate) = { + .name = "ti_gate_clock", + .id = UCLASS_CLK, + .of_match = clk_ti_gate_of_match, + .ofdata_to_platdata = clk_ti_gate_of_to_plat, + .priv_auto = sizeof(struct clk_ti_gate_priv), + .ops = &clk_ti_gate_ops, +}; diff --git a/drivers/clk/ti/clk-mux.c b/drivers/clk/ti/clk-mux.c new file mode 100644 index 0000000000..419502c389 --- /dev/null +++ b/drivers/clk/ti/clk-mux.c @@ -0,0 +1,253 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * TI multiplexer clock support + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + * + * Based on Linux kernel drivers/clk/ti/mux.c + */ + +#include <common.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <clk-uclass.h> +#include <asm/io.h> +#include <linux/clk-provider.h> +#include "clk.h" + +struct clk_ti_mux_priv { + struct clk_bulk parents; + fdt_addr_t reg; + u32 flags; + u32 mux_flags; + u32 mask; + u32 shift; + s32 latch; +}; + +static struct clk *clk_ti_mux_get_parent_by_index(struct clk_bulk *parents, + int index) +{ + if (index < 0 || !parents) + return ERR_PTR(-EINVAL); + + if (index >= parents->count) + return ERR_PTR(-ENODEV); + + return &parents->clks[index]; +} + +static int clk_ti_mux_get_parent_index(struct clk_bulk *parents, + struct clk *parent) +{ + int i; + + if (!parents || !parent) + return -EINVAL; + + for (i = 0; i < parents->count; i++) { + if (parents->clks[i].dev == parent->dev) + return i; + } + + return -ENODEV; +} + +static int clk_ti_mux_get_index(struct clk *clk) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(clk->dev); + u32 val; + + val = readl(priv->reg); + val >>= priv->shift; + val &= priv->mask; + + if (val && (priv->flags & CLK_MUX_INDEX_BIT)) + val = ffs(val) - 1; + + if (val && (priv->flags & CLK_MUX_INDEX_ONE)) + val--; + + if (val >= priv->parents.count) + return -EINVAL; + + return val; +} + +static int clk_ti_mux_set_parent(struct clk *clk, struct clk *parent) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(clk->dev); + int index; + u32 val; + + index = clk_ti_mux_get_parent_index(&priv->parents, parent); + if (index < 0) { + dev_err(clk->dev, "failed to get parent clock\n"); + return index; + } + + index = clk_mux_index_to_val(NULL, priv->flags, index); + + if (priv->flags & CLK_MUX_HIWORD_MASK) { + val = priv->mask << (priv->shift + 16); + } else { + val = readl(priv->reg); + val &= ~(priv->mask << priv->shift); + } + + val |= index << priv->shift; + writel(val, priv->reg); + clk_ti_latch(priv->reg, priv->latch); + return 0; +} + +static ulong clk_ti_mux_set_rate(struct clk *clk, ulong rate) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(clk->dev); + struct clk *parent; + int index; + + if ((clk->flags & CLK_SET_RATE_PARENT) == 0) + return -ENOSYS; + + index = clk_ti_mux_get_index(clk); + parent = clk_ti_mux_get_parent_by_index(&priv->parents, index); + if (IS_ERR(parent)) + return PTR_ERR(parent); + + rate = clk_set_rate(parent, rate); + dev_dbg(clk->dev, "rate=%ld\n", rate); + return rate; +} + +static ulong clk_ti_mux_get_rate(struct clk *clk) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(clk->dev); + int index; + struct clk *parent; + ulong rate; + + index = clk_ti_mux_get_index(clk); + parent = clk_ti_mux_get_parent_by_index(&priv->parents, index); + if (IS_ERR(parent)) + return PTR_ERR(parent); + + rate = clk_get_rate(parent); + dev_dbg(clk->dev, "rate=%ld\n", rate); + return rate; +} + +static ulong clk_ti_mux_round_rate(struct clk *clk, ulong rate) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(clk->dev); + struct clk *parent; + int index; + + if ((clk->flags & CLK_SET_RATE_PARENT) == 0) + return -ENOSYS; + + index = clk_ti_mux_get_index(clk); + parent = clk_ti_mux_get_parent_by_index(&priv->parents, index); + if (IS_ERR(parent)) + return PTR_ERR(parent); + + rate = clk_round_rate(parent, rate); + dev_dbg(clk->dev, "rate=%ld\n", rate); + return rate; +} + +static int clk_ti_mux_request(struct clk *clk) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(clk->dev); + struct clk *parent; + int index; + + clk->flags = priv->flags; + + index = clk_ti_mux_get_index(clk); + parent = clk_ti_mux_get_parent_by_index(&priv->parents, index); + if (IS_ERR(parent)) + return PTR_ERR(parent); + + return clk_ti_mux_set_parent(clk, parent); +} + +static struct clk_ops clk_ti_mux_ops = { + .request = clk_ti_mux_request, + .round_rate = clk_ti_mux_round_rate, + .get_rate = clk_ti_mux_get_rate, + .set_rate = clk_ti_mux_set_rate, + .set_parent = clk_ti_mux_set_parent, +}; + +static int clk_ti_mux_remove(struct udevice *dev) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(dev); + int err; + + err = clk_release_all(priv->parents.clks, priv->parents.count); + if (err) + dev_dbg(dev, "could not release all parents' clocks\n"); + + return err; +} + +static int clk_ti_mux_probe(struct udevice *dev) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(dev); + int err; + + err = clk_get_bulk(dev, &priv->parents); + if (err || priv->parents.count < 2) { + dev_err(dev, "mux-clock must have parents\n"); + return err ? err : -EFAULT; + } + + /* Generate bit-mask based on parents info */ + priv->mask = priv->parents.count; + if (!(priv->mux_flags & CLK_MUX_INDEX_ONE)) + priv->mask--; + + priv->mask = (1 << fls(priv->mask)) - 1; + return 0; +} + +static int clk_ti_mux_of_to_plat(struct udevice *dev) +{ + struct clk_ti_mux_priv *priv = dev_get_priv(dev); + + priv->reg = dev_read_addr(dev); + if (priv->reg == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get register\n"); + return -EINVAL; + } + + dev_dbg(dev, "reg=0x%08lx\n", priv->reg); + priv->shift = dev_read_u32_default(dev, "ti,bit-shift", 0); + priv->latch = dev_read_s32_default(dev, "ti,latch-bit", -EINVAL); + + priv->flags = CLK_SET_RATE_NO_REPARENT; + if (dev_read_bool(dev, "ti,set-rate-parent")) + priv->flags |= CLK_SET_RATE_PARENT; + + if (dev_read_bool(dev, "ti,index-starts-at-one")) + priv->mux_flags |= CLK_MUX_INDEX_ONE; + + return 0; +} + +static const struct udevice_id clk_ti_mux_of_match[] = { + {.compatible = "ti,mux-clock"}, + {}, +}; + +U_BOOT_DRIVER(clk_ti_mux) = { + .name = "ti_mux_clock", + .id = UCLASS_CLK, + .of_match = clk_ti_mux_of_match, + .ofdata_to_platdata = clk_ti_mux_of_to_plat, + .probe = clk_ti_mux_probe, + .remove = clk_ti_mux_remove, + .priv_auto = sizeof(struct clk_ti_mux_priv), + .ops = &clk_ti_mux_ops, +}; diff --git a/drivers/clk/clk-ti-sci.c b/drivers/clk/ti/clk-sci.c index 7a9a645137..6f0fdaa111 100644 --- a/drivers/clk/clk-ti-sci.c +++ b/drivers/clk/ti/clk-sci.c @@ -220,6 +220,6 @@ U_BOOT_DRIVER(ti_sci_clk) = { .id = UCLASS_CLK, .of_match = ti_sci_clk_of_match, .probe = ti_sci_clk_probe, - .priv_auto_alloc_size = sizeof(struct ti_sci_clk_data), + .priv_auto = sizeof(struct ti_sci_clk_data), .ops = &ti_sci_clk_ops, }; diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c new file mode 100644 index 0000000000..e44b90ad6a --- /dev/null +++ b/drivers/clk/ti/clk.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * TI clock utilities + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#include <common.h> +#include <asm/io.h> +#include "clk.h" + +static void clk_ti_rmw(u32 val, u32 mask, fdt_addr_t reg) +{ + u32 v; + + v = readl(reg); + v &= ~mask; + v |= val; + writel(v, reg); +} + +void clk_ti_latch(fdt_addr_t reg, s8 shift) +{ + u32 latch; + + if (shift < 0) + return; + + latch = 1 << shift; + + clk_ti_rmw(latch, latch, reg); + clk_ti_rmw(0, latch, reg); + readl(reg); /* OCP barrier */ +} diff --git a/drivers/clk/ti/clk.h b/drivers/clk/ti/clk.h new file mode 100644 index 0000000000..601c3823f7 --- /dev/null +++ b/drivers/clk/ti/clk.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * TI clock utilities header + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#ifndef _CLK_TI_H +#define _CLK_TI_H + +void clk_ti_latch(fdt_addr_t reg, s8 shift); + +#endif /* #ifndef _CLK_TI_H */ diff --git a/drivers/clk/ti/omap4-cm.c b/drivers/clk/ti/omap4-cm.c new file mode 100644 index 0000000000..3cdc9b2888 --- /dev/null +++ b/drivers/clk/ti/omap4-cm.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * OMAP4 clock manager (cm) + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#include <common.h> +#include <dm.h> +#include <dm/lists.h> + +static const struct udevice_id ti_omap4_cm_ids[] = { + {.compatible = "ti,omap4-cm"}, + {} +}; + +U_BOOT_DRIVER(ti_omap4_cm) = { + .name = "ti_omap4_cm", + .id = UCLASS_SIMPLE_BUS, + .of_match = ti_omap4_cm_ids, + .bind = dm_scan_fdt_dev, +}; diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c index 4e25db354e..c31e59641d 100644 --- a/drivers/clk/uniphier/clk-uniphier-core.c +++ b/drivers/clk/uniphier/clk-uniphier-core.c @@ -342,6 +342,6 @@ U_BOOT_DRIVER(uniphier_clk) = { .id = UCLASS_CLK, .of_match = uniphier_clk_match, .probe = uniphier_clk_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_clk_priv), + .priv_auto = sizeof(struct uniphier_clk_priv), .ops = &uniphier_clk_ops, }; diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index ffae6f9795..dbfe51c6e8 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -113,6 +113,22 @@ config SPL_DM_SEQ_ALIAS numbered devices (e.g. serial0 = &serial0). This feature can be disabled if it is not required, to save code space in SPL. +config SPL_DM_INLINE_OFNODE + bool "Inline some ofnode functions which are seldom used in SPL" + depends on SPL_DM + default y + help + This applies to several ofnode functions (see ofnode.h) which are + seldom used. Inlining them can help reduce code size. + +config TPL_DM_INLINE_OFNODE + bool "Inline some ofnode functions which are seldom used in TPL" + depends on TPL_DM + default y + help + This applies to several ofnode functions (see ofnode.h) which are + seldom used. Inlining them can help reduce code size. + config REGMAP bool "Support register maps" depends on DM @@ -231,6 +247,18 @@ config OF_TRANSLATE used for the address translation. This function is faster and smaller in size than fdt_translate_address(). +config OF_TRANSLATE_ZERO_SIZE_CELLS + bool "Enable translation for zero size cells" + depends on OF_TRANSLATE + default n + help + The routine used to translate an FDT address into a physical CPU + address was developed by IBM. It considers that crossing any level + with #size-cells = <0> makes translation impossible, even if it is + not the way it was specified. + Enabling this option makes translation possible even in the case + of crossing levels with #size-cells = <0>. + config SPL_OF_TRANSLATE bool "Translate addresses using fdt_translate_address in SPL" depends on SPL_DM && SPL_OF_CONTROL diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 63a791f335..0901b9260a 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -269,7 +269,7 @@ int acpi_recurse_method(struct acpi_ctx *ctx, struct udevice *parent, void *start = ctx->current; log_debug("- method %d, %s %p\n", method, parent->name, func); - ret = device_ofdata_to_platdata(parent); + ret = device_of_to_plat(parent); if (ret) return log_msg_ret("ofdata", ret); ret = func(parent, ctx); diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c index 0924a575f5..7e8f3afb2d 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -69,10 +69,10 @@ int device_unbind(struct udevice *dev) if (!dev) return log_msg_ret("dev", -EINVAL); - if (dev->flags & DM_FLAG_ACTIVATED) + if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) return log_msg_ret("active", -EINVAL); - if (!(dev->flags & DM_FLAG_BOUND)) + if (!(dev_get_flags(dev) & DM_FLAG_BOUND)) return log_msg_ret("not-bound", -EINVAL); drv = dev->driver; @@ -88,17 +88,17 @@ int device_unbind(struct udevice *dev) if (ret) return log_msg_ret("child unbind", ret); - if (dev->flags & DM_FLAG_ALLOC_PDATA) { - free(dev->platdata); - dev->platdata = NULL; + if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) { + free(dev_get_plat(dev)); + dev_set_plat(dev, NULL); } - if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) { - free(dev->uclass_platdata); - dev->uclass_platdata = NULL; + if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) { + free(dev_get_uclass_plat(dev)); + dev_set_uclass_plat(dev, NULL); } - if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) { - free(dev->parent_platdata); - dev->parent_platdata = NULL; + if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) { + free(dev_get_parent_plat(dev)); + dev_set_parent_plat(dev, NULL); } ret = uclass_unbind_device(dev); if (ret) @@ -109,7 +109,7 @@ int device_unbind(struct udevice *dev) devres_release_all(dev); - if (dev->flags & DM_FLAG_NAME_ALLOCED) + if (dev_get_flags(dev) & DM_FLAG_NAME_ALLOCED) free((char *)dev->name); free(dev); @@ -124,27 +124,27 @@ void device_free(struct udevice *dev) { int size; - if (dev->driver->priv_auto_alloc_size) { - free(dev->priv); - dev->priv = NULL; + if (dev->driver->priv_auto) { + free(dev_get_priv(dev)); + dev_set_priv(dev, NULL); } - size = dev->uclass->uc_drv->per_device_auto_alloc_size; + size = dev->uclass->uc_drv->per_device_auto; if (size) { - free(dev->uclass_priv); - dev->uclass_priv = NULL; + free(dev_get_uclass_priv(dev)); + dev_set_uclass_priv(dev, NULL); } if (dev->parent) { - size = dev->parent->driver->per_child_auto_alloc_size; + size = dev->parent->driver->per_child_auto; if (!size) { size = dev->parent->uclass->uc_drv-> - per_child_auto_alloc_size; + per_child_auto; } if (size) { - free(dev->parent_priv); - dev->parent_priv = NULL; + free(dev_get_parent_priv(dev)); + dev_set_parent_priv(dev, NULL); } } - dev->flags &= ~DM_FLAG_PLATDATA_VALID; + dev_bic_flags(dev, DM_FLAG_PLATDATA_VALID); devres_release_probe(dev); } @@ -166,7 +166,7 @@ int device_remove(struct udevice *dev, uint flags) if (!dev) return -EINVAL; - if (!(dev->flags & DM_FLAG_ACTIVATED)) + if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)) return 0; drv = dev->driver; @@ -207,8 +207,7 @@ int device_remove(struct udevice *dev, uint flags) if (flags_remove(flags, drv->flags)) { device_free(dev); - dev->seq = -1; - dev->flags &= ~DM_FLAG_ACTIVATED; + dev_bic_flags(dev, DM_FLAG_ACTIVATED); } return ret; diff --git a/drivers/core/device.c b/drivers/core/device.c index 4b3dcb3b37..aeab3836ed 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -34,13 +34,15 @@ DECLARE_GLOBAL_DATA_PTR; static int device_bind_common(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, + const char *name, void *plat, ulong driver_data, ofnode node, - uint of_platdata_size, struct udevice **devp) + uint of_plat_size, struct udevice **devp) { struct udevice *dev; struct uclass *uc; int size, ret = 0; + bool auto_seq = true; + void *ptr; if (devp) *devp = NULL; @@ -63,88 +65,79 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, #ifdef CONFIG_DEVRES INIT_LIST_HEAD(&dev->devres_head); #endif - dev->platdata = platdata; + dev_set_plat(dev, plat); dev->driver_data = driver_data; dev->name = name; - dev->node = node; + dev_set_ofnode(dev, node); dev->parent = parent; dev->driver = drv; dev->uclass = uc; - dev->seq = -1; - dev->req_seq = -1; + dev->seq_ = -1; if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) && (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) { /* * Some devices, such as a SPI bus, I2C bus and serial ports * are numbered using aliases. - * - * This is just a 'requested' sequence, and will be - * resolved (and ->seq updated) when the device is probed. */ if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { - if (uc->uc_drv->name && ofnode_valid(node)) - dev_read_alias_seq(dev, &dev->req_seq); -#if CONFIG_IS_ENABLED(OF_PRIOR_STAGE) - if (dev->req_seq == -1) - dev->req_seq = - uclass_find_next_free_req_seq(drv->id); -#endif - } else { - dev->req_seq = uclass_find_next_free_req_seq(drv->id); + if (uc->uc_drv->name && ofnode_valid(node)) { + if (!dev_read_alias_seq(dev, &dev->seq_)) + auto_seq = false; + } } } + if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ)) + dev->seq_ = uclass_find_next_free_seq(uc); - if (drv->platdata_auto_alloc_size) { - bool alloc = !platdata; + if (drv->plat_auto) { + bool alloc = !plat; if (CONFIG_IS_ENABLED(OF_PLATDATA)) { - if (of_platdata_size) { - dev->flags |= DM_FLAG_OF_PLATDATA; - if (of_platdata_size < - drv->platdata_auto_alloc_size) + if (of_plat_size) { + dev_or_flags(dev, DM_FLAG_OF_PLATDATA); + if (of_plat_size < drv->plat_auto) alloc = true; } } if (alloc) { - dev->flags |= DM_FLAG_ALLOC_PDATA; - dev->platdata = calloc(1, - drv->platdata_auto_alloc_size); - if (!dev->platdata) { + dev_or_flags(dev, DM_FLAG_ALLOC_PDATA); + ptr = calloc(1, drv->plat_auto); + if (!ptr) { ret = -ENOMEM; goto fail_alloc1; } - if (CONFIG_IS_ENABLED(OF_PLATDATA) && platdata) { - memcpy(dev->platdata, platdata, - of_platdata_size); - } + if (CONFIG_IS_ENABLED(OF_PLATDATA) && plat) + memcpy(ptr, plat, of_plat_size); + dev_set_plat(dev, ptr); } } - size = uc->uc_drv->per_device_platdata_auto_alloc_size; + size = uc->uc_drv->per_device_plat_auto; if (size) { - dev->flags |= DM_FLAG_ALLOC_UCLASS_PDATA; - dev->uclass_platdata = calloc(1, size); - if (!dev->uclass_platdata) { + dev_or_flags(dev, DM_FLAG_ALLOC_UCLASS_PDATA); + ptr = calloc(1, size); + if (!ptr) { ret = -ENOMEM; goto fail_alloc2; } + dev_set_uclass_plat(dev, ptr); } if (parent) { - size = parent->driver->per_child_platdata_auto_alloc_size; + size = parent->driver->per_child_plat_auto; if (!size) { - size = parent->uclass->uc_drv-> - per_child_platdata_auto_alloc_size; + size = parent->uclass->uc_drv->per_child_plat_auto; } if (size) { - dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA; - dev->parent_platdata = calloc(1, size); - if (!dev->parent_platdata) { + dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA); + ptr = calloc(1, size); + if (!ptr) { ret = -ENOMEM; goto fail_alloc3; } + dev_set_parent_plat(dev, ptr); } /* put dev into parent's successor list */ list_add_tail(&dev->sibling_node, &parent->child_head); @@ -176,7 +169,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, if (devp) *devp = dev; - dev->flags |= DM_FLAG_BOUND; + dev_or_flags(dev, DM_FLAG_BOUND); return 0; @@ -200,20 +193,20 @@ fail_bind: fail_uclass_bind: if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) { list_del(&dev->sibling_node); - if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) { - free(dev->parent_platdata); - dev->parent_platdata = NULL; + if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) { + free(dev_get_parent_plat(dev)); + dev_set_parent_plat(dev, NULL); } } fail_alloc3: - if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) { - free(dev->uclass_platdata); - dev->uclass_platdata = NULL; + if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) { + free(dev_get_uclass_plat(dev)); + dev_set_uclass_plat(dev, NULL); } fail_alloc2: - if (dev->flags & DM_FLAG_ALLOC_PDATA) { - free(dev->platdata); - dev->platdata = NULL; + if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) { + free(dev_get_plat(dev)); + dev_set_plat(dev, NULL); } fail_alloc1: devres_release_all(dev); @@ -233,18 +226,10 @@ int device_bind_with_driver_data(struct udevice *parent, } int device_bind(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, int of_offset, + const char *name, void *plat, ofnode node, struct udevice **devp) { - return device_bind_common(parent, drv, name, platdata, 0, - offset_to_ofnode(of_offset), 0, devp); -} - -int device_bind_ofnode(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, ofnode node, - struct udevice **devp) -{ - return device_bind_common(parent, drv, name, platdata, 0, node, 0, + return device_bind_common(parent, drv, name, plat, 0, node, 0, devp); } @@ -252,7 +237,7 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, const struct driver_info *info, struct udevice **devp) { struct driver *drv; - uint platdata_size = 0; + uint plat_size = 0; int ret; drv = lists_driver_lookup_name(info->name); @@ -262,11 +247,10 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, return -EPERM; #if CONFIG_IS_ENABLED(OF_PLATDATA) - platdata_size = info->platdata_size; + plat_size = info->plat_size; #endif - ret = device_bind_common(parent, drv, info->name, - (void *)info->platdata, 0, ofnode_null(), - platdata_size, devp); + ret = device_bind_common(parent, drv, info->name, (void *)info->plat, 0, + ofnode_null(), plat_size, devp); if (ret) return ret; @@ -339,21 +323,68 @@ static void *alloc_priv(int size, uint flags) return priv; } -int device_ofdata_to_platdata(struct udevice *dev) +/** + * device_alloc_priv() - Allocate priv/plat data required by the device + * + * @dev: Device to process + * @return 0 if OK, -ENOMEM if out of memory + */ +static int device_alloc_priv(struct udevice *dev) +{ + const struct driver *drv; + void *ptr; + int size; + + drv = dev->driver; + assert(drv); + + /* Allocate private data if requested and not reentered */ + if (drv->priv_auto && !dev_get_priv(dev)) { + ptr = alloc_priv(drv->priv_auto, drv->flags); + if (!ptr) + return -ENOMEM; + dev_set_priv(dev, ptr); + } + + /* Allocate private data if requested and not reentered */ + size = dev->uclass->uc_drv->per_device_auto; + if (size && !dev_get_uclass_priv(dev)) { + ptr = alloc_priv(size, dev->uclass->uc_drv->flags); + if (!ptr) + return -ENOMEM; + dev_set_uclass_priv(dev, ptr); + } + + /* Allocate parent data for this child */ + if (dev->parent) { + size = dev->parent->driver->per_child_auto; + if (!size) + size = dev->parent->uclass->uc_drv->per_child_auto; + if (size && !dev_get_parent_priv(dev)) { + ptr = alloc_priv(size, drv->flags); + if (!ptr) + return -ENOMEM; + dev_set_parent_priv(dev, ptr); + } + } + + return 0; +} + +int device_of_to_plat(struct udevice *dev) { const struct driver *drv; - int size = 0; int ret; if (!dev) return -EINVAL; - if (dev->flags & DM_FLAG_PLATDATA_VALID) + if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID) return 0; /* Ensure all parents have ofdata */ if (dev->parent) { - ret = device_ofdata_to_platdata(dev->parent); + ret = device_of_to_plat(dev->parent); if (ret) goto fail; @@ -363,56 +394,25 @@ int device_ofdata_to_platdata(struct udevice *dev) * (e.g. PCI bridge devices). Test the flags again * so that we don't mess up the device. */ - if (dev->flags & DM_FLAG_PLATDATA_VALID) + if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID) return 0; } + ret = device_alloc_priv(dev); + if (ret) + goto fail; + drv = dev->driver; assert(drv); - /* Allocate private data if requested and not reentered */ - if (drv->priv_auto_alloc_size && !dev->priv) { - dev->priv = alloc_priv(drv->priv_auto_alloc_size, drv->flags); - if (!dev->priv) { - ret = -ENOMEM; - goto fail; - } - } - /* Allocate private data if requested and not reentered */ - size = dev->uclass->uc_drv->per_device_auto_alloc_size; - if (size && !dev->uclass_priv) { - dev->uclass_priv = alloc_priv(size, - dev->uclass->uc_drv->flags); - if (!dev->uclass_priv) { - ret = -ENOMEM; - goto fail; - } - } - - /* Allocate parent data for this child */ - if (dev->parent) { - size = dev->parent->driver->per_child_auto_alloc_size; - if (!size) { - size = dev->parent->uclass->uc_drv-> - per_child_auto_alloc_size; - } - if (size && !dev->parent_priv) { - dev->parent_priv = alloc_priv(size, drv->flags); - if (!dev->parent_priv) { - ret = -ENOMEM; - goto fail; - } - } - } - - if (drv->ofdata_to_platdata && - (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) { - ret = drv->ofdata_to_platdata(dev); + if (drv->of_to_plat && + (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_ofnode(dev))) { + ret = drv->of_to_plat(dev); if (ret) goto fail; } - dev->flags |= DM_FLAG_PLATDATA_VALID; + dev_or_flags(dev, DM_FLAG_PLATDATA_VALID); return 0; fail: @@ -425,18 +425,17 @@ int device_probe(struct udevice *dev) { const struct driver *drv; int ret; - int seq; if (!dev) return -EINVAL; - if (dev->flags & DM_FLAG_ACTIVATED) + if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) return 0; drv = dev->driver; assert(drv); - ret = device_ofdata_to_platdata(dev); + ret = device_of_to_plat(dev); if (ret) goto fail; @@ -452,18 +451,11 @@ int device_probe(struct udevice *dev) * (e.g. PCI bridge devices). Test the flags again * so that we don't mess up the device. */ - if (dev->flags & DM_FLAG_ACTIVATED) + if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) return 0; } - seq = uclass_resolve_seq(dev); - if (seq < 0) { - ret = seq; - goto fail; - } - dev->seq = seq; - - dev->flags |= DM_FLAG_ACTIVATED; + dev_or_flags(dev, DM_FLAG_ACTIVATED); /* * Process pinctrl for everything except the root device, and @@ -493,7 +485,7 @@ int device_probe(struct udevice *dev) } /* Only handle devices that have a valid ofnode */ - if (dev_of_valid(dev)) { + if (dev_has_ofnode(dev)) { /* * Process 'assigned-{clocks/clock-parents/clock-rates}' * properties @@ -523,42 +515,41 @@ fail_uclass: __func__, dev->name); } fail: - dev->flags &= ~DM_FLAG_ACTIVATED; + dev_bic_flags(dev, DM_FLAG_ACTIVATED); - dev->seq = -1; device_free(dev); return ret; } -void *dev_get_platdata(const struct udevice *dev) +void *dev_get_plat(const struct udevice *dev) { if (!dev) { dm_warn("%s: null device\n", __func__); return NULL; } - return dev->platdata; + return dev->plat_; } -void *dev_get_parent_platdata(const struct udevice *dev) +void *dev_get_parent_plat(const struct udevice *dev) { if (!dev) { dm_warn("%s: null device\n", __func__); return NULL; } - return dev->parent_platdata; + return dev->parent_plat_; } -void *dev_get_uclass_platdata(const struct udevice *dev) +void *dev_get_uclass_plat(const struct udevice *dev) { if (!dev) { dm_warn("%s: null device\n", __func__); return NULL; } - return dev->uclass_platdata; + return dev->uclass_plat_; } void *dev_get_priv(const struct udevice *dev) @@ -568,7 +559,7 @@ void *dev_get_priv(const struct udevice *dev) return NULL; } - return dev->priv; + return dev->priv_; } void *dev_get_uclass_priv(const struct udevice *dev) @@ -578,7 +569,7 @@ void *dev_get_uclass_priv(const struct udevice *dev) return NULL; } - return dev->uclass_priv; + return dev->uclass_priv_; } void *dev_get_parent_priv(const struct udevice *dev) @@ -588,7 +579,7 @@ void *dev_get_parent_priv(const struct udevice *dev) return NULL; } - return dev->parent_priv; + return dev->parent_priv_; } static int device_get_device_tail(struct udevice *dev, int ret, @@ -622,7 +613,7 @@ static int device_find_by_ofnode(ofnode node, struct udevice **devp) struct udevice *dev; int ret; - list_for_each_entry(uc, &gd->uclass_root, sibling_node) { + list_for_each_entry(uc, gd->uclass_root, sibling_node) { ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node, &dev); if (!ret || dev) { @@ -659,18 +650,15 @@ int device_get_child_count(const struct udevice *parent) return count; } -int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp) +int device_find_child_by_seq(const struct udevice *parent, int seq, + struct udevice **devp) { struct udevice *dev; *devp = NULL; - if (seq_or_req_seq == -1) - return -ENODEV; list_for_each_entry(dev, &parent->child_head, sibling_node) { - if ((find_req_seq ? dev->req_seq : dev->seq) == - seq_or_req_seq) { + if (dev->seq_ == seq) { *devp = dev; return 0; } @@ -686,14 +674,8 @@ int device_get_child_by_seq(const struct udevice *parent, int seq, int ret; *devp = NULL; - ret = device_find_child_by_seq(parent, seq, false, &dev); - if (ret == -ENODEV) { - /* - * We didn't find it in probed devices. See if there is one - * that will request this seq if probed. - */ - ret = device_find_child_by_seq(parent, seq, true, &dev); - } + ret = device_find_child_by_seq(parent, seq, &dev); + return device_get_device_tail(dev, ret, devp); } @@ -895,7 +877,7 @@ int device_first_child_ofdata_err(struct udevice *parent, struct udevice **devp) if (!dev) return -ENODEV; - ret = device_ofdata_to_platdata(dev); + ret = device_of_to_plat(dev); if (ret) return ret; @@ -913,7 +895,7 @@ int device_next_child_ofdata_err(struct udevice **devp) if (!dev) return -ENODEV; - ret = device_ofdata_to_platdata(dev); + ret = device_of_to_plat(dev); if (ret) return ret; @@ -983,7 +965,7 @@ bool device_is_last_sibling(const struct udevice *dev) void device_set_name_alloced(struct udevice *dev) { - dev->flags |= DM_FLAG_NAME_ALLOCED; + dev_or_flags(dev, DM_FLAG_NAME_ALLOCED); } int device_set_name(struct udevice *dev, const char *name) @@ -997,6 +979,36 @@ int device_set_name(struct udevice *dev, const char *name) return 0; } +void dev_set_priv(struct udevice *dev, void *priv) +{ + dev->priv_ = priv; +} + +void dev_set_parent_priv(struct udevice *dev, void *parent_priv) +{ + dev->parent_priv_ = parent_priv; +} + +void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv) +{ + dev->uclass_priv_ = uclass_priv; +} + +void dev_set_plat(struct udevice *dev, void *plat) +{ + dev->plat_ = plat; +} + +void dev_set_parent_plat(struct udevice *dev, void *parent_plat) +{ + dev->parent_plat_ = parent_plat; +} + +void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat) +{ + dev->uclass_plat_ = uclass_plat; +} + #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) bool device_is_compatible(const struct udevice *dev, const char *compat) { @@ -1020,7 +1032,7 @@ int dev_disable_by_path(const char *path) if (!of_live_active()) return -ENOSYS; - list_for_each_entry(uc, &gd->uclass_root, sibling_node) { + list_for_each_entry(uc, gd->uclass_root, sibling_node) { ret = uclass_find_device_by_ofnode(uc->uc_drv->id, node, &dev); if (!ret) break; diff --git a/drivers/core/devres.c b/drivers/core/devres.c index 88244698b0..313ddc7089 100644 --- a/drivers/core/devres.c +++ b/drivers/core/devres.c @@ -23,7 +23,7 @@ /** enum devres_phase - Shows where resource was allocated * * DEVRES_PHASE_BIND: In the bind() method - * DEVRES_PHASE_OFDATA: In the ofdata_to_platdata() method + * DEVRES_PHASE_OFDATA: In the of_to_plat() method * DEVRES_PHASE_PROBE: In the probe() method */ enum devres_phase { @@ -107,9 +107,9 @@ void devres_add(struct udevice *dev, void *res) devres_log(dev, dr, "ADD"); assert_noisy(list_empty(&dr->entry)); - if (dev->flags & DM_FLAG_PLATDATA_VALID) + if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID) dr->phase = DEVRES_PHASE_PROBE; - else if (dev->flags & DM_FLAG_BOUND) + else if (dev_get_flags(dev) & DM_FLAG_BOUND) dr->phase = DEVRES_PHASE_OFDATA; else dr->phase = DEVRES_PHASE_BIND; diff --git a/drivers/core/dump.c b/drivers/core/dump.c index 6debaf97a1..f8afea30a9 100644 --- a/drivers/core/dump.c +++ b/drivers/core/dump.c @@ -14,11 +14,13 @@ static void show_devices(struct udevice *dev, int depth, int last_flag) { int i, is_last; struct udevice *child; + u32 flags = dev_get_flags(dev); /* print the first 20 characters to not break the tree-format. */ - printf(" %-10.10s %3d [ %c ] %-20.20s ", dev->uclass->uc_drv->name, + printf(IS_ENABLED(CONFIG_SPL_BUILD) ? " %s %d [ %c ] %s " : + " %-10.10s %3d [ %c ] %-20.20s ", dev->uclass->uc_drv->name, dev_get_uclass_index(dev, NULL), - dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name); + flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name); for (i = depth; i >= 0; i--) { is_last = (last_flag >> i) & 1; @@ -65,10 +67,10 @@ void dm_dump_all(void) static void dm_display_line(struct udevice *dev, int index) { printf("%-3i %c %s @ %08lx", index, - dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ', + dev_get_flags(dev) & DM_FLAG_ACTIVATED ? '*' : ' ', dev->name, (ulong)map_to_sysmem(dev)); - if (dev->seq != -1 || dev->req_seq != -1) - printf(", seq %d, (req %d)", dev->seq, dev->req_seq); + if (dev->seq_ != -1) + printf(", seq %d", dev_seq(dev)); puts("\n"); } @@ -170,6 +172,6 @@ void dm_dump_static_driver_info(void) puts("---------------------------------\n"); for (entry = drv; entry != drv + n_ents; entry++) { printf("%-25.25s @%08lx\n", entry->name, - (ulong)map_to_sysmem(entry->platdata)); + (ulong)map_to_sysmem(entry->plat)); } } diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c index 8b48aa5bc5..ed55f69de1 100644 --- a/drivers/core/fdtaddr.c +++ b/drivers/core/fdtaddr.c @@ -49,7 +49,7 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index) reg += index * (na + ns); - if (ns) { + if (ns || gd_size_cells_0()) { /* * Use the full-fledged translate function for complex * bus setups. diff --git a/drivers/core/lists.c b/drivers/core/lists.c index b23ee3030e..e214306b90 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -39,8 +39,8 @@ struct driver *lists_driver_lookup_name(const char *name) struct uclass_driver *lists_uclass_lookup(enum uclass_id id) { struct uclass_driver *uclass = - ll_entry_start(struct uclass_driver, uclass); - const int n_ents = ll_entry_count(struct uclass_driver, uclass); + ll_entry_start(struct uclass_driver, uclass_driver); + const int n_ents = ll_entry_count(struct uclass_driver, uclass_driver); struct uclass_driver *entry; for (entry = uclass; entry != uclass + n_ents; entry++) { @@ -251,7 +251,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, if (ret) { dm_warn("Error binding driver '%s': %d\n", entry->name, ret); - return ret; + return log_msg_ret("bind", ret); } else { found = true; if (devp) diff --git a/drivers/core/of_addr.c b/drivers/core/of_addr.c index ca34d84922..bbe80136ba 100644 --- a/drivers/core/of_addr.c +++ b/drivers/core/of_addr.c @@ -18,7 +18,8 @@ /* Max address size we deal with */ #define OF_MAX_ADDR_CELLS 4 #define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS) -#define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && (ns) > 0) +#define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && \ + ((ns) > 0 || gd_size_cells_0())) static struct of_bus *of_match_bus(struct device_node *np); @@ -162,11 +163,6 @@ const __be32 *of_get_address(const struct device_node *dev, int index, } EXPORT_SYMBOL(of_get_address); -static int of_empty_ranges_quirk(const struct device_node *np) -{ - return false; -} - static int of_translate_one(const struct device_node *parent, struct of_bus *bus, struct of_bus *pbus, __be32 *addr, int na, int ns, int pna, @@ -193,11 +189,8 @@ static int of_translate_one(const struct device_node *parent, * As far as we know, this damage only exists on Apple machines, so * This code is only enabled on powerpc. --gcl */ + ranges = of_get_property(parent, rprop, &rlen); - if (ranges == NULL && !of_empty_ranges_quirk(parent)) { - debug("no ranges; cannot translate\n"); - return 1; - } if (ranges == NULL || rlen == 0) { offset = of_read_number(addr, na); memset(addr, 0, pna * 4); diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index a68076bf35..7a5f4c0a73 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -226,6 +226,17 @@ int ofnode_read_u32_array(ofnode node, const char *propname, } } +#if !CONFIG_IS_ENABLED(DM_INLINE_OFNODE) +bool ofnode_is_enabled(ofnode node) +{ + if (ofnode_is_np(node)) { + return of_device_is_available(ofnode_to_np(node)); + } else { + return fdtdec_get_is_enabled(gd->fdt_blob, + ofnode_to_offset(node)); + } +} + ofnode ofnode_first_subnode(ofnode node) { assert(ofnode_valid(node)); @@ -245,6 +256,7 @@ ofnode ofnode_next_subnode(ofnode node) return offset_to_ofnode( fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node))); } +#endif /* !DM_INLINE_OFNODE */ ofnode ofnode_get_parent(ofnode node) { @@ -304,7 +316,8 @@ fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size) ns = of_n_size_cells(ofnode_to_np(node)); - if (IS_ENABLED(CONFIG_OF_TRANSLATE) && ns > 0) { + if (IS_ENABLED(CONFIG_OF_TRANSLATE) && + (ns > 0 || gd_size_cells_0())) { return of_translate_address(ofnode_to_np(node), prop_val); } else { na = of_n_addr_cells(ofnode_to_np(node)); @@ -678,8 +691,10 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property, ns = of_n_size_cells(np); *sizep = of_read_number(prop + na, ns); - if (CONFIG_IS_ENABLED(OF_TRANSLATE) && ns > 0) + if (CONFIG_IS_ENABLED(OF_TRANSLATE) && + (ns > 0 || gd_size_cells_0())) { return of_translate_address(np, prop); + } else return of_read_number(prop, na); } else { diff --git a/drivers/core/read.c b/drivers/core/read.c index 076125824c..4d9b5dd038 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -281,8 +281,10 @@ int dev_read_alias_seq(const struct udevice *dev, int *devnump) if (ofnode_is_np(node)) { ret = of_alias_get_id(ofnode_to_np(node), uc_name); - if (ret >= 0) + if (ret >= 0) { *devnump = ret; + ret = 0; + } } else { #if CONFIG_IS_ENABLED(OF_CONTROL) ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name, @@ -377,3 +379,9 @@ int dev_read_pci_bus_range(const struct udevice *dev, return 0; } + +int dev_decode_display_timing(const struct udevice *dev, int index, + struct display_timing *config) +{ + return ofnode_decode_display_timing(dev_ofnode(dev), index, config); +} diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index c2bed88eac..4baacabd01 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -60,8 +60,8 @@ static struct regmap *regmap_alloc(int count) } #if CONFIG_IS_ENABLED(OF_PLATDATA) -int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count, - struct regmap **mapp) +int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count, + struct regmap **mapp) { struct regmap_range *range; struct regmap *map; diff --git a/drivers/core/root.c b/drivers/core/root.c index 5f10d7a39c..2bfa75b472 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -45,8 +45,8 @@ void dm_fixup_for_gd_move(struct global_data *new_gd) { /* The sentinel node has moved, so update things that point to it */ if (gd->dm_root) { - new_gd->uclass_root.next->prev = &new_gd->uclass_root; - new_gd->uclass_root.prev->next = &new_gd->uclass_root; + new_gd->uclass_root->next->prev = new_gd->uclass_root; + new_gd->uclass_root->prev->next = new_gd->uclass_root; } } @@ -69,8 +69,8 @@ void fix_drivers(void) entry->remove += gd->reloc_off; if (entry->unbind) entry->unbind += gd->reloc_off; - if (entry->ofdata_to_platdata) - entry->ofdata_to_platdata += gd->reloc_off; + if (entry->of_to_plat) + entry->of_to_plat += gd->reloc_off; if (entry->child_post_bind) entry->child_post_bind += gd->reloc_off; if (entry->child_pre_probe) @@ -86,8 +86,8 @@ void fix_drivers(void) void fix_uclass(void) { struct uclass_driver *uclass = - ll_entry_start(struct uclass_driver, uclass); - const int n_ents = ll_entry_count(struct uclass_driver, uclass); + ll_entry_start(struct uclass_driver, uclass_driver); + const int n_ents = ll_entry_count(struct uclass_driver, uclass_driver); struct uclass_driver *entry; for (entry = uclass; entry != uclass + n_ents; entry++) { @@ -123,8 +123,8 @@ void fix_devices(void) struct driver_info *entry; for (entry = dev; entry != dev + n_ents; entry++) { - if (entry->platdata) - entry->platdata += gd->reloc_off; + if (entry->plat) + entry->plat += gd->reloc_off; } } @@ -132,11 +132,15 @@ int dm_init(bool of_live) { int ret; + if (IS_ENABLED(CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLS)) + gd->dm_flags |= GD_DM_FLG_SIZE_CELLS_0; + if (gd->dm_root) { dm_warn("Virtual root driver already exists!\n"); return -EINVAL; } - INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST); + gd->uclass_root = &DM_UCLASS_ROOT_S_NON_CONST; + INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST); if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) { fix_drivers(); @@ -147,12 +151,8 @@ int dm_init(bool of_live) ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST); if (ret) return ret; -#if CONFIG_IS_ENABLED(OF_CONTROL) - if (CONFIG_IS_ENABLED(OF_LIVE) && of_live) - DM_ROOT_NON_CONST->node = np_to_ofnode(gd_of_root()); - else - DM_ROOT_NON_CONST->node = offset_to_ofnode(0); -#endif + if (CONFIG_IS_ENABLED(OF_CONTROL)) + dev_set_ofnode(DM_ROOT_NON_CONST, ofnode_root()); ret = device_probe(DM_ROOT_NON_CONST); if (ret) return ret; @@ -178,7 +178,7 @@ int dm_remove_devices_flags(uint flags) } #endif -int dm_scan_platdata(bool pre_reloc_only) +int dm_scan_plat(bool pre_reloc_only) { int ret; @@ -203,33 +203,6 @@ int dm_scan_platdata(bool pre_reloc_only) } #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int dm_scan_fdt_live(struct udevice *parent, - const struct device_node *node_parent, - bool pre_reloc_only) -{ - struct device_node *np; - int ret = 0, err; - - for (np = node_parent->child; np; np = np->sibling) { - - if (!of_device_is_available(np)) { - pr_debug(" - ignoring disabled device\n"); - continue; - } - err = lists_bind_fdt(parent, np_to_ofnode(np), NULL, - pre_reloc_only); - if (err && !ret) { - ret = err; - debug("%s: ret=%d\n", np->name, ret); - } - } - - if (ret) - dm_warn("Some drivers failed to bind\n"); - - return ret; -} - /** * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node * @@ -237,28 +210,30 @@ static int dm_scan_fdt_live(struct udevice *parent, * for each one. * * @parent: Parent device for the devices that will be created - * @blob: Pointer to device tree blob - * @offset: Offset of node to scan + * @node: Node to scan * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC * flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -static int dm_scan_fdt_node(struct udevice *parent, const void *blob, - int offset, bool pre_reloc_only) +static int dm_scan_fdt_node(struct udevice *parent, ofnode parent_node, + bool pre_reloc_only) { int ret = 0, err; + ofnode node; - for (offset = fdt_first_subnode(blob, offset); - offset > 0; - offset = fdt_next_subnode(blob, offset)) { - const char *node_name = fdt_get_name(blob, offset, NULL); + if (!ofnode_valid(parent_node)) + return 0; + + for (node = ofnode_first_subnode(parent_node); + ofnode_valid(node); + node = ofnode_next_subnode(node)) { + const char *node_name = ofnode_get_name(node); - if (!fdtdec_get_is_enabled(blob, offset)) { + if (!ofnode_is_enabled(node)) { pr_debug(" - ignoring disabled device\n"); continue; } - err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL, - pre_reloc_only); + err = lists_bind_fdt(parent, node, NULL, pre_reloc_only); if (err && !ret) { ret = err; debug("%s: ret=%d\n", node_name, ret); @@ -273,43 +248,25 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, int dm_scan_fdt_dev(struct udevice *dev) { - if (!dev_of_valid(dev)) - return 0; - - if (of_live_active()) - return dm_scan_fdt_live(dev, dev_np(dev), - gd->flags & GD_FLG_RELOC ? false : true); - - return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), + return dm_scan_fdt_node(dev, dev_ofnode(dev), gd->flags & GD_FLG_RELOC ? false : true); } -int dm_scan_fdt(const void *blob, bool pre_reloc_only) +int dm_scan_fdt(bool pre_reloc_only) { - if (of_live_active()) - return dm_scan_fdt_live(gd->dm_root, gd_of_root(), - pre_reloc_only); - - return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only); + return dm_scan_fdt_node(gd->dm_root, ofnode_root(), pre_reloc_only); } -static int dm_scan_fdt_ofnode_path(const void *blob, const char *path, - bool pre_reloc_only) +static int dm_scan_fdt_ofnode_path(const char *path, bool pre_reloc_only) { ofnode node; node = ofnode_path(path); - if (!ofnode_valid(node)) - return 0; - - if (of_live_active()) - return dm_scan_fdt_live(gd->dm_root, node.np, pre_reloc_only); - return dm_scan_fdt_node(gd->dm_root, blob, node.of_offset, - pre_reloc_only); + return dm_scan_fdt_node(gd->dm_root, node, pre_reloc_only); } -int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) +int dm_extended_scan(bool pre_reloc_only) { int ret, i; const char * const nodes[] = { @@ -318,7 +275,7 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) "/firmware" }; - ret = dm_scan_fdt(blob, pre_reloc_only); + ret = dm_scan_fdt(pre_reloc_only); if (ret) { debug("dm_scan_fdt() failed: %d\n", ret); return ret; @@ -326,7 +283,7 @@ int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only) /* Some nodes aren't devices themselves but may contain some */ for (i = 0; i < ARRAY_SIZE(nodes); i++) { - ret = dm_scan_fdt_ofnode_path(blob, nodes[i], pre_reloc_only); + ret = dm_scan_fdt_ofnode_path(nodes[i], pre_reloc_only); if (ret) { debug("dm_scan_fdt() scan for %s failed: %d\n", nodes[i], ret); @@ -343,28 +300,30 @@ __weak int dm_scan_other(bool pre_reloc_only) return 0; } -int dm_init_and_scan(bool pre_reloc_only) +/** + * dm_scan() - Scan tables to bind devices + * + * Runs through the driver_info tables and binds the devices it finds. Then runs + * through the devicetree nodes. Finally calls dm_scan_other() to add any + * special devices + * + * @pre_reloc_only: If true, bind only nodes with special devicetree properties, + * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. + */ +static int dm_scan(bool pre_reloc_only) { int ret; - if (CONFIG_IS_ENABLED(OF_PLATDATA)) - dm_populate_phandle_data(); - - ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE)); + ret = dm_scan_plat(pre_reloc_only); if (ret) { - debug("dm_init() failed: %d\n", ret); - return ret; - } - ret = dm_scan_platdata(pre_reloc_only); - if (ret) { - debug("dm_scan_platdata() failed: %d\n", ret); + debug("dm_scan_plat() failed: %d\n", ret); return ret; } if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { - ret = dm_extended_scan_fdt(gd->fdt_blob, pre_reloc_only); + ret = dm_extended_scan(pre_reloc_only); if (ret) { - debug("dm_extended_scan_dt() failed: %d\n", ret); + debug("dm_extended_scan() failed: %d\n", ret); return ret; } } @@ -376,6 +335,24 @@ int dm_init_and_scan(bool pre_reloc_only) return 0; } +int dm_init_and_scan(bool pre_reloc_only) +{ + int ret; + + ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE)); + if (ret) { + debug("dm_init() failed: %d\n", ret); + return ret; + } + ret = dm_scan(pre_reloc_only); + if (ret) { + log_debug("dm_scan() failed: %d\n", ret); + return ret; + } + + return 0; +} + #ifdef CONFIG_ACPIGEN static int root_acpi_get_name(const struct udevice *dev, char *out_name) { diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c index 7cc1d46009..b0c2c20958 100644 --- a/drivers/core/simple-bus.c +++ b/drivers/core/simple-bus.c @@ -5,16 +5,11 @@ #include <common.h> #include <dm.h> - -struct simple_bus_plat { - u32 base; - u32 size; - u32 target; -}; +#include <dm/simple_bus.h> fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr) { - struct simple_bus_plat *plat = dev_get_uclass_platdata(dev); + struct simple_bus_plat *plat = dev_get_uclass_plat(dev); if (addr >= plat->base && addr < plat->base + plat->size) addr = (addr - plat->base) + plat->target; @@ -32,7 +27,7 @@ static int simple_bus_post_bind(struct udevice *dev) ret = dev_read_u32_array(dev, "ranges", cell, ARRAY_SIZE(cell)); if (!ret) { - struct simple_bus_plat *plat = dev_get_uclass_platdata(dev); + struct simple_bus_plat *plat = dev_get_uclass_plat(dev); plat->base = cell[0]; plat->target = cell[1]; @@ -47,18 +42,20 @@ UCLASS_DRIVER(simple_bus) = { .id = UCLASS_SIMPLE_BUS, .name = "simple_bus", .post_bind = simple_bus_post_bind, - .per_device_platdata_auto_alloc_size = sizeof(struct simple_bus_plat), + .per_device_plat_auto = sizeof(struct simple_bus_plat), }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id generic_simple_bus_ids[] = { { .compatible = "simple-bus" }, { .compatible = "simple-mfd" }, { } }; +#endif U_BOOT_DRIVER(simple_bus) = { .name = "simple_bus", .id = UCLASS_SIMPLE_BUS, - .of_match = generic_simple_bus_ids, + .of_match = of_match_ptr(generic_simple_bus_ids), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/core/simple-pm-bus.c b/drivers/core/simple-pm-bus.c index 51dc9b206f..7a18953cba 100644 --- a/drivers/core/simple-pm-bus.c +++ b/drivers/core/simple-pm-bus.c @@ -51,6 +51,6 @@ U_BOOT_DRIVER(simple_pm_bus_drv) = { .of_match = simple_pm_bus_ids, .probe = simple_pm_bus_probe, .remove = simple_pm_bus_remove, - .priv_auto_alloc_size = sizeof(struct clk_bulk), + .priv_auto = sizeof(struct clk_bulk), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index 567d0a4b50..cb33facc71 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -56,9 +56,9 @@ static int syscon_pre_probe(struct udevice *dev) * using OF_PLATDATA will need to ensure that this is true. */ #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct syscon_base_platdata *plat = dev_get_platdata(dev); + struct syscon_base_plat *plat = dev_get_plat(dev); - return regmap_init_mem_platdata(dev, plat->reg, ARRAY_SIZE(plat->reg), + return regmap_init_mem_plat(dev, plat->reg, ARRAY_SIZE(plat->reg), &priv->regmap); #else return regmap_init_mem(dev_ofnode(dev), &priv->regmap); @@ -174,7 +174,7 @@ void *syscon_get_first_range(ulong driver_data) UCLASS_DRIVER(syscon) = { .id = UCLASS_SYSCON, .name = "syscon", - .per_device_auto_alloc_size = sizeof(struct syscon_uc_info), + .per_device_auto = sizeof(struct syscon_uc_info), .pre_probe = syscon_pre_probe, }; diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index c3f1b73cd6..cdb975d5b3 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -33,7 +33,7 @@ struct uclass *uclass_find(enum uclass_id key) * node to the start of the list, or creating a linear array mapping * id to node. */ - list_for_each_entry(uc, &gd->uclass_root, sibling_node) { + list_for_each_entry(uc, gd->uclass_root, sibling_node) { if (uc->uc_drv->id == key) return uc; } @@ -71,17 +71,20 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp) uc = calloc(1, sizeof(*uc)); if (!uc) return -ENOMEM; - if (uc_drv->priv_auto_alloc_size) { - uc->priv = calloc(1, uc_drv->priv_auto_alloc_size); - if (!uc->priv) { + if (uc_drv->priv_auto) { + void *ptr; + + ptr = calloc(1, uc_drv->priv_auto); + if (!ptr) { ret = -ENOMEM; goto fail_mem; } + uclass_set_priv(uc, ptr); } uc->uc_drv = uc_drv; INIT_LIST_HEAD(&uc->sibling_node); INIT_LIST_HEAD(&uc->dev_head); - list_add(&uc->sibling_node, &DM_UCLASS_ROOT_NON_CONST); + list_add(&uc->sibling_node, DM_UCLASS_ROOT_NON_CONST); if (uc_drv->init) { ret = uc_drv->init(uc); @@ -93,9 +96,9 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp) return 0; fail: - if (uc_drv->priv_auto_alloc_size) { - free(uc->priv); - uc->priv = NULL; + if (uc_drv->priv_auto) { + free(uclass_get_priv(uc)); + uclass_set_priv(uc, NULL); } list_del(&uc->sibling_node); fail_mem: @@ -131,8 +134,8 @@ int uclass_destroy(struct uclass *uc) if (uc_drv->destroy) uc_drv->destroy(uc); list_del(&uc->sibling_node); - if (uc_drv->priv_auto_alloc_size) - free(uc->priv); + if (uc_drv->priv_auto) + free(uclass_get_priv(uc)); free(uc); return 0; @@ -160,6 +163,16 @@ const char *uclass_get_name(enum uclass_id id) return uc->uc_drv->name; } +void *uclass_get_priv(const struct uclass *uc) +{ + return uc->priv_; +} + +void uclass_set_priv(struct uclass *uc, void *priv) +{ + uc->priv_ = priv; +} + enum uclass_id uclass_get_by_name(const char *name) { int i; @@ -272,48 +285,46 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, return -ENODEV; } -int uclass_find_next_free_req_seq(enum uclass_id id) +int uclass_find_next_free_seq(struct uclass *uc) { - struct uclass *uc; struct udevice *dev; - int ret; int max = -1; - ret = uclass_get(id, &uc); - if (ret) - return ret; + /* If using aliases, start with the highest alias value */ + if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) && + (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) + max = dev_read_alias_highest_id(uc->uc_drv->name); + /* Avoid conflict with existing devices */ list_for_each_entry(dev, &uc->dev_head, uclass_node) { - if ((dev->req_seq != -1) && (dev->req_seq > max)) - max = dev->req_seq; + if (dev->seq_ > max) + max = dev->seq_; } - - if (max == -1) - return 0; + /* + * At this point, max will be -1 if there are no existing aliases or + * devices + */ return max + 1; } -int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp) +int uclass_find_device_by_seq(enum uclass_id id, int seq, struct udevice **devp) { struct uclass *uc; struct udevice *dev; int ret; *devp = NULL; - log_debug("%d %d\n", find_req_seq, seq_or_req_seq); - if (seq_or_req_seq == -1) + log_debug("%d\n", seq); + if (seq == -1) return -ENODEV; ret = uclass_get(id, &uc); if (ret) return ret; uclass_foreach_dev(dev, uc) { - log_debug(" - %d %d '%s'\n", - dev->req_seq, dev->seq, dev->name); - if ((find_req_seq ? dev->req_seq : dev->seq) == - seq_or_req_seq) { + log_debug(" - %d '%s'\n", dev->seq_, dev->name); + if (dev->seq_ == seq) { *devp = dev; log_debug(" - found\n"); return 0; @@ -473,14 +484,8 @@ int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp) int ret; *devp = NULL; - ret = uclass_find_device_by_seq(id, seq, false, &dev); - if (ret == -ENODEV) { - /* - * We didn't find it in probed devices. See if there is one - * that will request this seq if probed. - */ - ret = uclass_find_device_by_seq(id, seq, true, &dev); - } + ret = uclass_find_device_by_seq(id, seq, &dev); + return uclass_get_device_tail(dev, ret, devp); } @@ -687,46 +692,6 @@ int uclass_unbind_device(struct udevice *dev) } #endif -int uclass_resolve_seq(struct udevice *dev) -{ - struct uclass *uc = dev->uclass; - struct uclass_driver *uc_drv = uc->uc_drv; - struct udevice *dup; - int seq = 0; - int ret; - - assert(dev->seq == -1); - ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup); - if (!ret) { - dm_warn("Device '%s': seq %d is in use by '%s'\n", - dev->name, dev->req_seq, dup->name); - } else if (ret == -ENODEV) { - /* Our requested sequence number is available */ - if (dev->req_seq != -1) - return dev->req_seq; - } else { - return ret; - } - - if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS) && - (uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) { - /* - * dev_read_alias_highest_id() will return -1 if there no - * alias. Thus we can always add one. - */ - seq = dev_read_alias_highest_id(uc_drv->name) + 1; - } - - for (; seq < DM_MAX_SEQ; seq++) { - ret = uclass_find_device_by_seq(uc_drv->id, seq, false, &dup); - if (ret == -ENODEV) - break; - if (ret) - return ret; - } - return seq; -} - int uclass_pre_probe_device(struct udevice *dev) { struct uclass_driver *uc_drv; diff --git a/drivers/cpu/at91_cpu.c b/drivers/cpu/at91_cpu.c index 058ae3a811..9ef1b3102c 100644 --- a/drivers/cpu/at91_cpu.c +++ b/drivers/cpu/at91_cpu.c @@ -11,7 +11,7 @@ #include <div64.h> #include <linux/clk-provider.h> -struct at91_cpu_platdata { +struct at91_cpu_plat { const char *name; ulong cpufreq_mhz; ulong mckfreq_mhz; @@ -27,7 +27,7 @@ const char *at91_cpu_get_name(void) int at91_cpu_get_desc(const struct udevice *dev, char *buf, int size) { - struct at91_cpu_platdata *plat = dev_get_platdata(dev); + struct at91_cpu_plat *plat = dev_get_plat(dev); snprintf(buf, size, "%s\n" "Crystal frequency: %8lu MHz\n" @@ -41,7 +41,7 @@ int at91_cpu_get_desc(const struct udevice *dev, char *buf, int size) static int at91_cpu_get_info(const struct udevice *dev, struct cpu_info *info) { - struct at91_cpu_platdata *plat = dev_get_platdata(dev); + struct at91_cpu_plat *plat = dev_get_plat(dev); info->cpu_freq = plat->cpufreq_mhz * 1000000; info->features = BIT(CPU_FEAT_L1_CACHE); @@ -75,7 +75,7 @@ static const struct udevice_id at91_cpu_ids[] = { static int at91_cpu_probe(struct udevice *dev) { - struct at91_cpu_platdata *plat = dev_get_platdata(dev); + struct at91_cpu_plat *plat = dev_get_plat(dev); struct clk clk; ulong rate; int ret; @@ -118,6 +118,6 @@ U_BOOT_DRIVER(cpu_at91_drv) = { .of_match = at91_cpu_ids, .ops = &at91_cpu_ops, .probe = at91_cpu_probe, - .platdata_auto_alloc_size = sizeof(struct at91_cpu_platdata), + .plat_auto = sizeof(struct at91_cpu_plat), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/cpu/bmips_cpu.c b/drivers/cpu/bmips_cpu.c index 421cc7a9a4..172bc9980f 100644 --- a/drivers/cpu/bmips_cpu.c +++ b/drivers/cpu/bmips_cpu.c @@ -425,7 +425,7 @@ static const struct cpu_ops bmips_cpu_ops = { /* BMIPS CPU driver */ int bmips_cpu_bind(struct udevice *dev) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); plat->cpu_id = dev_read_u32_default(dev, "reg", -1); plat->device_id = read_c0_prid(); @@ -489,7 +489,7 @@ U_BOOT_DRIVER(bmips_cpu_drv) = { .of_match = bmips_cpu_ids, .bind = bmips_cpu_bind, .probe = bmips_cpu_probe, - .priv_auto_alloc_size = sizeof(struct bmips_cpu_priv), + .priv_auto = sizeof(struct bmips_cpu_priv), .ops = &bmips_cpu_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c index 37e3cf2d8f..1c338bad9a 100644 --- a/drivers/cpu/cpu-uclass.c +++ b/drivers/cpu/cpu-uclass.c @@ -115,7 +115,7 @@ int cpu_get_vendor(const struct udevice *dev, char *buf, int size) U_BOOT_DRIVER(cpu_bus) = { .name = "cpu_bus", .id = UCLASS_SIMPLE_BUS, - .per_child_platdata_auto_alloc_size = sizeof(struct cpu_platdata), + .per_child_plat_auto = sizeof(struct cpu_plat), }; static int uclass_cpu_init(struct uclass *uc) diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c index 4ba0d1b99e..fe6772ba5a 100644 --- a/drivers/cpu/cpu_sandbox.c +++ b/drivers/cpu/cpu_sandbox.c @@ -64,7 +64,7 @@ static const struct cpu_ops cpu_sandbox_ops = { static int cpu_sandbox_bind(struct udevice *dev) { int ret; - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); /* first examine the property in current cpu node */ ret = dev_read_u32(dev, "timebase-frequency", &plat->timebase_freq); diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 502c8ebb43..1d1e49efea 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -16,7 +16,7 @@ DECLARE_GLOBAL_DATA_PTR; -struct cpu_imx_platdata { +struct cpu_imx_plat { const char *name; const char *rev; const char *type; @@ -55,7 +55,7 @@ const char *get_imx8_rev(u32 rev) static void set_core_data(struct udevice *dev) { - struct cpu_imx_platdata *plat = dev_get_platdata(dev); + struct cpu_imx_plat *plat = dev_get_plat(dev); if (device_is_compatible(dev, "arm,cortex-a35")) { plat->cpu_rsrc = SC_R_A35; @@ -73,7 +73,7 @@ static void set_core_data(struct udevice *dev) } #if IS_ENABLED(CONFIG_IMX_SCU_THERMAL) -static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) +static int cpu_imx_get_temp(struct cpu_imx_plat *plat) { struct udevice *thermal_dev; int cpu_tmp, ret; @@ -94,7 +94,7 @@ static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) return cpu_tmp; } #else -static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) +static int cpu_imx_get_temp(struct cpu_imx_plat *plat) { return 0; } @@ -102,7 +102,7 @@ static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size) { - struct cpu_imx_platdata *plat = dev_get_platdata(dev); + struct cpu_imx_plat *plat = dev_get_plat(dev); int ret, temp; if (size < 100) @@ -128,7 +128,7 @@ int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size) static int cpu_imx_get_info(const struct udevice *dev, struct cpu_info *info) { - struct cpu_imx_platdata *plat = dev_get_platdata(dev); + struct cpu_imx_plat *plat = dev_get_plat(dev); info->cpu_freq = plat->freq_mhz * 1000; info->features = BIT(CPU_FEAT_L1_CACHE) | BIT(CPU_FEAT_MMU); @@ -165,7 +165,7 @@ static int cpu_imx_get_vendor(const struct udevice *dev, char *buf, int size) static int cpu_imx_is_current(struct udevice *dev) { - struct cpu_imx_platdata *plat = dev_get_platdata(dev); + struct cpu_imx_plat *plat = dev_get_plat(dev); if (plat->mpidr == (read_mpidr() & 0xffff)) return 1; @@ -190,7 +190,7 @@ static const struct udevice_id cpu_imx8_ids[] = { static ulong imx8_get_cpu_rate(struct udevice *dev) { - struct cpu_imx_platdata *plat = dev_get_platdata(dev); + struct cpu_imx_plat *plat = dev_get_plat(dev); ulong rate; int ret; @@ -206,7 +206,7 @@ static ulong imx8_get_cpu_rate(struct udevice *dev) static int imx8_cpu_probe(struct udevice *dev) { - struct cpu_imx_platdata *plat = dev_get_platdata(dev); + struct cpu_imx_plat *plat = dev_get_plat(dev); u32 cpurev; set_core_data(dev); @@ -230,6 +230,6 @@ U_BOOT_DRIVER(cpu_imx8_drv) = { .of_match = cpu_imx8_ids, .ops = &cpu_imx8_ops, .probe = imx8_cpu_probe, - .platdata_auto_alloc_size = sizeof(struct cpu_imx_platdata), + .plat_auto = sizeof(struct cpu_imx_plat), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c index 5f1592f9ad..e451c11116 100644 --- a/drivers/cpu/mpc83xx_cpu.c +++ b/drivers/cpu/mpc83xx_cpu.c @@ -348,7 +348,7 @@ U_BOOT_DRIVER(mpc83xx_cpu) = { .id = UCLASS_CPU, .of_match = mpc83xx_cpu_ids, .probe = mpc83xx_cpu_probe, - .priv_auto_alloc_size = sizeof(struct mpc83xx_cpu_priv), + .priv_auto = sizeof(struct mpc83xx_cpu_priv), .ops = &mpc83xx_cpu_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c index 93ce708f65..0b10c173a3 100644 --- a/drivers/cpu/riscv_cpu.c +++ b/drivers/cpu/riscv_cpu.c @@ -91,7 +91,7 @@ static int riscv_cpu_get_count(const struct udevice *dev) static int riscv_cpu_bind(struct udevice *dev) { - struct cpu_platdata *plat = dev_get_parent_platdata(dev); + struct cpu_plat *plat = dev_get_parent_plat(dev); struct driver *drv; int ret; diff --git a/drivers/crypto/fsl/fsl_rsa.c b/drivers/crypto/fsl/fsl_rsa.c index ed2a54f6ec..897ee855ea 100644 --- a/drivers/crypto/fsl/fsl_rsa.c +++ b/drivers/crypto/fsl/fsl_rsa.c @@ -55,6 +55,6 @@ U_BOOT_DRIVER(fsl_rsa_mod_exp) = { .ops = &fsl_mod_exp_ops, }; -U_BOOT_DEVICE(fsl_rsa) = { +U_BOOT_DRVINFO(fsl_rsa) = { .name = "fsl_rsa_mod_exp", }; diff --git a/drivers/crypto/fsl/rng.c b/drivers/crypto/fsl/rng.c index 3c0c2b067f..0636494805 100644 --- a/drivers/crypto/fsl/rng.c +++ b/drivers/crypto/fsl/rng.c @@ -83,6 +83,6 @@ U_BOOT_DRIVER(caam_rng) = { .id = UCLASS_RNG, .ops = &caam_rng_ops, .probe = caam_rng_probe, - .priv_auto_alloc_size = sizeof(struct caam_rng_priv), + .priv_auto = sizeof(struct caam_rng_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_sw.c b/drivers/crypto/rsa_mod_exp/mod_exp_sw.c index 4ce85b3224..7bed444c3f 100644 --- a/drivers/crypto/rsa_mod_exp/mod_exp_sw.c +++ b/drivers/crypto/rsa_mod_exp/mod_exp_sw.c @@ -35,6 +35,6 @@ U_BOOT_DRIVER(mod_exp_sw) = { .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DEVICE(mod_exp_sw) = { +U_BOOT_DRVINFO(mod_exp_sw) = { .name = "mod_exp_sw", }; diff --git a/drivers/ddr/altera/sdram_agilex.c b/drivers/ddr/altera/sdram_agilex.c index d6e7a175d0..a4ceb36461 100644 --- a/drivers/ddr/altera/sdram_agilex.c +++ b/drivers/ddr/altera/sdram_agilex.c @@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR; int sdram_mmr_init_full(struct udevice *dev) { - struct altera_sdram_platdata *plat = dev->platdata; + struct altera_sdram_plat *plat = dev_get_plat(dev); struct altera_sdram_priv *priv = dev_get_priv(dev); u32 i; int ret; diff --git a/drivers/ddr/altera/sdram_gen5.c b/drivers/ddr/altera/sdram_gen5.c index 1360bd0a3b..8d3ce495de 100644 --- a/drivers/ddr/altera/sdram_gen5.c +++ b/drivers/ddr/altera/sdram_gen5.c @@ -27,7 +27,7 @@ struct altera_gen5_sdram_priv { struct ram_info info; }; -struct altera_gen5_sdram_platdata { +struct altera_gen5_sdram_plat { struct socfpga_sdr *sdr; }; @@ -563,9 +563,9 @@ static unsigned long sdram_calculate_size(struct socfpga_sdr_ctrl *sdr_ctrl) return temp; } -static int altera_gen5_sdram_ofdata_to_platdata(struct udevice *dev) +static int altera_gen5_sdram_of_to_plat(struct udevice *dev) { - struct altera_gen5_sdram_platdata *plat = dev->platdata; + struct altera_gen5_sdram_plat *plat = dev_get_plat(dev); plat->sdr = (struct socfpga_sdr *)devfdt_get_addr_index(dev, 0); if (!plat->sdr) @@ -578,7 +578,7 @@ static int altera_gen5_sdram_probe(struct udevice *dev) { int ret; unsigned long sdram_size; - struct altera_gen5_sdram_platdata *plat = dev->platdata; + struct altera_gen5_sdram_plat *plat = dev_get_plat(dev); struct altera_gen5_sdram_priv *priv = dev_get_priv(dev); struct socfpga_sdr_ctrl *sdr_ctrl = &plat->sdr->sdr_ctrl; struct reset_ctl_bulk resets; @@ -646,10 +646,10 @@ U_BOOT_DRIVER(altera_gen5_sdram) = { .id = UCLASS_RAM, .of_match = altera_gen5_sdram_ids, .ops = &altera_gen5_sdram_ops, - .ofdata_to_platdata = altera_gen5_sdram_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_gen5_sdram_platdata), + .of_to_plat = altera_gen5_sdram_of_to_plat, + .plat_auto = sizeof(struct altera_gen5_sdram_plat), .probe = altera_gen5_sdram_probe, - .priv_auto_alloc_size = sizeof(struct altera_gen5_sdram_priv), + .priv_auto = sizeof(struct altera_gen5_sdram_priv), }; #endif /* CONFIG_SPL_BUILD */ diff --git a/drivers/ddr/altera/sdram_s10.c b/drivers/ddr/altera/sdram_s10.c index 2945f1e1df..03a270f263 100644 --- a/drivers/ddr/altera/sdram_s10.c +++ b/drivers/ddr/altera/sdram_s10.c @@ -70,7 +70,7 @@ int match_ddr_conf(u32 ddr_conf) */ int sdram_mmr_init_full(struct udevice *dev) { - struct altera_sdram_platdata *plat = dev->platdata; + struct altera_sdram_plat *plat = dev_get_plat(dev); struct altera_sdram_priv *priv = dev_get_priv(dev); u32 update_value, io48_value, ddrioctl; u32 i; diff --git a/drivers/ddr/altera/sdram_soc64.c b/drivers/ddr/altera/sdram_soc64.c index 8cb75fe02a..5aba655e5f 100644 --- a/drivers/ddr/altera/sdram_soc64.c +++ b/drivers/ddr/altera/sdram_soc64.c @@ -27,29 +27,29 @@ #define PGTABLE_OFF 0x4000 -u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg) +u32 hmc_readl(struct altera_sdram_plat *plat, u32 reg) { return readl(plat->iomhc + reg); } -u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg) +u32 hmc_ecc_readl(struct altera_sdram_plat *plat, u32 reg) { return readl(plat->hmc + reg); } -u32 hmc_ecc_writel(struct altera_sdram_platdata *plat, +u32 hmc_ecc_writel(struct altera_sdram_plat *plat, u32 data, u32 reg) { return writel(data, plat->hmc + reg); } -u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data, +u32 ddr_sch_writel(struct altera_sdram_plat *plat, u32 data, u32 reg) { return writel(data, plat->ddr_sch + reg); } -int emif_clear(struct altera_sdram_platdata *plat) +int emif_clear(struct altera_sdram_plat *plat) { hmc_ecc_writel(plat, 0, RSTHANDSHAKECTRL); @@ -59,7 +59,7 @@ int emif_clear(struct altera_sdram_platdata *plat) false, 1000, false); } -int emif_reset(struct altera_sdram_platdata *plat) +int emif_reset(struct altera_sdram_plat *plat) { u32 c2s, s2c, ret; @@ -214,7 +214,7 @@ void sdram_size_check(struct bd_info *bd) * Calculate SDRAM device size based on SDRAM controller parameters. * Size is specified in bytes. */ -phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat) +phys_size_t sdram_calculate_size(struct altera_sdram_plat *plat) { u32 dramaddrw = hmc_readl(plat, DRAMADDRW); @@ -230,9 +230,9 @@ phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat) return size; } -static int altera_sdram_ofdata_to_platdata(struct udevice *dev) +static int altera_sdram_of_to_plat(struct udevice *dev) { - struct altera_sdram_platdata *plat = dev->platdata; + struct altera_sdram_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr_index(dev, 0); @@ -303,8 +303,8 @@ U_BOOT_DRIVER(altera_sdram) = { .id = UCLASS_RAM, .of_match = altera_sdram_ids, .ops = &altera_sdram_ops, - .ofdata_to_platdata = altera_sdram_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_sdram_platdata), + .of_to_plat = altera_sdram_of_to_plat, + .plat_auto = sizeof(struct altera_sdram_plat), .probe = altera_sdram_probe, - .priv_auto_alloc_size = sizeof(struct altera_sdram_priv), + .priv_auto = sizeof(struct altera_sdram_priv), }; diff --git a/drivers/ddr/altera/sdram_soc64.h b/drivers/ddr/altera/sdram_soc64.h index 4a830e7ec1..8af0afc410 100644 --- a/drivers/ddr/altera/sdram_soc64.h +++ b/drivers/ddr/altera/sdram_soc64.h @@ -14,7 +14,7 @@ struct altera_sdram_priv { struct reset_ctl_bulk resets; }; -struct altera_sdram_platdata { +struct altera_sdram_plat { void __iomem *hmc; void __iomem *ddr_sch; void __iomem *iomhc; @@ -169,19 +169,19 @@ struct altera_sdram_platdata { #define FW_HMC_ADAPTOR_REG_ADDR 0xf8020004 #define FW_HMC_ADAPTOR_MPU_MASK BIT(0) -u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg); -u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg); -u32 hmc_ecc_writel(struct altera_sdram_platdata *plat, +u32 hmc_readl(struct altera_sdram_plat *plat, u32 reg); +u32 hmc_ecc_readl(struct altera_sdram_plat *plat, u32 reg); +u32 hmc_ecc_writel(struct altera_sdram_plat *plat, u32 data, u32 reg); -u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data, +u32 ddr_sch_writel(struct altera_sdram_plat *plat, u32 data, u32 reg); -int emif_clear(struct altera_sdram_platdata *plat); -int emif_reset(struct altera_sdram_platdata *plat); +int emif_clear(struct altera_sdram_plat *plat); +int emif_reset(struct altera_sdram_plat *plat); int poll_hmc_clock_status(void); void sdram_clear_mem(phys_addr_t addr, phys_size_t size); void sdram_init_ecc_bits(struct bd_info *bd); void sdram_size_check(struct bd_info *bd); -phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat); +phys_size_t sdram_calculate_size(struct altera_sdram_plat *plat); int sdram_mmr_init_full(struct udevice *dev); #endif /* _SDRAM_SOC64_H_ */ diff --git a/drivers/demo/demo-pdata.c b/drivers/demo/demo-pdata.c index 2f434f8db0..818f77503a 100644 --- a/drivers/demo/demo-pdata.c +++ b/drivers/demo/demo-pdata.c @@ -20,27 +20,27 @@ static const struct dm_demo_pdata yellow_hexagon = { .sides = 6. }; -U_BOOT_DEVICE(demo0) = { +U_BOOT_DRVINFO(demo0) = { .name = "demo_shape_drv", - .platdata = &red_square, + .plat = &red_square, }; -U_BOOT_DEVICE(demo1) = { +U_BOOT_DRVINFO(demo1) = { .name = "demo_simple_drv", - .platdata = &red_square, + .plat = &red_square, }; -U_BOOT_DEVICE(demo2) = { +U_BOOT_DRVINFO(demo2) = { .name = "demo_shape_drv", - .platdata = &green_triangle, + .plat = &green_triangle, }; -U_BOOT_DEVICE(demo3) = { +U_BOOT_DRVINFO(demo3) = { .name = "demo_simple_drv", - .platdata = &yellow_hexagon, + .plat = &yellow_hexagon, }; -U_BOOT_DEVICE(demo4) = { +U_BOOT_DRVINFO(demo4) = { .name = "demo_shape_drv", - .platdata = &yellow_hexagon, + .plat = &yellow_hexagon, }; diff --git a/drivers/demo/demo-shape.c b/drivers/demo/demo-shape.c index 8686c99845..8129317ba1 100644 --- a/drivers/demo/demo-shape.c +++ b/drivers/demo/demo-shape.c @@ -28,7 +28,7 @@ struct shape_data { /* Crazy little function to draw shapes on the console */ static int shape_hello(struct udevice *dev, int ch) { - const struct dm_demo_pdata *pdata = dev_get_platdata(dev); + const struct dm_demo_pdata *pdata = dev_get_plat(dev); struct shape_data *data = dev_get_priv(dev); static const struct shape { int start; @@ -140,9 +140,9 @@ static const struct demo_ops shape_ops = { .set_light = set_light, }; -static int shape_ofdata_to_platdata(struct udevice *dev) +static int shape_of_to_plat(struct udevice *dev) { - struct dm_demo_pdata *pdata = dev_get_platdata(dev); + struct dm_demo_pdata *pdata = dev_get_plat(dev); int ret; /* Parse the data that is common with all demo devices */ @@ -189,10 +189,10 @@ U_BOOT_DRIVER(demo_shape_drv) = { .name = "demo_shape_drv", .of_match = demo_shape_id, .id = UCLASS_DEMO, - .ofdata_to_platdata = shape_ofdata_to_platdata, + .of_to_plat = shape_of_to_plat, .ops = &shape_ops, .probe = dm_shape_probe, .remove = dm_shape_remove, - .priv_auto_alloc_size = sizeof(struct shape_data), - .platdata_auto_alloc_size = sizeof(struct dm_demo_pdata), + .priv_auto = sizeof(struct shape_data), + .plat_auto = sizeof(struct dm_demo_pdata), }; diff --git a/drivers/demo/demo-simple.c b/drivers/demo/demo-simple.c index 68972c780f..28b271f779 100644 --- a/drivers/demo/demo-simple.c +++ b/drivers/demo/demo-simple.c @@ -14,7 +14,7 @@ static int simple_hello(struct udevice *dev, int ch) { - const struct dm_demo_pdata *pdata = dev_get_platdata(dev); + const struct dm_demo_pdata *pdata = dev_get_plat(dev); printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour, pdata->sides); @@ -26,7 +26,7 @@ static const struct demo_ops simple_ops = { .hello = simple_hello, }; -static int demo_shape_ofdata_to_platdata(struct udevice *dev) +static int demo_shape_of_to_plat(struct udevice *dev) { /* Parse the data that is common with all demo devices */ return demo_parse_dt(dev); @@ -41,7 +41,7 @@ U_BOOT_DRIVER(demo_simple_drv) = { .name = "demo_simple_drv", .of_match = demo_shape_id, .id = UCLASS_DEMO, - .ofdata_to_platdata = demo_shape_ofdata_to_platdata, + .of_to_plat = demo_shape_of_to_plat, .ops = &simple_ops, - .platdata_auto_alloc_size = sizeof(struct dm_demo_pdata), + .plat_auto = sizeof(struct dm_demo_pdata), }; diff --git a/drivers/demo/demo-uclass.c b/drivers/demo/demo-uclass.c index 6c36f03254..a020ecb24f 100644 --- a/drivers/demo/demo-uclass.c +++ b/drivers/demo/demo-uclass.c @@ -65,7 +65,7 @@ int demo_set_light(struct udevice *dev, int light) int demo_parse_dt(struct udevice *dev) { - struct dm_demo_pdata *pdata = dev_get_platdata(dev); + struct dm_demo_pdata *pdata = dev_get_plat(dev); int dn = dev_of_offset(dev); pdata->sides = fdtdec_get_int(gd->fdt_blob, dn, "sides", 0); diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c index 36cd4e945b..b34975dbb0 100644 --- a/drivers/dfu/dfu_mtd.c +++ b/drivers/dfu/dfu_mtd.c @@ -21,7 +21,7 @@ static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size) static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu, u64 offset, void *buf, long *len) { - u64 off, lim, remaining; + u64 off, lim, remaining, lock_ofs, lock_len; struct mtd_info *mtd = dfu->data.mtd.info; struct mtd_oob_ops io_op = {}; int ret = 0; @@ -34,7 +34,7 @@ static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu, return 0; } - off = dfu->data.mtd.start + offset + dfu->bad_skip; + off = lock_ofs = dfu->data.mtd.start + offset + dfu->bad_skip; lim = dfu->data.mtd.start + dfu->data.mtd.size; if (off >= lim) { @@ -56,12 +56,19 @@ static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu, if (op == DFU_OP_WRITE) { struct erase_info erase_op = {}; - remaining = round_up(*len, mtd->erasesize); + remaining = lock_len = round_up(*len, mtd->erasesize); erase_op.mtd = mtd; erase_op.addr = off; erase_op.len = mtd->erasesize; erase_op.scrub = 0; + debug("Unlocking the mtd device\n"); + ret = mtd_unlock(mtd, lock_ofs, lock_len); + if (ret && ret != -EOPNOTSUPP) { + printf("MTD device unlock failed\n"); + return 0; + } + while (remaining) { if (erase_op.addr + remaining > lim) { printf("Limit reached 0x%llx while erasing at offset 0x%llx\n", @@ -139,6 +146,13 @@ static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu, io_op.len = mtd->writesize; } + if (op == DFU_OP_WRITE) { + /* Write done, lock again */ + debug("Locking the mtd device\n"); + ret = mtd_lock(mtd, lock_ofs, lock_len); + if (ret && ret != -EOPNOTSUPP) + printf("MTD device lock failed\n"); + } return ret; } diff --git a/drivers/dma/bcm6348-iudma.c b/drivers/dma/bcm6348-iudma.c index 91172d483c..98577601b5 100644 --- a/drivers/dma/bcm6348-iudma.c +++ b/drivers/dma/bcm6348-iudma.c @@ -649,6 +649,6 @@ U_BOOT_DRIVER(bcm6348_iudma) = { .id = UCLASS_DMA, .of_match = bcm6348_iudma_ids, .ops = &bcm6348_iudma_ops, - .priv_auto_alloc_size = sizeof(struct bcm6348_iudma_priv), + .priv_auto = sizeof(struct bcm6348_iudma_priv), .probe = bcm6348_iudma_probe, }; diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c index 50403148d6..a93b0b7ba0 100644 --- a/drivers/dma/dma-uclass.c +++ b/drivers/dma/dma-uclass.c @@ -254,5 +254,5 @@ UCLASS_DRIVER(dma) = { .id = UCLASS_DMA, .name = "dma", .flags = DM_UC_FLAG_SEQ_ALIAS, - .per_device_auto_alloc_size = sizeof(struct dma_dev_priv), + .per_device_auto = sizeof(struct dma_dev_priv), }; diff --git a/drivers/dma/sandbox-dma-test.c b/drivers/dma/sandbox-dma-test.c index 838596b24b..aebf3eef96 100644 --- a/drivers/dma/sandbox-dma-test.c +++ b/drivers/dma/sandbox-dma-test.c @@ -280,5 +280,5 @@ U_BOOT_DRIVER(sandbox_dma) = { .of_match = sandbox_dma_ids, .ops = &sandbox_dma_ops, .probe = sandbox_dma_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_dma_dev), + .priv_auto = sizeof(struct sandbox_dma_dev), }; diff --git a/drivers/dma/ti-edma3.c b/drivers/dma/ti-edma3.c index 13ab967089..ec3dc62d2f 100644 --- a/drivers/dma/ti-edma3.c +++ b/drivers/dma/ti-edma3.c @@ -542,7 +542,7 @@ static int ti_edma3_transfer(struct udevice *dev, int direction, void *dst, return 0; } -static int ti_edma3_ofdata_to_platdata(struct udevice *dev) +static int ti_edma3_of_to_plat(struct udevice *dev) { struct ti_edma3_priv *priv = dev_get_priv(dev); @@ -574,8 +574,8 @@ U_BOOT_DRIVER(ti_edma3) = { .id = UCLASS_DMA, .of_match = ti_edma3_ids, .ops = &ti_edma3_ops, - .ofdata_to_platdata = ti_edma3_ofdata_to_platdata, + .of_to_plat = ti_edma3_of_to_plat, .probe = ti_edma3_probe, - .priv_auto_alloc_size = sizeof(struct ti_edma3_priv), + .priv_auto = sizeof(struct ti_edma3_priv), }; #endif /* CONFIG_DMA */ diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 94216045cc..f3ec827897 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -1933,5 +1933,5 @@ U_BOOT_DRIVER(ti_edma3) = { .of_match = udma_ids, .ops = &udma_ops, .probe = udma_probe, - .priv_auto_alloc_size = sizeof(struct udma_dev), + .priv_auto = sizeof(struct udma_dev), }; diff --git a/drivers/firmware/scmi/mailbox_agent.c b/drivers/firmware/scmi/mailbox_agent.c index a85cff1097..3f4b04a4ae 100644 --- a/drivers/firmware/scmi/mailbox_agent.c +++ b/drivers/firmware/scmi/mailbox_agent.c @@ -97,7 +97,7 @@ U_BOOT_DRIVER(scmi_mbox) = { .name = "scmi-over-mailbox", .id = UCLASS_SCMI_AGENT, .of_match = scmi_mbox_ids, - .priv_auto_alloc_size = sizeof(struct scmi_mbox_channel), + .priv_auto = sizeof(struct scmi_mbox_channel), .probe = scmi_mbox_probe, .ops = &scmi_mbox_ops, }; diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index 5b6a4232af..35de68c75d 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -403,7 +403,7 @@ U_BOOT_DRIVER(sandbox_scmi_agent) = { .name = "sandbox-scmi_agent", .id = UCLASS_SCMI_AGENT, .of_match = sandbox_scmi_test_ids, - .priv_auto_alloc_size = sizeof(struct sandbox_scmi_agent), + .priv_auto = sizeof(struct sandbox_scmi_agent), .probe = sandbox_scmi_test_probe, .remove = sandbox_scmi_test_remove, .ops = &sandbox_scmi_test_ops, diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c b/drivers/firmware/scmi/sandbox-scmi_devices.c index c69967bf69..414da6f4df 100644 --- a/drivers/firmware/scmi/sandbox-scmi_devices.c +++ b/drivers/firmware/scmi/sandbox-scmi_devices.c @@ -107,7 +107,7 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = { .name = "sandbox-scmi_devices", .id = UCLASS_MISC, .of_match = sandbox_scmi_devices_ids, - .priv_auto_alloc_size = sizeof(struct sandbox_scmi_device_priv), + .priv_auto = sizeof(struct sandbox_scmi_device_priv), .remove = sandbox_scmi_devices_remove, .probe = sandbox_scmi_devices_probe, }; diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index 7dc533149b..516e690ac2 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -73,11 +73,11 @@ static int scmi_bind_protocols(struct udevice *dev) switch (protocol_id) { case SCMI_PROTOCOL_ID_CLOCK: if (IS_ENABLED(CONFIG_CLK_SCMI)) - drv = DM_GET_DRIVER(scmi_clock); + drv = DM_DRIVER_GET(scmi_clock); break; case SCMI_PROTOCOL_ID_RESET_DOMAIN: if (IS_ENABLED(CONFIG_RESET_SCMI)) - drv = DM_GET_DRIVER(scmi_reset_domain); + drv = DM_DRIVER_GET(scmi_reset_domain); break; default: break; @@ -89,8 +89,8 @@ static int scmi_bind_protocols(struct udevice *dev) continue; } - ret = device_bind_ofnode(dev, drv, ofnode_get_name(node), - NULL, node, NULL); + ret = device_bind(dev, drv, ofnode_get_name(node), NULL, node, + NULL); if (ret) break; } diff --git a/drivers/firmware/scmi/smccc_agent.c b/drivers/firmware/scmi/smccc_agent.c index 85dbf9195e..64d0929f69 100644 --- a/drivers/firmware/scmi/smccc_agent.c +++ b/drivers/firmware/scmi/smccc_agent.c @@ -83,7 +83,7 @@ U_BOOT_DRIVER(scmi_smccc) = { .name = "scmi-over-smccc", .id = UCLASS_SCMI_AGENT, .of_match = scmi_smccc_ids, - .priv_auto_alloc_size = sizeof(struct scmi_smccc_channel), + .priv_auto = sizeof(struct scmi_smccc_channel), .probe = scmi_smccc_probe, .ops = &scmi_smccc_ops, }; diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index a2beb0079d..0cdfb0e91a 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3166,5 +3166,5 @@ U_BOOT_DRIVER(ti_sci) = { .id = UCLASS_FIRMWARE, .of_match = ti_sci_ids, .probe = ti_sci_probe, - .priv_auto_alloc_size = sizeof(struct ti_sci_info), + .priv_auto = sizeof(struct ti_sci_info), }; diff --git a/drivers/gpio/74x164_gpio.c b/drivers/gpio/74x164_gpio.c index 64717a6780..0c06301a81 100644 --- a/drivers/gpio/74x164_gpio.c +++ b/drivers/gpio/74x164_gpio.c @@ -187,6 +187,6 @@ U_BOOT_DRIVER(74x164) = { .id = UCLASS_GPIO, .ops = &gen_74x164_ops, .probe = gen_74x164_probe, - .priv_auto_alloc_size = sizeof(struct gen_74x164_priv), + .priv_auto = sizeof(struct gen_74x164_priv), .of_match = gen_74x164_ids, }; diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c index 75800d9f31..f4582b1467 100644 --- a/drivers/gpio/altera_pio.c +++ b/drivers/gpio/altera_pio.c @@ -19,7 +19,7 @@ struct altera_pio_regs { u32 direction; /* Direction register */ }; -struct altera_pio_platdata { +struct altera_pio_plat { struct altera_pio_regs *regs; int gpio_count; const char *bank_name; @@ -27,7 +27,7 @@ struct altera_pio_platdata { static int altera_pio_direction_input(struct udevice *dev, unsigned pin) { - struct altera_pio_platdata *plat = dev_get_platdata(dev); + struct altera_pio_plat *plat = dev_get_plat(dev); struct altera_pio_regs *const regs = plat->regs; clrbits_le32(®s->direction, 1 << pin); @@ -38,7 +38,7 @@ static int altera_pio_direction_input(struct udevice *dev, unsigned pin) static int altera_pio_direction_output(struct udevice *dev, unsigned pin, int val) { - struct altera_pio_platdata *plat = dev_get_platdata(dev); + struct altera_pio_plat *plat = dev_get_plat(dev); struct altera_pio_regs *const regs = plat->regs; if (val) @@ -53,7 +53,7 @@ static int altera_pio_direction_output(struct udevice *dev, unsigned pin, static int altera_pio_get_value(struct udevice *dev, unsigned pin) { - struct altera_pio_platdata *plat = dev_get_platdata(dev); + struct altera_pio_plat *plat = dev_get_plat(dev); struct altera_pio_regs *const regs = plat->regs; return !!(readl(®s->data) & (1 << pin)); @@ -62,7 +62,7 @@ static int altera_pio_get_value(struct udevice *dev, unsigned pin) static int altera_pio_set_value(struct udevice *dev, unsigned pin, int val) { - struct altera_pio_platdata *plat = dev_get_platdata(dev); + struct altera_pio_plat *plat = dev_get_plat(dev); struct altera_pio_regs *const regs = plat->regs; if (val) @@ -76,7 +76,7 @@ static int altera_pio_set_value(struct udevice *dev, unsigned pin, int val) static int altera_pio_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - struct altera_pio_platdata *plat = dev_get_platdata(dev); + struct altera_pio_plat *plat = dev_get_plat(dev); uc_priv->gpio_count = plat->gpio_count; uc_priv->bank_name = plat->bank_name; @@ -84,9 +84,9 @@ static int altera_pio_probe(struct udevice *dev) return 0; } -static int altera_pio_ofdata_to_platdata(struct udevice *dev) +static int altera_pio_of_to_plat(struct udevice *dev) { - struct altera_pio_platdata *plat = dev_get_platdata(dev); + struct altera_pio_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_pio_regs), @@ -116,7 +116,7 @@ U_BOOT_DRIVER(altera_pio) = { .id = UCLASS_GPIO, .of_match = altera_pio_ids, .ops = &altera_pio_ops, - .ofdata_to_platdata = altera_pio_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_pio_platdata), + .of_to_plat = altera_pio_of_to_plat, + .plat_auto = sizeof(struct altera_pio_plat), .probe = altera_pio_probe, }; diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c index ef7984374b..1409db5dc1 100644 --- a/drivers/gpio/at91_gpio.c +++ b/drivers/gpio/at91_gpio.c @@ -590,7 +590,7 @@ static const struct dm_gpio_ops gpio_at91_ops = { static int at91_gpio_probe(struct udevice *dev) { struct at91_port_priv *port = dev_get_priv(dev); - struct at91_port_platdata *plat = dev_get_platdata(dev); + struct at91_port_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct clk clk; int ret; @@ -629,10 +629,10 @@ U_BOOT_DRIVER(atmel_at91rm9200_gpio) = { .id = UCLASS_GPIO, #if CONFIG_IS_ENABLED(OF_CONTROL) .of_match = at91_gpio_ids, - .platdata_auto_alloc_size = sizeof(struct at91_port_platdata), + .plat_auto = sizeof(struct at91_port_plat), #endif .ops = &gpio_at91_ops, .probe = at91_gpio_probe, - .priv_auto_alloc_size = sizeof(struct at91_port_priv), + .priv_auto = sizeof(struct at91_port_priv), }; #endif diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c index 18f365fa41..e7b8f231cc 100644 --- a/drivers/gpio/atmel_pio4.c +++ b/drivers/gpio/atmel_pio4.c @@ -176,14 +176,14 @@ struct atmel_pioctrl_data { u32 nbanks; }; -struct atmel_pio4_platdata { +struct atmel_pio4_plat { struct atmel_pio4_port *reg_base; }; static struct atmel_pio4_port *atmel_pio4_bank_base(struct udevice *dev, u32 bank) { - struct atmel_pio4_platdata *plat = dev_get_platdata(dev); + struct atmel_pio4_plat *plat = dev_get_plat(dev); struct atmel_pio4_port *port_base = (struct atmel_pio4_port *)((u32)plat->reg_base + ATMEL_PIO_BANK_OFFSET * bank); @@ -281,7 +281,7 @@ static int atmel_pio4_bind(struct udevice *dev) static int atmel_pio4_probe(struct udevice *dev) { - struct atmel_pio4_platdata *plat = dev_get_platdata(dev); + struct atmel_pio4_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct atmel_pioctrl_data *pioctrl_data; struct clk clk; @@ -338,7 +338,7 @@ U_BOOT_DRIVER(gpio_atmel_pio4) = { .probe = atmel_pio4_probe, .bind = atmel_pio4_bind, .of_match = atmel_pio4_ids, - .platdata_auto_alloc_size = sizeof(struct atmel_pio4_platdata), + .plat_auto = sizeof(struct atmel_pio4_plat), }; #endif diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c index 0dff9ac711..704a6fa712 100644 --- a/drivers/gpio/bcm2835_gpio.c +++ b/drivers/gpio/bcm2835_gpio.c @@ -102,7 +102,7 @@ static const struct dm_gpio_ops gpio_bcm2835_ops = { static int bcm2835_gpio_probe(struct udevice *dev) { struct bcm2835_gpios *gpios = dev_get_priv(dev); - struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev); + struct bcm2835_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); uc_priv->bank_name = "GPIO"; @@ -116,9 +116,9 @@ static int bcm2835_gpio_probe(struct udevice *dev) } #if CONFIG_IS_ENABLED(OF_CONTROL) -static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev) +static int bcm2835_gpio_of_to_plat(struct udevice *dev) { - struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev); + struct bcm2835_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -133,10 +133,10 @@ static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev) U_BOOT_DRIVER(gpio_bcm2835) = { .name = "gpio_bcm2835", .id = UCLASS_GPIO, - .ofdata_to_platdata = of_match_ptr(bcm2835_gpio_ofdata_to_platdata), - .platdata_auto_alloc_size = sizeof(struct bcm2835_gpio_platdata), + .of_to_plat = of_match_ptr(bcm2835_gpio_of_to_plat), + .plat_auto = sizeof(struct bcm2835_gpio_plat), .ops = &gpio_bcm2835_ops, .probe = bcm2835_gpio_probe, .flags = DM_FLAG_PRE_RELOC, - .priv_auto_alloc_size = sizeof(struct bcm2835_gpios), + .priv_auto = sizeof(struct bcm2835_gpios), }; diff --git a/drivers/gpio/bcm6345_gpio.c b/drivers/gpio/bcm6345_gpio.c index 5da11d988e..e031f71a78 100644 --- a/drivers/gpio/bcm6345_gpio.c +++ b/drivers/gpio/bcm6345_gpio.c @@ -114,6 +114,6 @@ U_BOOT_DRIVER(bcm6345_gpio) = { .id = UCLASS_GPIO, .of_match = bcm6345_gpio_ids, .ops = &bcm6345_gpio_ops, - .priv_auto_alloc_size = sizeof(struct bcm6345_gpio_priv), + .priv_auto = sizeof(struct bcm6345_gpio_priv), .probe = bcm6345_gpio_probe, }; diff --git a/drivers/gpio/cortina_gpio.c b/drivers/gpio/cortina_gpio.c index 055907c1a1..72ef523be9 100644 --- a/drivers/gpio/cortina_gpio.c +++ b/drivers/gpio/cortina_gpio.c @@ -107,7 +107,7 @@ U_BOOT_DRIVER(cortina_gpio) = { .id = UCLASS_GPIO, .ops = &gpio_cortina_ops, .probe = ca_gpio_probe, - .priv_auto_alloc_size = sizeof(struct cortina_gpio_bank), + .priv_auto = sizeof(struct cortina_gpio_bank), .of_match = ca_gpio_ids, }; #endif /* CONFIG_DM_GPIO */ diff --git a/drivers/gpio/da8xx_gpio.c b/drivers/gpio/da8xx_gpio.c index f875888510..9a52a5e414 100644 --- a/drivers/gpio/da8xx_gpio.c +++ b/drivers/gpio/da8xx_gpio.c @@ -522,7 +522,7 @@ static const struct dm_gpio_ops gpio_davinci_ops = { static int davinci_gpio_probe(struct udevice *dev) { struct davinci_gpio_bank *bank = dev_get_priv(dev); - struct davinci_gpio_platdata *plat = dev_get_platdata(dev); + struct davinci_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); @@ -540,9 +540,9 @@ static const struct udevice_id davinci_gpio_ids[] = { { } }; -static int davinci_gpio_ofdata_to_platdata(struct udevice *dev) +static int davinci_gpio_of_to_plat(struct udevice *dev) { - struct davinci_gpio_platdata *plat = dev_get_platdata(dev); + struct davinci_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -557,12 +557,12 @@ U_BOOT_DRIVER(ti_dm6441_gpio) = { .name = "ti_dm6441_gpio", .id = UCLASS_GPIO, .ops = &gpio_davinci_ops, - .ofdata_to_platdata = of_match_ptr(davinci_gpio_ofdata_to_platdata), + .of_to_plat = of_match_ptr(davinci_gpio_of_to_plat), .of_match = davinci_gpio_ids, .bind = dm_scan_fdt_dev, - .platdata_auto_alloc_size = sizeof(struct davinci_gpio_platdata), + .plat_auto = sizeof(struct davinci_gpio_plat), .probe = davinci_gpio_probe, - .priv_auto_alloc_size = sizeof(struct davinci_gpio_bank), + .priv_auto = sizeof(struct davinci_gpio_bank), }; #endif diff --git a/drivers/gpio/da8xx_gpio.h b/drivers/gpio/da8xx_gpio.h index 849e8d2dcf..ca59d6a90b 100644 --- a/drivers/gpio/da8xx_gpio.h +++ b/drivers/gpio/da8xx_gpio.h @@ -31,7 +31,7 @@ struct davinci_gpio_bank { #if CONFIG_IS_ENABLED(DM_GPIO) /* Information about a GPIO bank */ -struct davinci_gpio_platdata { +struct davinci_gpio_plat { int bank_index; ulong base; /* address of registers in physical memory */ const char *port_name; diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c index 37916e7771..e6e919444f 100644 --- a/drivers/gpio/dwapb_gpio.c +++ b/drivers/gpio/dwapb_gpio.c @@ -36,7 +36,7 @@ struct gpio_dwapb_priv { struct reset_ctl_bulk resets; }; -struct gpio_dwapb_platdata { +struct gpio_dwapb_plat { const char *name; int bank; int pins; @@ -45,7 +45,7 @@ struct gpio_dwapb_platdata { static int dwapb_gpio_direction_input(struct udevice *dev, unsigned pin) { - struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); + struct gpio_dwapb_plat *plat = dev_get_plat(dev); clrbits_le32(plat->base + GPIO_SWPORT_DDR(plat->bank), 1 << pin); return 0; @@ -54,7 +54,7 @@ static int dwapb_gpio_direction_input(struct udevice *dev, unsigned pin) static int dwapb_gpio_direction_output(struct udevice *dev, unsigned pin, int val) { - struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); + struct gpio_dwapb_plat *plat = dev_get_plat(dev); setbits_le32(plat->base + GPIO_SWPORT_DDR(plat->bank), 1 << pin); @@ -68,7 +68,7 @@ static int dwapb_gpio_direction_output(struct udevice *dev, unsigned pin, static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val) { - struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); + struct gpio_dwapb_plat *plat = dev_get_plat(dev); if (val) setbits_le32(plat->base + GPIO_SWPORT_DR(plat->bank), 1 << pin); @@ -80,7 +80,7 @@ static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val) static int dwapb_gpio_get_function(struct udevice *dev, unsigned offset) { - struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); + struct gpio_dwapb_plat *plat = dev_get_plat(dev); u32 gpio; gpio = readl(plat->base + GPIO_SWPORT_DDR(plat->bank)); @@ -93,7 +93,7 @@ static int dwapb_gpio_get_function(struct udevice *dev, unsigned offset) static int dwapb_gpio_get_value(struct udevice *dev, unsigned pin) { - struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); + struct gpio_dwapb_plat *plat = dev_get_plat(dev); u32 value; if (dwapb_gpio_get_function(dev, pin) == GPIOF_OUTPUT) @@ -141,7 +141,7 @@ static int gpio_dwapb_reset(struct udevice *dev) static int gpio_dwapb_probe(struct udevice *dev) { struct gpio_dev_priv *priv = dev_get_uclass_priv(dev); - struct gpio_dwapb_platdata *plat = dev->platdata; + struct gpio_dwapb_plat *plat = dev_get_plat(dev); if (!plat) { /* Reset on parent device only */ @@ -156,7 +156,7 @@ static int gpio_dwapb_probe(struct udevice *dev) static int gpio_dwapb_bind(struct udevice *dev) { - struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); + struct gpio_dwapb_plat *plat = dev_get_plat(dev); struct udevice *subdev; fdt_addr_t base; int ret, bank = 0; @@ -202,8 +202,8 @@ static int gpio_dwapb_bind(struct udevice *dev) } } - ret = device_bind_ofnode(dev, dev->driver, plat->name, - plat, node, &subdev); + ret = device_bind(dev, dev->driver, plat->name, plat, node, + &subdev); if (ret) return ret; @@ -215,7 +215,7 @@ static int gpio_dwapb_bind(struct udevice *dev) static int gpio_dwapb_remove(struct udevice *dev) { - struct gpio_dwapb_platdata *plat = dev_get_platdata(dev); + struct gpio_dwapb_plat *plat = dev_get_plat(dev); struct gpio_dwapb_priv *priv = dev_get_priv(dev); if (!plat && priv) @@ -237,5 +237,5 @@ U_BOOT_DRIVER(gpio_dwapb) = { .bind = gpio_dwapb_bind, .probe = gpio_dwapb_probe, .remove = gpio_dwapb_remove, - .priv_auto_alloc_size = sizeof(struct gpio_dwapb_priv), + .priv_auto = sizeof(struct gpio_dwapb_priv), }; diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index a993fd4d70..beae34f233 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -189,6 +189,6 @@ U_BOOT_DRIVER(rcar_gpio) = { .id = UCLASS_GPIO, .of_match = rcar_gpio_ids, .ops = &rcar_gpio_ops, - .priv_auto_alloc_size = sizeof(struct rcar_gpio_priv), + .priv_auto = sizeof(struct rcar_gpio_priv), .probe = rcar_gpio_probe, }; diff --git a/drivers/gpio/gpio-rza1.c b/drivers/gpio/gpio-rza1.c index 86804ac2f5..ee7de4c17e 100644 --- a/drivers/gpio/gpio-rza1.c +++ b/drivers/gpio/gpio-rza1.c @@ -130,6 +130,6 @@ U_BOOT_DRIVER(r7s72100_gpio) = { .name = "r7s72100-gpio", .id = UCLASS_GPIO, .ops = &r7s72100_gpio_ops, - .priv_auto_alloc_size = sizeof(struct r7s72100_gpio_priv), + .priv_auto = sizeof(struct r7s72100_gpio_priv), .probe = r7s72100_gpio_probe, }; diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 0c01413b58..bad6b71e0c 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -239,9 +239,9 @@ struct gpio_hog_data { u32 val[2]; }; -static int gpio_hog_ofdata_to_platdata(struct udevice *dev) +static int gpio_hog_of_to_plat(struct udevice *dev) { - struct gpio_hog_data *plat = dev_get_platdata(dev); + struct gpio_hog_data *plat = dev_get_plat(dev); const char *nodename; int ret; @@ -272,7 +272,7 @@ static int gpio_hog_ofdata_to_platdata(struct udevice *dev) static int gpio_hog_probe(struct udevice *dev) { - struct gpio_hog_data *plat = dev_get_platdata(dev); + struct gpio_hog_data *plat = dev_get_plat(dev); struct gpio_hog_priv *priv = dev_get_priv(dev); int ret; @@ -306,7 +306,7 @@ int gpio_hog_probe_all(void) for (uclass_first_device(UCLASS_NOP, &dev); dev; uclass_find_next_device(&dev)) { - if (dev->driver == DM_GET_DRIVER(gpio_hog)) { + if (dev->driver == DM_DRIVER_GET(gpio_hog)) { ret = device_probe(dev); if (ret) { printf("Failed to probe device %s err: %d\n", @@ -338,10 +338,10 @@ int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc) U_BOOT_DRIVER(gpio_hog) = { .name = "gpio_hog", .id = UCLASS_NOP, - .ofdata_to_platdata = gpio_hog_ofdata_to_platdata, + .of_to_plat = gpio_hog_of_to_plat, .probe = gpio_hog_probe, - .priv_auto_alloc_size = sizeof(struct gpio_hog_priv), - .platdata_auto_alloc_size = sizeof(struct gpio_hog_data), + .priv_auto = sizeof(struct gpio_hog_priv), + .plat_auto = sizeof(struct gpio_hog_data), }; #else int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc) @@ -1100,9 +1100,8 @@ int gpio_get_list_count(struct udevice *dev, const char *list_name) { int ret; - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), - list_name, "#gpio-cells", 0, -1, - NULL); + ret = dev_read_phandle_with_args(dev, list_name, "#gpio-cells", 0, -1, + NULL); if (ret) { debug("%s: Node '%s', property '%s', GPIO count failed: %d\n", __func__, dev->name, list_name, ret); @@ -1166,7 +1165,7 @@ int gpio_get_number(const struct gpio_desc *desc) if (!dev) return -1; - uc_priv = dev->uclass_priv; + uc_priv = dev_get_uclass_priv(dev); return uc_priv->gpio_base + desc->offset; } @@ -1340,5 +1339,5 @@ UCLASS_DRIVER(gpio) = { .post_probe = gpio_post_probe, .post_bind = gpio_post_bind, .pre_remove = gpio_pre_remove, - .per_device_auto_alloc_size = sizeof(struct gpio_dev_priv), + .per_device_auto = sizeof(struct gpio_dev_priv), }; diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c index 54a38da0f1..61c705b5ac 100644 --- a/drivers/gpio/gpio-uniphier.c +++ b/drivers/gpio/gpio-uniphier.c @@ -166,6 +166,6 @@ U_BOOT_DRIVER(uniphier_gpio) = { .id = UCLASS_GPIO, .of_match = uniphier_gpio_match, .probe = uniphier_gpio_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_gpio_priv), + .priv_auto = sizeof(struct uniphier_gpio_priv), .ops = &uniphier_gpio_ops, }; diff --git a/drivers/gpio/hi6220_gpio.c b/drivers/gpio/hi6220_gpio.c index 95de2ae366..04f8d904a2 100644 --- a/drivers/gpio/hi6220_gpio.c +++ b/drivers/gpio/hi6220_gpio.c @@ -66,8 +66,8 @@ static const struct dm_gpio_ops gpio_hi6220_ops = { static int hi6220_gpio_probe(struct udevice *dev) { struct gpio_bank *bank = dev_get_priv(dev); - struct hikey_gpio_platdata *plat = dev_get_platdata(dev); - struct gpio_dev_priv *uc_priv = dev->uclass_priv; + struct hikey_gpio_plat *plat = dev_get_plat(dev); + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); char name[18], *str; sprintf(name, "GPIO%d_", plat->bank_index); @@ -89,7 +89,7 @@ U_BOOT_DRIVER(gpio_hi6220) = { .id = UCLASS_GPIO, .ops = &gpio_hi6220_ops, .probe = hi6220_gpio_probe, - .priv_auto_alloc_size = sizeof(struct gpio_bank), + .priv_auto = sizeof(struct gpio_bank), }; diff --git a/drivers/gpio/hsdk-creg-gpio.c b/drivers/gpio/hsdk-creg-gpio.c index 35b114904d..66f8441840 100644 --- a/drivers/gpio/hsdk-creg-gpio.c +++ b/drivers/gpio/hsdk-creg-gpio.c @@ -165,5 +165,5 @@ U_BOOT_DRIVER(gpio_hsdk_creg) = { .ops = &hsdk_creg_gpio_ops, .probe = hsdk_creg_gpio_probe, .of_match = hsdk_creg_gpio_ids, - .platdata_auto_alloc_size = sizeof(struct hsdk_creg_gpio), + .plat_auto = sizeof(struct hsdk_creg_gpio), }; diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c index 1e876f6914..0e2874ca95 100644 --- a/drivers/gpio/imx_rgpio2p.c +++ b/drivers/gpio/imx_rgpio2p.c @@ -11,6 +11,7 @@ #include <fdtdec.h> #include <asm/gpio.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <malloc.h> enum imx_rgpio2p_direction { @@ -132,7 +133,7 @@ static const struct dm_gpio_ops imx_rgpio2p_ops = { static int imx_rgpio2p_probe(struct udevice *dev) { struct imx_rgpio2p_data *bank = dev_get_priv(dev); - struct imx_rgpio2p_plat *plat = dev_get_platdata(dev); + struct imx_rgpio2p_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); int banknum; char name[18], *str; @@ -151,13 +152,13 @@ static int imx_rgpio2p_probe(struct udevice *dev) static int imx_rgpio2p_bind(struct udevice *dev) { - struct imx_rgpio2p_plat *plat = dev->platdata; + struct imx_rgpio2p_plat *plat = dev_get_plat(dev); fdt_addr_t addr; /* - * If platdata already exsits, directly return. - * Actually only when DT is not supported, platdata - * is statically initialized in U_BOOT_DEVICES.Here + * If plat already exsits, directly return. + * Actually only when DT is not supported, plat + * is statically initialized in U_BOOT_DRVINFOS.Here * will return. */ if (plat) @@ -171,7 +172,7 @@ static int imx_rgpio2p_bind(struct udevice *dev) * TODO: * When every board is converted to driver model and DT is supported, * this can be done by auto-alloc feature, but not using calloc - * to alloc memory for platdata. + * to alloc memory for plat. * * For example imx_rgpio2p_plat uses platform data rather than device * tree. @@ -183,8 +184,8 @@ static int imx_rgpio2p_bind(struct udevice *dev) return -ENOMEM; plat->regs = (struct gpio_regs *)addr; - plat->bank_index = dev->req_seq; - dev->platdata = plat; + plat->bank_index = dev_seq(dev); + dev_set_plat(dev, plat); return 0; } @@ -200,7 +201,7 @@ U_BOOT_DRIVER(imx_rgpio2p) = { .id = UCLASS_GPIO, .ops = &imx_rgpio2p_ops, .probe = imx_rgpio2p_probe, - .priv_auto_alloc_size = sizeof(struct imx_rgpio2p_plat), + .priv_auto = sizeof(struct imx_rgpio2p_plat), .of_match = imx_rgpio2p_ids, .bind = imx_rgpio2p_bind, }; @@ -215,7 +216,7 @@ static const struct imx_rgpio2p_plat imx_plat[] = { { 5, (struct gpio_regs *)RGPIO2P_GPIO6_BASE_ADDR }, }; -U_BOOT_DEVICES(imx_rgpio2ps) = { +U_BOOT_DRVINFOS(imx_rgpio2ps) = { { "imx_rgpio2p", &imx_plat[0] }, { "imx_rgpio2p", &imx_plat[1] }, { "imx_rgpio2p", &imx_plat[2] }, diff --git a/drivers/gpio/intel_broadwell_gpio.c b/drivers/gpio/intel_broadwell_gpio.c index 95f8b2ba6c..68d72eedc5 100644 --- a/drivers/gpio/intel_broadwell_gpio.c +++ b/drivers/gpio/intel_broadwell_gpio.c @@ -117,7 +117,7 @@ static int broadwell_gpio_get_function(struct udevice *dev, unsigned offset) static int broadwell_gpio_probe(struct udevice *dev) { - struct broadwell_bank_platdata *plat = dev_get_platdata(dev); + struct broadwell_bank_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct broadwell_bank_priv *priv = dev_get_priv(dev); struct udevice *pinctrl; @@ -139,9 +139,9 @@ static int broadwell_gpio_probe(struct udevice *dev) return 0; } -static int broadwell_gpio_ofdata_to_platdata(struct udevice *dev) +static int broadwell_gpio_of_to_plat(struct udevice *dev) { - struct broadwell_bank_platdata *plat = dev_get_platdata(dev); + struct broadwell_bank_plat *plat = dev_get_plat(dev); u32 gpiobase; int bank; int ret; @@ -182,8 +182,8 @@ U_BOOT_DRIVER(gpio_broadwell) = { .id = UCLASS_GPIO, .of_match = intel_broadwell_gpio_ids, .ops = &gpio_broadwell_ops, - .ofdata_to_platdata = broadwell_gpio_ofdata_to_platdata, + .of_to_plat = broadwell_gpio_of_to_plat, .probe = broadwell_gpio_probe, - .priv_auto_alloc_size = sizeof(struct broadwell_bank_priv), - .platdata_auto_alloc_size = sizeof(struct broadwell_bank_platdata), + .priv_auto = sizeof(struct broadwell_bank_priv), + .plat_auto = sizeof(struct broadwell_bank_plat), }; diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c index c3b67f24d8..eda95485c9 100644 --- a/drivers/gpio/intel_gpio.c +++ b/drivers/gpio/intel_gpio.c @@ -164,7 +164,7 @@ static int intel_gpio_probe(struct udevice *dev) return 0; } -static int intel_gpio_ofdata_to_platdata(struct udevice *dev) +static int intel_gpio_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *upriv = dev_get_uclass_priv(dev); struct intel_pinctrl_priv *pinctrl_priv = dev_get_priv(dev->parent); @@ -188,16 +188,18 @@ static const struct dm_gpio_ops gpio_intel_ops = { #endif }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id intel_intel_gpio_ids[] = { { .compatible = "intel,gpio" }, { } }; +#endif U_BOOT_DRIVER(intel_gpio) = { .name = "intel_gpio", .id = UCLASS_GPIO, - .of_match = intel_intel_gpio_ids, + .of_match = of_match_ptr(intel_intel_gpio_ids), .ops = &gpio_intel_ops, - .ofdata_to_platdata = intel_gpio_ofdata_to_platdata, + .of_to_plat = intel_gpio_of_to_plat, .probe = intel_gpio_probe, }; diff --git a/drivers/gpio/intel_ich6_gpio.c b/drivers/gpio/intel_ich6_gpio.c index 73d98fde55..11d4be04f5 100644 --- a/drivers/gpio/intel_ich6_gpio.c +++ b/drivers/gpio/intel_ich6_gpio.c @@ -93,9 +93,9 @@ static int _ich6_gpio_set_direction(uint16_t base, unsigned offset, int dir) return 0; } -static int gpio_ich6_ofdata_to_platdata(struct udevice *dev) +static int gpio_ich6_of_to_plat(struct udevice *dev) { - struct ich6_bank_platdata *plat = dev_get_platdata(dev); + struct ich6_bank_plat *plat = dev_get_plat(dev); u32 gpiobase; int offset; int ret; @@ -119,7 +119,7 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev) static int ich6_gpio_probe(struct udevice *dev) { - struct ich6_bank_platdata *plat = dev_get_platdata(dev); + struct ich6_bank_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct ich6_bank_priv *bank = dev_get_priv(dev); const void *prop; @@ -234,8 +234,8 @@ U_BOOT_DRIVER(gpio_ich6) = { .id = UCLASS_GPIO, .of_match = intel_ich6_gpio_ids, .ops = &gpio_ich6_ops, - .ofdata_to_platdata = gpio_ich6_ofdata_to_platdata, + .of_to_plat = gpio_ich6_of_to_plat, .probe = ich6_gpio_probe, - .priv_auto_alloc_size = sizeof(struct ich6_bank_priv), - .platdata_auto_alloc_size = sizeof(struct ich6_bank_platdata), + .priv_auto = sizeof(struct ich6_bank_priv), + .plat_auto = sizeof(struct ich6_bank_plat), }; diff --git a/drivers/gpio/iproc_gpio.c b/drivers/gpio/iproc_gpio.c index cc26a1306b..8c143e9b75 100644 --- a/drivers/gpio/iproc_gpio.c +++ b/drivers/gpio/iproc_gpio.c @@ -55,7 +55,7 @@ struct iproc_gpio_pctrl_map { * @name: gpio device name, ex GPIO0, GPIO1 * @ngpios: total number of gpios */ -struct iproc_gpio_platdata { +struct iproc_gpio_plat { struct udevice *pinctrl_dev; struct list_head gpiomap; void __iomem *base; @@ -73,7 +73,7 @@ struct iproc_gpio_platdata { * @gpio: GPIO pin * @set: set or clear */ -static inline void iproc_gpio_set_bit(struct iproc_gpio_platdata *plat, +static inline void iproc_gpio_set_bit(struct iproc_gpio_plat *plat, u32 reg, u32 gpio, bool set) { u32 offset = GPIO_REG(gpio, reg); @@ -83,7 +83,7 @@ static inline void iproc_gpio_set_bit(struct iproc_gpio_platdata *plat, (set ? BIT(shift) : 0)); } -static inline bool iproc_gpio_get_bit(struct iproc_gpio_platdata *plat, +static inline bool iproc_gpio_get_bit(struct iproc_gpio_plat *plat, u32 reg, u32 gpio) { u32 offset = GPIO_REG(gpio, reg); @@ -98,7 +98,7 @@ static inline bool iproc_gpio_get_bit(struct iproc_gpio_platdata *plat, * @plat: iproc GPIO device * @gpio: GPIO pin */ -static u32 iproc_get_pctrl_from_gpio(struct iproc_gpio_platdata *plat, u32 gpio) +static u32 iproc_get_pctrl_from_gpio(struct iproc_gpio_plat *plat, u32 gpio) { struct iproc_gpio_pctrl_map *range = NULL; struct list_head *pos, *tmp; @@ -127,7 +127,7 @@ static u32 iproc_get_pctrl_from_gpio(struct iproc_gpio_platdata *plat, u32 gpio) */ static int iproc_get_gpio_pctrl_mapping(struct udevice *dev) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); struct iproc_gpio_pctrl_map *range = NULL; struct ofnode_phandle_args args; int index = 0, ret; @@ -153,7 +153,7 @@ static int iproc_get_gpio_pctrl_mapping(struct udevice *dev) static int iproc_gpio_request(struct udevice *dev, u32 gpio, const char *label) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); u32 pctrl; /* nothing to do if there is no corresponding pinctrl device */ @@ -167,7 +167,7 @@ static int iproc_gpio_request(struct udevice *dev, u32 gpio, const char *label) static int iproc_gpio_direction_input(struct udevice *dev, u32 gpio) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); iproc_gpio_set_bit(plat, OUT_EN_OFFSET, gpio, false); dev_dbg(dev, "gpio:%u set input\n", gpio); @@ -177,7 +177,7 @@ static int iproc_gpio_direction_input(struct udevice *dev, u32 gpio) static int iproc_gpio_direction_output(struct udevice *dev, u32 gpio, int value) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); iproc_gpio_set_bit(plat, OUT_EN_OFFSET, gpio, true); iproc_gpio_set_bit(plat, DATA_OUT_OFFSET, gpio, value); @@ -188,7 +188,7 @@ static int iproc_gpio_direction_output(struct udevice *dev, u32 gpio, int value) static int iproc_gpio_get_value(struct udevice *dev, u32 gpio) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); int value; value = iproc_gpio_get_bit(plat, DATA_IN_OFFSET, gpio); @@ -199,7 +199,7 @@ static int iproc_gpio_get_value(struct udevice *dev, u32 gpio) static int iproc_gpio_set_value(struct udevice *dev, u32 gpio, int value) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); if (iproc_gpio_get_bit(plat, OUT_EN_OFFSET, gpio)) iproc_gpio_set_bit(plat, DATA_OUT_OFFSET, gpio, value); @@ -210,7 +210,7 @@ static int iproc_gpio_set_value(struct udevice *dev, u32 gpio, int value) static int iproc_gpio_get_function(struct udevice *dev, u32 gpio) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); if (iproc_gpio_get_bit(plat, OUT_EN_OFFSET, gpio)) return GPIOF_OUTPUT; @@ -218,9 +218,9 @@ static int iproc_gpio_get_function(struct udevice *dev, u32 gpio) return GPIOF_INPUT; } -static int iproc_gpio_ofdata_to_platdata(struct udevice *dev) +static int iproc_gpio_of_to_plat(struct udevice *dev) { - struct iproc_gpio_platdata *plat = dev_get_platdata(dev); + struct iproc_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); int ret; char name[10]; @@ -252,7 +252,7 @@ static int iproc_gpio_ofdata_to_platdata(struct udevice *dev) return ret; } - snprintf(name, sizeof(name), "GPIO%d", dev->req_seq); + snprintf(name, sizeof(name), "GPIO%d", dev_seq(dev)); plat->name = strdup(name); if (!plat->name) return -ENOMEM; @@ -285,6 +285,6 @@ U_BOOT_DRIVER(iproc_gpio) = { .id = UCLASS_GPIO, .of_match = iproc_gpio_ids, .ops = &iproc_gpio_ops, - .ofdata_to_platdata = iproc_gpio_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct iproc_gpio_platdata), + .of_to_plat = iproc_gpio_of_to_plat, + .plat_auto = sizeof(struct iproc_gpio_plat), }; diff --git a/drivers/gpio/lpc32xx_gpio.c b/drivers/gpio/lpc32xx_gpio.c index 1265ee41a6..de66c765d1 100644 --- a/drivers/gpio/lpc32xx_gpio.c +++ b/drivers/gpio/lpc32xx_gpio.c @@ -295,7 +295,7 @@ static const struct dm_gpio_ops gpio_lpc32xx_ops = { static int lpc32xx_gpio_probe(struct udevice *dev) { struct lpc32xx_gpio_priv *gpio_priv = dev_get_priv(dev); - struct gpio_dev_priv *uc_priv = dev->uclass_priv; + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); if (dev_of_offset(dev) == -1) { /* Tell the uclass how many GPIOs we have */ @@ -317,5 +317,5 @@ U_BOOT_DRIVER(gpio_lpc32xx) = { .id = UCLASS_GPIO, .ops = &gpio_lpc32xx_ops, .probe = lpc32xx_gpio_probe, - .priv_auto_alloc_size = sizeof(struct lpc32xx_gpio_priv), + .priv_auto = sizeof(struct lpc32xx_gpio_priv), }; diff --git a/drivers/gpio/mpc83xx_spisel_boot.c b/drivers/gpio/mpc83xx_spisel_boot.c index 54dc437e1c..fd26a36a0f 100644 --- a/drivers/gpio/mpc83xx_spisel_boot.c +++ b/drivers/gpio/mpc83xx_spisel_boot.c @@ -61,9 +61,9 @@ static int mpc83xx_spisel_boot_get_function(struct udevice *dev, uint gpio) } #if CONFIG_IS_ENABLED(OF_CONTROL) -static int mpc83xx_spisel_boot_ofdata_to_platdata(struct udevice *dev) +static int mpc83xx_spisel_boot_of_to_plat(struct udevice *dev) { - struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); + struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t addr; u32 reg[2]; @@ -78,10 +78,10 @@ static int mpc83xx_spisel_boot_ofdata_to_platdata(struct udevice *dev) } #endif -static int mpc83xx_spisel_boot_platdata_to_priv(struct udevice *dev) +static int mpc83xx_spisel_boot_plat_to_priv(struct udevice *dev) { struct mpc83xx_spisel_boot *priv = dev_get_priv(dev); - struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); + struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev); unsigned long size = plat->size; ulong driver_data = dev_get_driver_data(dev); @@ -107,7 +107,7 @@ static int mpc83xx_spisel_boot_probe(struct udevice *dev) struct mpc83xx_spisel_boot *data = dev_get_priv(dev); char name[32], *str; - mpc83xx_spisel_boot_platdata_to_priv(dev); + mpc83xx_spisel_boot_plat_to_priv(dev); snprintf(name, sizeof(name), "MPC@%lx_", data->addr); str = strdup(name); @@ -140,10 +140,10 @@ U_BOOT_DRIVER(spisel_boot_mpc83xx) = { .id = UCLASS_GPIO, .ops = &mpc83xx_spisel_boot_ops, #if CONFIG_IS_ENABLED(OF_CONTROL) - .ofdata_to_platdata = mpc83xx_spisel_boot_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mpc8xxx_gpio_plat), + .of_to_plat = mpc83xx_spisel_boot_of_to_plat, + .plat_auto = sizeof(struct mpc8xxx_gpio_plat), .of_match = mpc83xx_spisel_boot_ids, #endif .probe = mpc83xx_spisel_boot_probe, - .priv_auto_alloc_size = sizeof(struct mpc83xx_spisel_boot), + .priv_auto = sizeof(struct mpc83xx_spisel_boot), }; diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c index 27881a7322..a964347fa3 100644 --- a/drivers/gpio/mpc8xxx_gpio.c +++ b/drivers/gpio/mpc8xxx_gpio.c @@ -183,15 +183,15 @@ static int mpc8xxx_gpio_get_function(struct udevice *dev, uint gpio) } #if CONFIG_IS_ENABLED(OF_CONTROL) -static int mpc8xxx_gpio_ofdata_to_platdata(struct udevice *dev) +static int mpc8xxx_gpio_of_to_plat(struct udevice *dev) { - struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); + struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev); struct mpc8xxx_gpio_data *data = dev_get_priv(dev); fdt_addr_t addr; u32 i; u32 reg[4]; - if (ofnode_read_bool(dev->node, "little-endian")) + if (ofnode_read_bool(dev_ofnode(dev), "little-endian")) data->little_endian = true; if (data->little_endian) @@ -219,10 +219,10 @@ static int mpc8xxx_gpio_ofdata_to_platdata(struct udevice *dev) } #endif -static int mpc8xxx_gpio_platdata_to_priv(struct udevice *dev) +static int mpc8xxx_gpio_plat_to_priv(struct udevice *dev) { struct mpc8xxx_gpio_data *priv = dev_get_priv(dev); - struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); + struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev); unsigned long size = plat->size; ulong driver_data = dev_get_driver_data(dev); @@ -249,7 +249,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev) struct mpc8xxx_gpio_data *data = dev_get_priv(dev); char name[32], *str; - mpc8xxx_gpio_platdata_to_priv(dev); + mpc8xxx_gpio_plat_to_priv(dev); snprintf(name, sizeof(name), "MPC@%lx_", data->addr); str = strdup(name); @@ -257,7 +257,7 @@ static int mpc8xxx_gpio_probe(struct udevice *dev) if (!str) return -ENOMEM; - if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) { + if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) { unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio) - sizeof(u32); @@ -294,10 +294,10 @@ U_BOOT_DRIVER(gpio_mpc8xxx) = { .id = UCLASS_GPIO, .ops = &gpio_mpc8xxx_ops, #if CONFIG_IS_ENABLED(OF_CONTROL) - .ofdata_to_platdata = mpc8xxx_gpio_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mpc8xxx_gpio_plat), + .of_to_plat = mpc8xxx_gpio_of_to_plat, + .plat_auto = sizeof(struct mpc8xxx_gpio_plat), .of_match = mpc8xxx_gpio_ids, #endif .probe = mpc8xxx_gpio_probe, - .priv_auto_alloc_size = sizeof(struct mpc8xxx_gpio_data), + .priv_auto = sizeof(struct mpc8xxx_gpio_data), }; diff --git a/drivers/gpio/mscc_sgpio.c b/drivers/gpio/mscc_sgpio.c index 780d77b2f8..1cbcc43489 100644 --- a/drivers/gpio/mscc_sgpio.c +++ b/drivers/gpio/mscc_sgpio.c @@ -275,5 +275,5 @@ U_BOOT_DRIVER(gpio_mscc_sgpio) = { .of_match = mscc_sgpio_ids, .ops = &mscc_sgpio_ops, .probe = mscc_sgpio_probe, - .priv_auto_alloc_size = sizeof(struct mscc_sgpio_priv), + .priv_auto = sizeof(struct mscc_sgpio_priv), }; diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c index 416fb56a98..af6c8383aa 100644 --- a/drivers/gpio/msm_gpio.c +++ b/drivers/gpio/msm_gpio.c @@ -101,7 +101,7 @@ static int msm_gpio_probe(struct udevice *dev) return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0; } -static int msm_gpio_ofdata_to_platdata(struct udevice *dev) +static int msm_gpio_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); @@ -126,8 +126,8 @@ U_BOOT_DRIVER(gpio_msm) = { .name = "gpio_msm", .id = UCLASS_GPIO, .of_match = msm_gpio_ids, - .ofdata_to_platdata = msm_gpio_ofdata_to_platdata, + .of_to_plat = msm_gpio_of_to_plat, .probe = msm_gpio_probe, .ops = &gpio_msm_ops, - .priv_auto_alloc_size = sizeof(struct msm_gpio_bank), + .priv_auto = sizeof(struct msm_gpio_bank), }; diff --git a/drivers/gpio/mt7621_gpio.c b/drivers/gpio/mt7621_gpio.c index 612413e17b..43bb4df4da 100644 --- a/drivers/gpio/mt7621_gpio.c +++ b/drivers/gpio/mt7621_gpio.c @@ -38,20 +38,20 @@ enum mediatek_gpio_reg { static void __iomem *mediatek_gpio_membase; -struct mediatek_gpio_platdata { +struct mediatek_gpio_plat { char bank_name[3]; /* Name of bank, e.g. "PA", "PB" etc */ int gpio_count; int bank; }; -static u32 reg_offs(struct mediatek_gpio_platdata *plat, int reg) +static u32 reg_offs(struct mediatek_gpio_plat *plat, int reg) { return (reg * 0x10) + (plat->bank * 0x4); } static int mediatek_gpio_get_value(struct udevice *dev, unsigned int offset) { - struct mediatek_gpio_platdata *plat = dev_get_platdata(dev); + struct mediatek_gpio_plat *plat = dev_get_plat(dev); return !!(ioread32(mediatek_gpio_membase + reg_offs(plat, GPIO_REG_DATA)) & BIT(offset)); @@ -60,7 +60,7 @@ static int mediatek_gpio_get_value(struct udevice *dev, unsigned int offset) static int mediatek_gpio_set_value(struct udevice *dev, unsigned int offset, int value) { - struct mediatek_gpio_platdata *plat = dev_get_platdata(dev); + struct mediatek_gpio_plat *plat = dev_get_plat(dev); iowrite32(BIT(offset), mediatek_gpio_membase + reg_offs(plat, value ? GPIO_REG_DSET : GPIO_REG_DCLR)); @@ -70,7 +70,7 @@ static int mediatek_gpio_set_value(struct udevice *dev, unsigned int offset, static int mediatek_gpio_direction_input(struct udevice *dev, unsigned int offset) { - struct mediatek_gpio_platdata *plat = dev_get_platdata(dev); + struct mediatek_gpio_plat *plat = dev_get_plat(dev); clrbits_le32(mediatek_gpio_membase + reg_offs(plat, GPIO_REG_CTRL), BIT(offset)); @@ -81,7 +81,7 @@ static int mediatek_gpio_direction_input(struct udevice *dev, unsigned int offse static int mediatek_gpio_direction_output(struct udevice *dev, unsigned int offset, int value) { - struct mediatek_gpio_platdata *plat = dev_get_platdata(dev); + struct mediatek_gpio_plat *plat = dev_get_plat(dev); setbits_le32(mediatek_gpio_membase + reg_offs(plat, GPIO_REG_CTRL), BIT(offset)); @@ -92,7 +92,7 @@ static int mediatek_gpio_direction_output(struct udevice *dev, unsigned int offs static int mediatek_gpio_get_function(struct udevice *dev, unsigned int offset) { - struct mediatek_gpio_platdata *plat = dev_get_platdata(dev); + struct mediatek_gpio_plat *plat = dev_get_plat(dev); u32 t; t = ioread32(mediatek_gpio_membase + reg_offs(plat, GPIO_REG_CTRL)); @@ -112,7 +112,7 @@ static const struct dm_gpio_ops gpio_mediatek_ops = { static int gpio_mediatek_probe(struct udevice *dev) { - struct mediatek_gpio_platdata *plat = dev_get_platdata(dev); + struct mediatek_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); /* Tell the uclass how many GPIOs we have */ @@ -130,7 +130,7 @@ static int gpio_mediatek_probe(struct udevice *dev) */ static int gpio_mediatek_bind(struct udevice *parent) { - struct mediatek_gpio_platdata *plat = parent->platdata; + struct mediatek_gpio_plat *plat = dev_get_plat(parent); ofnode node; int bank = 0; int ret; @@ -145,7 +145,7 @@ static int gpio_mediatek_bind(struct udevice *parent) for (node = dev_read_first_subnode(parent); ofnode_valid(node); node = dev_read_next_subnode(node)) { - struct mediatek_gpio_platdata *plat; + struct mediatek_gpio_plat *plat; struct udevice *dev; plat = calloc(1, sizeof(*plat)); @@ -157,12 +157,11 @@ static int gpio_mediatek_bind(struct udevice *parent) plat->gpio_count = MTK_BANK_WIDTH; plat->bank = bank; - ret = device_bind(parent, parent->driver, - plat->bank_name, plat, -1, &dev); + ret = device_bind(parent, parent->driver, plat->bank_name, plat, + node, &dev); if (ret) return ret; - dev->node = node; bank++; } diff --git a/drivers/gpio/mvebu_gpio.c b/drivers/gpio/mvebu_gpio.c index 65eaa71c20..4c1c68ee19 100644 --- a/drivers/gpio/mvebu_gpio.c +++ b/drivers/gpio/mvebu_gpio.c @@ -92,7 +92,7 @@ static int mvebu_gpio_probe(struct udevice *dev) priv->regs = dev_read_addr_ptr(dev); uc_priv->gpio_count = MVEBU_GPIOS_PER_BANK; - priv->name[0] = 'A' + dev->req_seq; + priv->name[0] = 'A' + dev_seq(dev); uc_priv->bank_name = priv->name; return 0; @@ -117,5 +117,5 @@ U_BOOT_DRIVER(gpio_mvebu) = { .of_match = mvebu_gpio_ids, .ops = &mvebu_gpio_ops, .probe = mvebu_gpio_probe, - .priv_auto_alloc_size = sizeof(struct mvebu_gpio_priv), + .priv_auto = sizeof(struct mvebu_gpio_priv), }; diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index 88b920a074..06e6b2279f 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -281,7 +281,7 @@ static const struct dm_gpio_ops gpio_mxc_ops = { static int mxc_gpio_probe(struct udevice *dev) { struct mxc_bank_info *bank = dev_get_priv(dev); - struct mxc_gpio_plat *plat = dev_get_platdata(dev); + struct mxc_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); int banknum; char name[18], *str; @@ -307,9 +307,9 @@ static int mxc_gpio_probe(struct udevice *dev) return 0; } -static int mxc_gpio_ofdata_to_platdata(struct udevice *dev) +static int mxc_gpio_of_to_plat(struct udevice *dev) { - struct mxc_gpio_plat *plat = dev_get_platdata(dev); + struct mxc_gpio_plat *plat = dev_get_plat(dev); if (!CONFIG_IS_ENABLED(OF_PLATDATA)) { fdt_addr_t addr; addr = dev_read_addr(dev); @@ -318,7 +318,7 @@ static int mxc_gpio_ofdata_to_platdata(struct udevice *dev) plat->regs = (struct gpio_regs *)addr; } - plat->bank_index = dev->req_seq; + plat->bank_index = dev_seq(dev); return 0; } @@ -338,14 +338,14 @@ U_BOOT_DRIVER(gpio_mxc) = { .id = UCLASS_GPIO, .ops = &gpio_mxc_ops, .probe = mxc_gpio_probe, - .ofdata_to_platdata = mxc_gpio_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mxc_gpio_plat), - .priv_auto_alloc_size = sizeof(struct mxc_bank_info), + .of_to_plat = mxc_gpio_of_to_plat, + .plat_auto = sizeof(struct mxc_gpio_plat), + .priv_auto = sizeof(struct mxc_bank_info), .of_match = mxc_gpio_ids, .bind = mxc_gpio_bind, }; -U_BOOT_DRIVER_ALIAS(gpio_mxc, fsl_imx6q_gpio) +DM_DRIVER_ALIAS(gpio_mxc, fsl_imx6q_gpio) #if !CONFIG_IS_ENABLED(OF_CONTROL) static const struct mxc_gpio_plat mxc_plat[] = { @@ -372,7 +372,7 @@ static const struct mxc_gpio_plat mxc_plat[] = { #endif }; -U_BOOT_DEVICES(mxc_gpios) = { +U_BOOT_DRVINFOS(mxc_gpios) = { { "gpio_mxc", &mxc_plat[0] }, { "gpio_mxc", &mxc_plat[1] }, { "gpio_mxc", &mxc_plat[2] }, diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c index aaabb0216b..4b2b18fdb5 100644 --- a/drivers/gpio/mxs_gpio.c +++ b/drivers/gpio/mxs_gpio.c @@ -150,7 +150,7 @@ DECLARE_GLOBAL_DATA_PTR; * Bank 4: 0-20 -> 21 PINS */ -struct mxs_gpio_platdata { +struct mxs_gpio_plat { #if CONFIG_IS_ENABLED(OF_PLATDATA) struct dtd_fsl_imx23_gpio dtplat; #endif @@ -235,7 +235,7 @@ static const struct dm_gpio_ops gpio_mxs_ops = { static int mxs_gpio_probe(struct udevice *dev) { - struct mxs_gpio_platdata *plat = dev_get_platdata(dev); + struct mxs_gpio_plat *plat = dev_get_plat(dev); struct mxs_gpio_priv *priv = dev_get_priv(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); char name[16], *str; @@ -262,9 +262,9 @@ static int mxs_gpio_probe(struct udevice *dev) } #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int mxs_ofdata_to_platdata(struct udevice *dev) +static int mxs_of_to_plat(struct udevice *dev) { - struct mxs_gpio_platdata *plat = dev->platdata; + struct mxs_gpio_plat *plat = dev_get_plat(dev); struct fdtdec_phandle_args args; int node = dev_of_offset(dev); int ret; @@ -298,13 +298,13 @@ U_BOOT_DRIVER(fsl_imx23_gpio) = { .id = UCLASS_GPIO, .ops = &gpio_mxs_ops, .probe = mxs_gpio_probe, - .priv_auto_alloc_size = sizeof(struct mxs_gpio_priv), - .platdata_auto_alloc_size = sizeof(struct mxs_gpio_platdata), + .priv_auto = sizeof(struct mxs_gpio_priv), + .plat_auto = sizeof(struct mxs_gpio_plat), #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = mxs_gpio_ids, - .ofdata_to_platdata = mxs_ofdata_to_platdata, + .of_to_plat = mxs_of_to_plat, #endif }; -U_BOOT_DRIVER_ALIAS(fsl_imx23_gpio, fsl_imx28_gpio) +DM_DRIVER_ALIAS(fsl_imx23_gpio, fsl_imx28_gpio) #endif /* DM_GPIO */ diff --git a/drivers/gpio/nx_gpio.c b/drivers/gpio/nx_gpio.c index 5ec73c4359..52851e58b6 100644 --- a/drivers/gpio/nx_gpio.c +++ b/drivers/gpio/nx_gpio.c @@ -36,7 +36,7 @@ struct nx_alive_gpio_regs { u32 pad; /* Alive GPIO Input Value Register */ }; -struct nx_gpio_platdata { +struct nx_gpio_plat { void *regs; int gpio_count; const char *bank_name; @@ -44,7 +44,7 @@ struct nx_gpio_platdata { static int nx_alive_gpio_is_check(struct udevice *dev) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); const char *bank_name = plat->bank_name; if (!strcmp(bank_name, "gpio_alv")) @@ -55,7 +55,7 @@ static int nx_alive_gpio_is_check(struct udevice *dev) static int nx_alive_gpio_direction_input(struct udevice *dev, unsigned int pin) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_alive_gpio_regs *const regs = plat->regs; setbits_le32(®s->outputenb_reset, 1 << pin); @@ -66,7 +66,7 @@ static int nx_alive_gpio_direction_input(struct udevice *dev, unsigned int pin) static int nx_alive_gpio_direction_output(struct udevice *dev, unsigned int pin, int val) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_alive_gpio_regs *const regs = plat->regs; if (val) @@ -81,7 +81,7 @@ static int nx_alive_gpio_direction_output(struct udevice *dev, unsigned int pin, static int nx_alive_gpio_get_value(struct udevice *dev, unsigned int pin) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_alive_gpio_regs *const regs = plat->regs; unsigned int mask = 1UL << pin; unsigned int value; @@ -94,7 +94,7 @@ static int nx_alive_gpio_get_value(struct udevice *dev, unsigned int pin) static int nx_alive_gpio_set_value(struct udevice *dev, unsigned int pin, int val) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_alive_gpio_regs *const regs = plat->regs; if (val) @@ -107,7 +107,7 @@ static int nx_alive_gpio_set_value(struct udevice *dev, unsigned int pin, static int nx_alive_gpio_get_function(struct udevice *dev, unsigned int pin) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_alive_gpio_regs *const regs = plat->regs; unsigned int mask = (1UL << pin); unsigned int output; @@ -122,7 +122,7 @@ static int nx_alive_gpio_get_function(struct udevice *dev, unsigned int pin) static int nx_gpio_direction_input(struct udevice *dev, unsigned int pin) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_gpio_regs *const regs = plat->regs; if (nx_alive_gpio_is_check(dev)) @@ -136,7 +136,7 @@ static int nx_gpio_direction_input(struct udevice *dev, unsigned int pin) static int nx_gpio_direction_output(struct udevice *dev, unsigned int pin, int val) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_gpio_regs *const regs = plat->regs; if (nx_alive_gpio_is_check(dev)) @@ -154,7 +154,7 @@ static int nx_gpio_direction_output(struct udevice *dev, unsigned int pin, static int nx_gpio_get_value(struct udevice *dev, unsigned int pin) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_gpio_regs *const regs = plat->regs; unsigned int mask = 1UL << pin; unsigned int value; @@ -169,7 +169,7 @@ static int nx_gpio_get_value(struct udevice *dev, unsigned int pin) static int nx_gpio_set_value(struct udevice *dev, unsigned int pin, int val) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_gpio_regs *const regs = plat->regs; if (nx_alive_gpio_is_check(dev)) @@ -185,7 +185,7 @@ static int nx_gpio_set_value(struct udevice *dev, unsigned int pin, int val) static int nx_gpio_get_function(struct udevice *dev, unsigned int pin) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); struct nx_gpio_regs *const regs = plat->regs; unsigned int mask = (1UL << pin); unsigned int output; @@ -204,7 +204,7 @@ static int nx_gpio_get_function(struct udevice *dev, unsigned int pin) static int nx_gpio_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); uc_priv->gpio_count = plat->gpio_count; uc_priv->bank_name = plat->bank_name; @@ -212,9 +212,9 @@ static int nx_gpio_probe(struct udevice *dev) return 0; } -static int nx_gpio_ofdata_to_platdata(struct udevice *dev) +static int nx_gpio_of_to_plat(struct udevice *dev) { - struct nx_gpio_platdata *plat = dev_get_platdata(dev); + struct nx_gpio_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(devfdt_get_addr(dev), sizeof(struct nx_gpio_regs), @@ -244,7 +244,7 @@ U_BOOT_DRIVER(nx_gpio) = { .id = UCLASS_GPIO, .of_match = nx_gpio_ids, .ops = &nx_gpio_ops, - .ofdata_to_platdata = nx_gpio_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct nx_gpio_platdata), + .of_to_plat = nx_gpio_of_to_plat, + .plat_auto = sizeof(struct nx_gpio_plat), .probe = nx_gpio_probe, }; diff --git a/drivers/gpio/octeon_gpio.c b/drivers/gpio/octeon_gpio.c index 45acaadcdb..42eae79d8c 100644 --- a/drivers/gpio/octeon_gpio.c +++ b/drivers/gpio/octeon_gpio.c @@ -190,7 +190,7 @@ static int octeon_gpio_probe(struct udevice *dev) GPIO_CONST_GPIOS_MASK; } else { priv->base = dev_remap_addr(dev); - uc_priv->gpio_count = ofnode_read_u32_default(dev->node, + uc_priv->gpio_count = ofnode_read_u32_default(dev_ofnode(dev), "nr-gpios", 32); } @@ -202,7 +202,7 @@ static int octeon_gpio_probe(struct udevice *dev) uc_priv->bank_name = strdup(dev->name); end = strchr(uc_priv->bank_name, '@'); - end[0] = 'A' + dev->seq; + end[0] = 'A' + dev_seq(dev); end[1] = '\0'; debug("%s(%s): base address: %p, pin count: %d\n", @@ -236,7 +236,7 @@ U_BOOT_DRIVER(octeon_gpio) = { .id = UCLASS_GPIO, .of_match = of_match_ptr(octeon_gpio_ids), .probe = octeon_gpio_probe, - .priv_auto_alloc_size = sizeof(struct octeon_gpio), + .priv_auto = sizeof(struct octeon_gpio), .ops = &octeon_gpio_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index 6eaa0a08a2..336ece4778 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -22,6 +22,7 @@ #include <fdtdec.h> #include <asm/gpio.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <linux/errno.h> #include <malloc.h> @@ -285,7 +286,7 @@ static const struct dm_gpio_ops gpio_omap_ops = { static int omap_gpio_probe(struct udevice *dev) { struct gpio_bank *bank = dev_get_priv(dev); - struct omap_gpio_platdata *plat = dev_get_platdata(dev); + struct omap_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); char name[18], *str; @@ -302,7 +303,7 @@ static int omap_gpio_probe(struct udevice *dev) #if !CONFIG_IS_ENABLED(OF_CONTROL) static int omap_gpio_bind(struct udevice *dev) { - struct omap_gpio_platdata *plat = dev_get_platdata(dev); + struct omap_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t base_addr; if (plat) @@ -316,7 +317,7 @@ static int omap_gpio_bind(struct udevice *dev) * TODO: * When every board is converted to driver model and DT is * supported, this can be done by auto-alloc feature, but - * not using calloc to alloc memory for platdata. + * not using calloc to alloc memory for plat. * * For example am33xx_gpio uses platform data rather than device tree. * @@ -328,7 +329,7 @@ static int omap_gpio_bind(struct udevice *dev) plat->base = base_addr; plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL); - dev->platdata = plat; + dev_set_plat(dev, plat); return 0; } @@ -342,9 +343,9 @@ static const struct udevice_id omap_gpio_ids[] = { { } }; -static int omap_gpio_ofdata_to_platdata(struct udevice *dev) +static int omap_gpio_of_to_plat(struct udevice *dev) { - struct omap_gpio_platdata *plat = dev_get_platdata(dev); + struct omap_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -362,15 +363,15 @@ U_BOOT_DRIVER(gpio_omap) = { #if CONFIG_IS_ENABLED(OF_CONTROL) #if !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = omap_gpio_ids, - .ofdata_to_platdata = of_match_ptr(omap_gpio_ofdata_to_platdata), - .platdata_auto_alloc_size = sizeof(struct omap_gpio_platdata), + .of_to_plat = of_match_ptr(omap_gpio_of_to_plat), + .plat_auto = sizeof(struct omap_gpio_plat), #endif #else .bind = omap_gpio_bind, #endif .ops = &gpio_omap_ops, .probe = omap_gpio_probe, - .priv_auto_alloc_size = sizeof(struct gpio_bank), + .priv_auto = sizeof(struct gpio_bank), #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, #endif diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c index fd17d1a591..dc8911a8eb 100644 --- a/drivers/gpio/pca953x_gpio.c +++ b/drivers/gpio/pca953x_gpio.c @@ -76,7 +76,7 @@ struct pca953x_info { static int pca953x_write_single(struct udevice *dev, int reg, u8 val, int offset) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); int bank_shift = fls((info->gpio_count - 1) / BANK_SZ); int off = offset / BANK_SZ; int ret = 0; @@ -93,7 +93,7 @@ static int pca953x_write_single(struct udevice *dev, int reg, u8 val, static int pca953x_read_single(struct udevice *dev, int reg, u8 *val, int offset) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); int bank_shift = fls((info->gpio_count - 1) / BANK_SZ); int off = offset / BANK_SZ; int ret; @@ -112,7 +112,7 @@ static int pca953x_read_single(struct udevice *dev, int reg, u8 *val, static int pca953x_read_regs(struct udevice *dev, int reg, u8 *val) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); int ret = 0; if (info->gpio_count <= 8) { @@ -137,7 +137,7 @@ static int pca953x_read_regs(struct udevice *dev, int reg, u8 *val) static int pca953x_write_regs(struct udevice *dev, int reg, u8 *val) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); int ret = 0; if (info->gpio_count <= 8) { @@ -160,7 +160,7 @@ static int pca953x_write_regs(struct udevice *dev, int reg, u8 *val) static int pca953x_is_output(struct udevice *dev, int offset) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); int bank = offset / BANK_SZ; int off = offset % BANK_SZ; @@ -185,7 +185,7 @@ static int pca953x_get_value(struct udevice *dev, uint offset) static int pca953x_set_value(struct udevice *dev, uint offset, int value) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); int bank = offset / BANK_SZ; int off = offset % BANK_SZ; u8 val; @@ -207,7 +207,7 @@ static int pca953x_set_value(struct udevice *dev, uint offset, int value) static int pca953x_set_direction(struct udevice *dev, uint offset, int dir) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); int bank = offset / BANK_SZ; int off = offset % BANK_SZ; u8 val; @@ -271,7 +271,7 @@ static const struct dm_gpio_ops pca953x_ops = { static int pca953x_probe(struct udevice *dev) { - struct pca953x_info *info = dev_get_platdata(dev); + struct pca953x_info *info = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); char name[32], label[8], *str; int addr; @@ -385,6 +385,6 @@ U_BOOT_DRIVER(pca953x) = { .id = UCLASS_GPIO, .ops = &pca953x_ops, .probe = pca953x_probe, - .platdata_auto_alloc_size = sizeof(struct pca953x_info), + .plat_auto = sizeof(struct pca953x_info), .of_match = pca953x_ids, }; diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c index 1b9a18fe5d..6d38646ef6 100644 --- a/drivers/gpio/pcf8575_gpio.c +++ b/drivers/gpio/pcf8575_gpio.c @@ -55,7 +55,7 @@ struct pcf8575_chip { static int pcf8575_i2c_write_le16(struct udevice *dev, unsigned int word) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); u8 buf[2] = { word & 0xff, word >> 8, }; int ret; @@ -69,7 +69,7 @@ static int pcf8575_i2c_write_le16(struct udevice *dev, unsigned int word) static int pcf8575_i2c_read_le16(struct udevice *dev) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); u8 buf[2]; int ret; @@ -85,7 +85,7 @@ static int pcf8575_i2c_read_le16(struct udevice *dev) static int pcf8575_direction_input(struct udevice *dev, unsigned offset) { - struct pcf8575_chip *plat = dev_get_platdata(dev); + struct pcf8575_chip *plat = dev_get_plat(dev); int status; plat->out |= BIT(offset); @@ -97,7 +97,7 @@ static int pcf8575_direction_input(struct udevice *dev, unsigned offset) static int pcf8575_direction_output(struct udevice *dev, unsigned int offset, int value) { - struct pcf8575_chip *plat = dev_get_platdata(dev); + struct pcf8575_chip *plat = dev_get_plat(dev); int ret; if (value) @@ -125,9 +125,9 @@ static int pcf8575_set_value(struct udevice *dev, unsigned int offset, return pcf8575_direction_output(dev, offset, value); } -static int pcf8575_ofdata_platdata(struct udevice *dev) +static int pcf8575_ofdata_plat(struct udevice *dev) { - struct pcf8575_chip *plat = dev_get_platdata(dev); + struct pcf8575_chip *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); int n_latch; @@ -175,7 +175,7 @@ U_BOOT_DRIVER(gpio_pcf8575) = { .id = UCLASS_GPIO, .ops = &pcf8575_gpio_ops, .of_match = pcf8575_gpio_ids, - .ofdata_to_platdata = pcf8575_ofdata_platdata, + .of_to_plat = pcf8575_ofdata_plat, .probe = pcf8575_gpio_probe, - .platdata_auto_alloc_size = sizeof(struct pcf8575_chip), + .plat_auto = sizeof(struct pcf8575_chip), }; diff --git a/drivers/gpio/pic32_gpio.c b/drivers/gpio/pic32_gpio.c index bb1ad256fa..253a9ba2f8 100644 --- a/drivers/gpio/pic32_gpio.c +++ b/drivers/gpio/pic32_gpio.c @@ -161,5 +161,5 @@ U_BOOT_DRIVER(gpio_pic32) = { .of_match = pic32_gpio_ids, .ops = &gpio_pic32_ops, .probe = pic32_gpio_probe, - .priv_auto_alloc_size = sizeof(struct pic32_gpio_priv), + .priv_auto = sizeof(struct pic32_gpio_priv), }; diff --git a/drivers/gpio/pm8916_gpio.c b/drivers/gpio/pm8916_gpio.c index 58f044678b..40b0f2578b 100644 --- a/drivers/gpio/pm8916_gpio.c +++ b/drivers/gpio/pm8916_gpio.c @@ -187,7 +187,7 @@ static int pm8916_gpio_probe(struct udevice *dev) return 0; } -static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev) +static int pm8916_gpio_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); @@ -209,10 +209,10 @@ U_BOOT_DRIVER(gpio_pm8916) = { .name = "gpio_pm8916", .id = UCLASS_GPIO, .of_match = pm8916_gpio_ids, - .ofdata_to_platdata = pm8916_gpio_ofdata_to_platdata, + .of_to_plat = pm8916_gpio_of_to_plat, .probe = pm8916_gpio_probe, .ops = &pm8916_gpio_ops, - .priv_auto_alloc_size = sizeof(struct pm8916_gpio_bank), + .priv_auto = sizeof(struct pm8916_gpio_bank), }; @@ -272,7 +272,7 @@ static int pm8941_pwrkey_probe(struct udevice *dev) return 0; } -static int pm8941_pwrkey_ofdata_to_platdata(struct udevice *dev) +static int pm8941_pwrkey_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); @@ -294,8 +294,8 @@ U_BOOT_DRIVER(pwrkey_pm8941) = { .name = "pwrkey_pm8916", .id = UCLASS_GPIO, .of_match = pm8941_pwrkey_ids, - .ofdata_to_platdata = pm8941_pwrkey_ofdata_to_platdata, + .of_to_plat = pm8941_pwrkey_of_to_plat, .probe = pm8941_pwrkey_probe, .ops = &pm8941_pwrkey_ops, - .priv_auto_alloc_size = sizeof(struct pm8916_gpio_bank), + .priv_auto = sizeof(struct pm8916_gpio_bank), }; diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c index 8cc288581c..68f30157a9 100644 --- a/drivers/gpio/rk_gpio.c +++ b/drivers/gpio/rk_gpio.c @@ -177,6 +177,6 @@ U_BOOT_DRIVER(rockchip_gpio_bank) = { .id = UCLASS_GPIO, .of_match = rockchip_gpio_ids, .ops = &gpio_rockchip_ops, - .priv_auto_alloc_size = sizeof(struct rockchip_gpio_priv), + .priv_auto = sizeof(struct rockchip_gpio_priv), .probe = rockchip_gpio_probe, }; diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index c78227f4da..796fe3e110 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -34,7 +34,7 @@ DECLARE_GLOBAL_DATA_PTR; #define RATE_SET(gpio) (0x1 << (gpio + 16)) /* Platform data for each bank */ -struct exynos_gpio_platdata { +struct exynos_gpio_plat { struct s5p_gpio_bank *bank; const char *bank_name; /* Name of port, e.g. 'gpa0" */ }; @@ -286,8 +286,8 @@ static const struct dm_gpio_ops gpio_exynos_ops = { static int gpio_exynos_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - struct exynos_bank_info *priv = dev->priv; - struct exynos_gpio_platdata *plat = dev->platdata; + struct exynos_bank_info *priv = dev_get_priv(dev); + struct exynos_gpio_plat *plat = dev_get_plat(dev); /* Only child devices have ports */ if (!plat) @@ -307,7 +307,7 @@ static int gpio_exynos_probe(struct udevice *dev) */ static int gpio_exynos_bind(struct udevice *parent) { - struct exynos_gpio_platdata *plat = parent->platdata; + struct exynos_gpio_plat *plat = dev_get_plat(parent); struct s5p_gpio_bank *bank, *base; const void *blob = gd->fdt_blob; int node; @@ -320,7 +320,7 @@ static int gpio_exynos_bind(struct udevice *parent) for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base; node > 0; node = fdt_next_subnode(blob, node), bank++) { - struct exynos_gpio_platdata *plat; + struct exynos_gpio_plat *plat; struct udevice *dev; fdt_addr_t reg; int ret; @@ -332,13 +332,11 @@ static int gpio_exynos_bind(struct udevice *parent) return -ENOMEM; plat->bank_name = fdt_get_name(blob, node, NULL); - ret = device_bind(parent, parent->driver, - plat->bank_name, plat, -1, &dev); + ret = device_bind(parent, parent->driver, plat->bank_name, plat, + offset_to_ofnode(node), &dev); if (ret) return ret; - dev_set_of_offset(dev, node); - reg = dev_read_addr(dev); if (reg != FDT_ADDR_T_NONE) bank = (struct s5p_gpio_bank *)((ulong)base + reg); @@ -367,7 +365,7 @@ U_BOOT_DRIVER(gpio_exynos) = { .of_match = exynos_gpio_ids, .bind = gpio_exynos_bind, .probe = gpio_exynos_probe, - .priv_auto_alloc_size = sizeof(struct exynos_bank_info), + .priv_auto = sizeof(struct exynos_bank_info), .ops = &gpio_exynos_ops, }; #endif diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index eb2600de31..dc8d506e8d 100644 --- a/drivers/gpio/sandbox.c +++ b/drivers/gpio/sandbox.c @@ -11,6 +11,7 @@ #include <acpi/acpi_device.h> #include <asm/gpio.h> #include <dm/acpi.h> +#include <dm/device-internal.h> #include <dm/device_compat.h> #include <dm/lists.h> #include <dm/of.h> @@ -278,7 +279,7 @@ static const struct dm_gpio_ops gpio_sandbox_ops = { #endif }; -static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev) +static int sandbox_gpio_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); @@ -293,18 +294,19 @@ static int gpio_sandbox_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) /* Tell the uclass how many GPIOs we have */ uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT; - dev->priv = calloc(sizeof(struct gpio_state), uc_priv->gpio_count); + dev_set_priv(dev, + calloc(sizeof(struct gpio_state), uc_priv->gpio_count)); return 0; } static int gpio_sandbox_remove(struct udevice *dev) { - free(dev->priv); + free(dev_get_priv(dev)); return 0; } @@ -318,14 +320,14 @@ U_BOOT_DRIVER(sandbox_gpio) = { .name = "sandbox_gpio", .id = UCLASS_GPIO, .of_match = sandbox_gpio_ids, - .ofdata_to_platdata = sandbox_gpio_ofdata_to_platdata, + .of_to_plat = sandbox_gpio_of_to_plat, .probe = gpio_sandbox_probe, .remove = gpio_sandbox_remove, .ops = &gpio_sandbox_ops, ACPI_OPS_PTR(&gpio_sandbox_acpi_ops) }; -U_BOOT_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias) +DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias) /* pincontrol: used only to check GPIO pin configuration (pinmux command) */ @@ -532,6 +534,6 @@ U_BOOT_DRIVER(sandbox_pinctrl_gpio) = { .ops = &sandbox_pinctrl_gpio_ops, .bind = dm_scan_fdt_dev, .probe = sandbox_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct sb_pinctrl_priv), + .priv_auto = sizeof(struct sb_pinctrl_priv), ACPI_OPS_PTR(&pinctrl_sandbox_acpi_ops) }; diff --git a/drivers/gpio/sifive-gpio.c b/drivers/gpio/sifive-gpio.c index bf3537b76b..abd1f629b9 100644 --- a/drivers/gpio/sifive-gpio.c +++ b/drivers/gpio/sifive-gpio.c @@ -15,7 +15,7 @@ static int sifive_gpio_probe(struct udevice *dev) { - struct sifive_gpio_platdata *plat = dev_get_platdata(dev); + struct sifive_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); char name[18], *str; @@ -49,7 +49,7 @@ static void sifive_update_gpio_reg(void *bptr, u32 offset, bool value) static int sifive_gpio_direction_input(struct udevice *dev, u32 offset) { - struct sifive_gpio_platdata *plat = dev_get_platdata(dev); + struct sifive_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); if (offset > uc_priv->gpio_count) @@ -65,7 +65,7 @@ static int sifive_gpio_direction_input(struct udevice *dev, u32 offset) static int sifive_gpio_direction_output(struct udevice *dev, u32 offset, int value) { - struct sifive_gpio_platdata *plat = dev_get_platdata(dev); + struct sifive_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); if (offset > uc_priv->gpio_count) @@ -83,7 +83,7 @@ static int sifive_gpio_direction_output(struct udevice *dev, u32 offset, static int sifive_gpio_get_value(struct udevice *dev, u32 offset) { - struct sifive_gpio_platdata *plat = dev_get_platdata(dev); + struct sifive_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); int val; int dir; @@ -104,7 +104,7 @@ static int sifive_gpio_get_value(struct udevice *dev, u32 offset) static int sifive_gpio_set_value(struct udevice *dev, u32 offset, int value) { - struct sifive_gpio_platdata *plat = dev_get_platdata(dev); + struct sifive_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); if (offset > uc_priv->gpio_count) @@ -117,7 +117,7 @@ static int sifive_gpio_set_value(struct udevice *dev, u32 offset, int value) static int sifive_gpio_get_function(struct udevice *dev, unsigned int offset) { - struct sifive_gpio_platdata *plat = dev_get_platdata(dev); + struct sifive_gpio_plat *plat = dev_get_plat(dev); u32 outdir, indir, val; struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); @@ -154,9 +154,9 @@ static const struct dm_gpio_ops sifive_gpio_ops = { .get_function = sifive_gpio_get_function, }; -static int sifive_gpio_ofdata_to_platdata(struct udevice *dev) +static int sifive_gpio_of_to_plat(struct udevice *dev) { - struct sifive_gpio_platdata *plat = dev_get_platdata(dev); + struct sifive_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -171,8 +171,8 @@ U_BOOT_DRIVER(gpio_sifive) = { .name = "gpio_sifive", .id = UCLASS_GPIO, .of_match = sifive_gpio_match, - .ofdata_to_platdata = of_match_ptr(sifive_gpio_ofdata_to_platdata), - .platdata_auto_alloc_size = sizeof(struct sifive_gpio_platdata), + .of_to_plat = of_match_ptr(sifive_gpio_of_to_plat), + .plat_auto = sizeof(struct sifive_gpio_plat), .ops = &sifive_gpio_ops, .probe = sifive_gpio_probe, }; diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c index 51e1efd701..79d55e812d 100644 --- a/drivers/gpio/stm32_gpio.c +++ b/drivers/gpio/stm32_gpio.c @@ -342,5 +342,5 @@ U_BOOT_DRIVER(gpio_stm32) = { .probe = gpio_stm32_probe, .ops = &gpio_stm32_ops, .flags = DM_UC_FLAG_SEQ_ALIAS, - .priv_auto_alloc_size = sizeof(struct stm32_gpio_priv), + .priv_auto = sizeof(struct stm32_gpio_priv), }; diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c index 02c3471b56..7633422b0b 100644 --- a/drivers/gpio/sunxi_gpio.c +++ b/drivers/gpio/sunxi_gpio.c @@ -22,7 +22,7 @@ #define SUNXI_GPIOS_PER_BANK SUNXI_GPIO_A_NR -struct sunxi_gpio_platdata { +struct sunxi_gpio_plat { struct sunxi_gpio *regs; const char *bank_name; /* Name of bank, e.g. "B" */ int gpio_count; @@ -158,7 +158,7 @@ int sunxi_name_to_gpio(const char *name) static int sunxi_gpio_direction_input(struct udevice *dev, unsigned offset) { - struct sunxi_gpio_platdata *plat = dev_get_platdata(dev); + struct sunxi_gpio_plat *plat = dev_get_plat(dev); sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_INPUT); @@ -168,7 +168,7 @@ static int sunxi_gpio_direction_input(struct udevice *dev, unsigned offset) static int sunxi_gpio_direction_output(struct udevice *dev, unsigned offset, int value) { - struct sunxi_gpio_platdata *plat = dev_get_platdata(dev); + struct sunxi_gpio_plat *plat = dev_get_plat(dev); u32 num = GPIO_NUM(offset); sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_OUTPUT); @@ -179,7 +179,7 @@ static int sunxi_gpio_direction_output(struct udevice *dev, unsigned offset, static int sunxi_gpio_get_value(struct udevice *dev, unsigned offset) { - struct sunxi_gpio_platdata *plat = dev_get_platdata(dev); + struct sunxi_gpio_plat *plat = dev_get_plat(dev); u32 num = GPIO_NUM(offset); unsigned dat; @@ -192,7 +192,7 @@ static int sunxi_gpio_get_value(struct udevice *dev, unsigned offset) static int sunxi_gpio_set_value(struct udevice *dev, unsigned offset, int value) { - struct sunxi_gpio_platdata *plat = dev_get_platdata(dev); + struct sunxi_gpio_plat *plat = dev_get_plat(dev); u32 num = GPIO_NUM(offset); clrsetbits_le32(&plat->regs->dat, 1 << num, value ? (1 << num) : 0); @@ -201,7 +201,7 @@ static int sunxi_gpio_set_value(struct udevice *dev, unsigned offset, static int sunxi_gpio_get_function(struct udevice *dev, unsigned offset) { - struct sunxi_gpio_platdata *plat = dev_get_platdata(dev); + struct sunxi_gpio_plat *plat = dev_get_plat(dev); int func; func = sunxi_gpio_get_cfgbank(plat->regs, offset); @@ -260,7 +260,7 @@ static char *gpio_bank_name(int bank) static int gpio_sunxi_probe(struct udevice *dev) { - struct sunxi_gpio_platdata *plat = dev_get_platdata(dev); + struct sunxi_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); /* Tell the uclass how many GPIOs we have */ @@ -285,7 +285,7 @@ static int gpio_sunxi_bind(struct udevice *parent) { struct sunxi_gpio_soc_data *soc_data = (struct sunxi_gpio_soc_data *)dev_get_driver_data(parent); - struct sunxi_gpio_platdata *plat = parent->platdata; + struct sunxi_gpio_plat *plat = dev_get_plat(parent); struct sunxi_gpio_reg *ctlr; int bank, ret; @@ -295,7 +295,7 @@ static int gpio_sunxi_bind(struct udevice *parent) ctlr = dev_read_addr_ptr(parent); for (bank = 0; bank < soc_data->no_banks; bank++) { - struct sunxi_gpio_platdata *plat; + struct sunxi_gpio_plat *plat; struct udevice *dev; plat = calloc(1, sizeof(*plat)); @@ -305,11 +305,10 @@ static int gpio_sunxi_bind(struct udevice *parent) plat->bank_name = gpio_bank_name(soc_data->start + bank); plat->gpio_count = SUNXI_GPIOS_PER_BANK; - ret = device_bind(parent, parent->driver, - plat->bank_name, plat, -1, &dev); + ret = device_bind(parent, parent->driver, plat->bank_name, plat, + dev_ofnode(parent), &dev); if (ret) return ret; - dev_set_of_offset(dev, dev_of_offset(parent)); } return 0; diff --git a/drivers/gpio/tca642x.c b/drivers/gpio/tca642x.c index 463cfe879a..7007c7a002 100644 --- a/drivers/gpio/tca642x.c +++ b/drivers/gpio/tca642x.c @@ -213,6 +213,24 @@ static int tca642x_info(uchar chip) return 0; } +static int tca642x_get_bank(int pin) +{ + int gpio_bank; + + if (pin <= 7) { + gpio_bank = 0; + } else if ((pin >= 10) && (pin <= 17)) { + gpio_bank = 1; + } else if ((pin >= 20) && (pin <= 27)) { + gpio_bank = 2; + } else { + printf("Requested pin is not available\n"); + gpio_bank = -1; + } + + return gpio_bank; +} + static struct cmd_tbl cmd_tca642x[] = { U_BOOT_CMD_MKENT(device, 3, 0, (void *)TCA642X_CMD_DEVICE, "", ""), U_BOOT_CMD_MKENT(output, 4, 0, (void *)TCA642X_CMD_OUTPUT, "", ""), @@ -226,7 +244,7 @@ static int do_tca642x(struct cmd_tbl *cmdtp, int flag, int argc, { static uchar chip = CONFIG_SYS_I2C_TCA642X_ADDR; int ret = CMD_RET_USAGE, val; - uint8_t gpio_bank = 0; + int gpio_bank = 0; uint8_t bank_shift; ulong ul_arg2 = 0; ulong ul_arg3 = 0; @@ -247,20 +265,8 @@ static int do_tca642x(struct cmd_tbl *cmdtp, int flag, int argc, ul_arg2 = simple_strtoul(argv[2], NULL, 10); /* arg3 used as pin or invert value */ - if (argc > 3) { + if (argc > 3) ul_arg3 = simple_strtoul(argv[3], NULL, 10) & 0x1; - if (ul_arg2 <= 7) { - gpio_bank = 0; - } else if ((ul_arg2 >= 10) && (ul_arg2 <= 17)) { - gpio_bank = 1; - } else if ((ul_arg2 >= 20) && (ul_arg2 <= 27)) { - gpio_bank = 2; - } else { - printf("Requested pin is not available\n"); - ret = CMD_RET_FAILURE; - goto error; - } - } switch ((int)c->cmd) { case TCA642X_CMD_INFO: @@ -277,6 +283,11 @@ static int do_tca642x(struct cmd_tbl *cmdtp, int flag, int argc, break; case TCA642X_CMD_INPUT: + gpio_bank = tca642x_get_bank(ul_arg2); + if (gpio_bank < 0) { + ret = CMD_RET_FAILURE; + goto error; + } bank_shift = ul_arg2 - (gpio_bank * 10); ret = tca642x_set_dir(chip, gpio_bank, (1 << bank_shift), TCA642X_DIR_IN << bank_shift); @@ -291,6 +302,11 @@ static int do_tca642x(struct cmd_tbl *cmdtp, int flag, int argc, break; case TCA642X_CMD_OUTPUT: + gpio_bank = tca642x_get_bank(ul_arg2); + if (gpio_bank < 0) { + ret = CMD_RET_FAILURE; + goto error; + } bank_shift = ul_arg2 - (gpio_bank * 10); ret = tca642x_set_dir(chip, gpio_bank, (1 << bank_shift), (TCA642X_DIR_OUT << bank_shift)); @@ -303,6 +319,11 @@ static int do_tca642x(struct cmd_tbl *cmdtp, int flag, int argc, break; case TCA642X_CMD_INVERT: + gpio_bank = tca642x_get_bank(ul_arg2); + if (gpio_bank < 0) { + ret = CMD_RET_FAILURE; + goto error; + } bank_shift = ul_arg2 - (gpio_bank * 10); ret = tca642x_set_pol(chip, gpio_bank, (1 << bank_shift), (ul_arg3 << bank_shift)); diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c index 6626b5415a..82dcaf9631 100644 --- a/drivers/gpio/tegra186_gpio.c +++ b/drivers/gpio/tegra186_gpio.c @@ -26,7 +26,7 @@ struct tegra186_gpio_ctlr_data { uint32_t port_count; }; -struct tegra186_gpio_platdata { +struct tegra186_gpio_plat { const char *name; uint32_t *regs; }; @@ -34,7 +34,7 @@ struct tegra186_gpio_platdata { static uint32_t *tegra186_gpio_reg(struct udevice *dev, uint32_t reg, uint32_t gpio) { - struct tegra186_gpio_platdata *plat = dev->platdata; + struct tegra186_gpio_plat *plat = dev_get_plat(dev); uint32_t index = (reg + (gpio * TEGRA186_GPIO_PER_GPIO_STRIDE)) / 4; return &(plat->regs[index]); @@ -166,7 +166,7 @@ static const struct dm_gpio_ops tegra186_gpio_ops = { */ static int tegra186_gpio_bind(struct udevice *parent) { - struct tegra186_gpio_platdata *parent_plat = parent->platdata; + struct tegra186_gpio_plat *parent_plat = dev_get_plat(parent); struct tegra186_gpio_ctlr_data *ctlr_data = (struct tegra186_gpio_ctlr_data *)dev_get_driver_data(parent); uint32_t *regs; @@ -181,7 +181,7 @@ static int tegra186_gpio_bind(struct udevice *parent) return -EINVAL; for (port = 0; port < ctlr_data->port_count; port++) { - struct tegra186_gpio_platdata *plat; + struct tegra186_gpio_plat *plat; struct udevice *dev; plat = calloc(1, sizeof(*plat)); @@ -191,10 +191,9 @@ static int tegra186_gpio_bind(struct udevice *parent) plat->regs = &(regs[ctlr_data->ports[port].offset / 4]); ret = device_bind(parent, parent->driver, plat->name, plat, - -1, &dev); + dev_ofnode(parent), &dev); if (ret) return ret; - dev_set_of_offset(dev, dev_of_offset(parent)); } return 0; @@ -202,7 +201,7 @@ static int tegra186_gpio_bind(struct udevice *parent) static int tegra186_gpio_probe(struct udevice *dev) { - struct tegra186_gpio_platdata *plat = dev->platdata; + struct tegra186_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); /* Only child devices have ports */ diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c index 912577a571..5d3af8a016 100644 --- a/drivers/gpio/tegra_gpio.c +++ b/drivers/gpio/tegra_gpio.c @@ -28,7 +28,7 @@ static const int CONFIG_GPIO = 1; static const int DIRECTION_INPUT = 0; static const int DIRECTION_OUTPUT = 1; -struct tegra_gpio_platdata { +struct tegra_gpio_plat { struct gpio_ctlr_bank *bank; const char *port_name; /* Name of port, e.g. "B" */ int base_gpio; /* Port number for this port (0, 1,.., n-1) */ @@ -291,8 +291,8 @@ static const struct udevice_id tegra_gpio_ids[] = { static int gpio_tegra_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - struct tegra_port_info *priv = dev->priv; - struct tegra_gpio_platdata *plat = dev->platdata; + struct tegra_port_info *priv = dev_get_priv(dev); + struct tegra_gpio_plat *plat = dev_get_plat(dev); /* Only child devices have ports */ if (!plat) @@ -313,7 +313,7 @@ static int gpio_tegra_probe(struct udevice *dev) */ static int gpio_tegra_bind(struct udevice *parent) { - struct tegra_gpio_platdata *plat = parent->platdata; + struct tegra_gpio_plat *plat = dev_get_plat(parent); struct gpio_ctlr *ctlr; int bank_count; int bank; @@ -348,7 +348,7 @@ static int gpio_tegra_bind(struct udevice *parent) int port; for (port = 0; port < TEGRA_PORTS_PER_BANK; port++) { - struct tegra_gpio_platdata *plat; + struct tegra_gpio_plat *plat; struct udevice *dev; int base_port; @@ -361,10 +361,10 @@ static int gpio_tegra_bind(struct udevice *parent) plat->port_name = gpio_port_name(base_port); ret = device_bind(parent, parent->driver, - plat->port_name, plat, -1, &dev); + plat->port_name, plat, + dev_ofnode(parent), &dev); if (ret) return ret; - dev_set_of_offset(dev, dev_of_offset(parent)); } } @@ -377,6 +377,6 @@ U_BOOT_DRIVER(gpio_tegra) = { .of_match = tegra_gpio_ids, .bind = gpio_tegra_bind, .probe = gpio_tegra_probe, - .priv_auto_alloc_size = sizeof(struct tegra_port_info), + .priv_auto = sizeof(struct tegra_port_info), .ops = &gpio_tegra_ops, }; diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c index 4efff5c364..fcce90c53c 100644 --- a/drivers/gpio/vybrid_gpio.c +++ b/drivers/gpio/vybrid_gpio.c @@ -93,7 +93,7 @@ static const struct dm_gpio_ops gpio_vybrid_ops = { static int vybrid_gpio_probe(struct udevice *dev) { struct vybrid_gpios *gpios = dev_get_priv(dev); - struct vybrid_gpio_platdata *plat = dev_get_platdata(dev); + struct vybrid_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); uc_priv->bank_name = plat->port_name; @@ -104,9 +104,9 @@ static int vybrid_gpio_probe(struct udevice *dev) return 0; } -static int vybrid_gpio_odata_to_platdata(struct udevice *dev) +static int vybrid_gpio_odata_to_plat(struct udevice *dev) { - struct vybrid_gpio_platdata *plat = dev_get_platdata(dev); + struct vybrid_gpio_plat *plat = dev_get_plat(dev); fdt_addr_t base_addr; base_addr = dev_read_addr(dev); @@ -114,7 +114,7 @@ static int vybrid_gpio_odata_to_platdata(struct udevice *dev) return -EINVAL; plat->base = base_addr; - plat->chip = dev->req_seq; + plat->chip = dev_seq(dev); plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL); return 0; @@ -130,8 +130,8 @@ U_BOOT_DRIVER(gpio_vybrid) = { .id = UCLASS_GPIO, .ops = &gpio_vybrid_ops, .of_match = vybrid_gpio_ids, - .ofdata_to_platdata = vybrid_gpio_odata_to_platdata, + .of_to_plat = vybrid_gpio_odata_to_plat, .probe = vybrid_gpio_probe, - .priv_auto_alloc_size = sizeof(struct vybrid_gpios), - .platdata_auto_alloc_size = sizeof(struct vybrid_gpio_platdata), + .priv_auto = sizeof(struct vybrid_gpios), + .plat_auto = sizeof(struct vybrid_gpio_plat), }; diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c index 014f120d60..510838d2f5 100644 --- a/drivers/gpio/xilinx_gpio.c +++ b/drivers/gpio/xilinx_gpio.c @@ -21,7 +21,7 @@ struct gpio_regs { u32 gpiodir; }; -struct xilinx_gpio_platdata { +struct xilinx_gpio_plat { struct gpio_regs *regs; int bank_max[XILINX_GPIO_MAX_BANK]; int bank_input[XILINX_GPIO_MAX_BANK]; @@ -36,13 +36,13 @@ struct xilinx_gpio_privdata { static int xilinx_gpio_get_bank_pin(unsigned offset, u32 *bank_num, u32 *bank_pin_num, struct udevice *dev) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); u32 bank, max_pins; /* the first gpio is 0 not 1 */ u32 pin_num = offset; for (bank = 0; bank < XILINX_GPIO_MAX_BANK; bank++) { - max_pins = platdata->bank_max[bank]; + max_pins = plat->bank_max[bank]; if (pin_num < max_pins) { debug("%s: found at bank 0x%x pin 0x%x\n", __func__, bank, pin_num); @@ -59,7 +59,7 @@ static int xilinx_gpio_get_bank_pin(unsigned offset, u32 *bank_num, static int xilinx_gpio_set_value(struct udevice *dev, unsigned offset, int value) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); struct xilinx_gpio_privdata *priv = dev_get_priv(dev); int val, ret; u32 bank, pin; @@ -71,14 +71,14 @@ static int xilinx_gpio_set_value(struct udevice *dev, unsigned offset, val = priv->output_val[bank]; debug("%s: regs: %lx, value: %x, gpio: %x, bank %x, pin %x, out %x\n", - __func__, (ulong)platdata->regs, value, offset, bank, pin, val); + __func__, (ulong)plat->regs, value, offset, bank, pin, val); if (value) val = val | (1 << pin); else val = val & ~(1 << pin); - writel(val, &platdata->regs->gpiodata + bank * 2); + writel(val, &plat->regs->gpiodata + bank * 2); priv->output_val[bank] = val; @@ -87,7 +87,7 @@ static int xilinx_gpio_set_value(struct udevice *dev, unsigned offset, static int xilinx_gpio_get_value(struct udevice *dev, unsigned offset) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); struct xilinx_gpio_privdata *priv = dev_get_priv(dev); int val, ret; u32 bank, pin; @@ -97,14 +97,14 @@ static int xilinx_gpio_get_value(struct udevice *dev, unsigned offset) return ret; debug("%s: regs: %lx, gpio: %x, bank %x, pin %x\n", __func__, - (ulong)platdata->regs, offset, bank, pin); + (ulong)plat->regs, offset, bank, pin); - if (platdata->bank_output[bank]) { + if (plat->bank_output[bank]) { debug("%s: Read saved output value\n", __func__); val = priv->output_val[bank]; } else { debug("%s: Read input value from reg\n", __func__); - val = readl(&platdata->regs->gpiodata + bank * 2); + val = readl(&plat->regs->gpiodata + bank * 2); } val = !!(val & (1 << pin)); @@ -114,7 +114,7 @@ static int xilinx_gpio_get_value(struct udevice *dev, unsigned offset) static int xilinx_gpio_get_function(struct udevice *dev, unsigned offset) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); int val, ret; u32 bank, pin; @@ -123,15 +123,15 @@ static int xilinx_gpio_get_function(struct udevice *dev, unsigned offset) return ret; /* Check if all pins are inputs */ - if (platdata->bank_input[bank]) + if (plat->bank_input[bank]) return GPIOF_INPUT; /* Check if all pins are outputs */ - if (platdata->bank_output[bank]) + if (plat->bank_output[bank]) return GPIOF_OUTPUT; /* FIXME test on dual */ - val = readl(&platdata->regs->gpiodir + bank * 2); + val = readl(&plat->regs->gpiodir + bank * 2); val = !(val & (1 << pin)); /* input is 1 in reg but GPIOF_INPUT is 0 */ @@ -143,7 +143,7 @@ static int xilinx_gpio_get_function(struct udevice *dev, unsigned offset) static int xilinx_gpio_direction_output(struct udevice *dev, unsigned offset, int value) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); int val, ret; u32 bank, pin; @@ -152,15 +152,15 @@ static int xilinx_gpio_direction_output(struct udevice *dev, unsigned offset, return ret; /* can't change it if all is input by default */ - if (platdata->bank_input[bank]) + if (plat->bank_input[bank]) return -EINVAL; xilinx_gpio_set_value(dev, offset, value); - if (!platdata->bank_output[bank]) { - val = readl(&platdata->regs->gpiodir + bank * 2); + if (!plat->bank_output[bank]) { + val = readl(&plat->regs->gpiodir + bank * 2); val = val & ~(1 << pin); - writel(val, &platdata->regs->gpiodir + bank * 2); + writel(val, &plat->regs->gpiodir + bank * 2); } return 0; @@ -168,7 +168,7 @@ static int xilinx_gpio_direction_output(struct udevice *dev, unsigned offset, static int xilinx_gpio_direction_input(struct udevice *dev, unsigned offset) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); int val, ret; u32 bank, pin; @@ -177,16 +177,16 @@ static int xilinx_gpio_direction_input(struct udevice *dev, unsigned offset) return ret; /* Already input */ - if (platdata->bank_input[bank]) + if (plat->bank_input[bank]) return 0; /* can't change it if all is output by default */ - if (platdata->bank_output[bank]) + if (plat->bank_output[bank]) return -EINVAL; - val = readl(&platdata->regs->gpiodir + bank * 2); + val = readl(&plat->regs->gpiodir + bank * 2); val = val | (1 << pin); - writel(val, &platdata->regs->gpiodir + bank * 2); + writel(val, &plat->regs->gpiodir + bank * 2); return 0; } @@ -194,7 +194,7 @@ static int xilinx_gpio_direction_input(struct udevice *dev, unsigned offset) static int xilinx_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, struct ofnode_phandle_args *args) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); desc->offset = args->args[0]; @@ -209,13 +209,13 @@ static int xilinx_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, * add amount of pins in second channel if present. */ if (args->args[1]) { - if (!platdata->bank_max[1]) { + if (!plat->bank_max[1]) { printf("%s: %s has no second channel\n", __func__, dev->name); return -EINVAL; } - desc->offset += platdata->bank_max[0]; + desc->offset += plat->bank_max[0]; } /* The third cell is optional */ @@ -239,7 +239,7 @@ static const struct dm_gpio_ops xilinx_gpio_ops = { static int xilinx_gpio_probe(struct udevice *dev) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); struct xilinx_gpio_privdata *priv = dev_get_priv(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); const void *label_ptr; @@ -253,42 +253,38 @@ static int xilinx_gpio_probe(struct udevice *dev) uc_priv->bank_name = dev->name; } - uc_priv->gpio_count = platdata->bank_max[0] + platdata->bank_max[1]; + uc_priv->gpio_count = plat->bank_max[0] + plat->bank_max[1]; - priv->output_val[0] = platdata->dout_default[0]; + priv->output_val[0] = plat->dout_default[0]; - if (platdata->bank_max[1]) - priv->output_val[1] = platdata->dout_default[1]; + if (plat->bank_max[1]) + priv->output_val[1] = plat->dout_default[1]; return 0; } -static int xilinx_gpio_ofdata_to_platdata(struct udevice *dev) +static int xilinx_gpio_of_to_plat(struct udevice *dev) { - struct xilinx_gpio_platdata *platdata = dev_get_platdata(dev); + struct xilinx_gpio_plat *plat = dev_get_plat(dev); int is_dual; - platdata->regs = (struct gpio_regs *)dev_read_addr(dev); + plat->regs = (struct gpio_regs *)dev_read_addr(dev); - platdata->bank_max[0] = dev_read_u32_default(dev, - "xlnx,gpio-width", 0); - platdata->bank_input[0] = dev_read_u32_default(dev, - "xlnx,all-inputs", 0); - platdata->bank_output[0] = dev_read_u32_default(dev, - "xlnx,all-outputs", 0); - platdata->dout_default[0] = dev_read_u32_default(dev, - "xlnx,dout-default", - 0); + plat->bank_max[0] = dev_read_u32_default(dev, "xlnx,gpio-width", 0); + plat->bank_input[0] = dev_read_u32_default(dev, "xlnx,all-inputs", 0); + plat->bank_output[0] = dev_read_u32_default(dev, "xlnx,all-outputs", 0); + plat->dout_default[0] = dev_read_u32_default(dev, "xlnx,dout-default", + 0); is_dual = dev_read_u32_default(dev, "xlnx,is-dual", 0); if (is_dual) { - platdata->bank_max[1] = dev_read_u32_default(dev, - "xlnx,gpio2-width", 0); - platdata->bank_input[1] = dev_read_u32_default(dev, + plat->bank_max[1] = dev_read_u32_default(dev, + "xlnx,gpio2-width", 0); + plat->bank_input[1] = dev_read_u32_default(dev, "xlnx,all-inputs-2", 0); - platdata->bank_output[1] = dev_read_u32_default(dev, + plat->bank_output[1] = dev_read_u32_default(dev, "xlnx,all-outputs-2", 0); - platdata->dout_default[1] = dev_read_u32_default(dev, + plat->dout_default[1] = dev_read_u32_default(dev, "xlnx,dout-default-2", 0); } @@ -305,8 +301,8 @@ U_BOOT_DRIVER(xilinx_gpio) = { .id = UCLASS_GPIO, .ops = &xilinx_gpio_ops, .of_match = xilinx_gpio_ids, - .ofdata_to_platdata = xilinx_gpio_ofdata_to_platdata, + .of_to_plat = xilinx_gpio_of_to_plat, .probe = xilinx_gpio_probe, - .platdata_auto_alloc_size = sizeof(struct xilinx_gpio_platdata), - .priv_auto_alloc_size = sizeof(struct xilinx_gpio_privdata), + .plat_auto = sizeof(struct xilinx_gpio_plat), + .priv_auto = sizeof(struct xilinx_gpio_privdata), }; diff --git a/drivers/gpio/zynq_gpio.c b/drivers/gpio/zynq_gpio.c index d0e90b8d63..71a56127c0 100644 --- a/drivers/gpio/zynq_gpio.c +++ b/drivers/gpio/zynq_gpio.c @@ -97,7 +97,7 @@ #define PMC_GPIO_NR_GPIOS 116 #define PMC_GPIO_MAX_BANK 5 -struct zynq_gpio_platdata { +struct zynq_gpio_plat { phys_addr_t base; const struct zynq_platform_data *p_data; }; @@ -193,20 +193,20 @@ static inline void zynq_gpio_get_bank_pin(unsigned int pin_num, unsigned int *bank_pin_num, struct udevice *dev) { - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); u32 bank; - for (bank = 0; bank < platdata->p_data->max_bank; bank++) { - if (pin_num >= platdata->p_data->bank_min[bank] && - pin_num <= platdata->p_data->bank_max[bank]) { + for (bank = 0; bank < plat->p_data->max_bank; bank++) { + if (pin_num >= plat->p_data->bank_min[bank] && + pin_num <= plat->p_data->bank_max[bank]) { *bank_num = bank; *bank_pin_num = pin_num - - platdata->p_data->bank_min[bank]; + plat->p_data->bank_min[bank]; return; } } - if (bank >= platdata->p_data->max_bank) { + if (bank >= plat->p_data->max_bank) { printf("Invalid bank and pin num\n"); *bank_num = 0; *bank_pin_num = 0; @@ -215,9 +215,9 @@ static inline void zynq_gpio_get_bank_pin(unsigned int pin_num, static int gpio_is_valid(unsigned gpio, struct udevice *dev) { - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); - return gpio < platdata->p_data->ngpio; + return gpio < plat->p_data->ngpio; } static int check_gpio(unsigned gpio, struct udevice *dev) @@ -233,14 +233,14 @@ static int zynq_gpio_get_value(struct udevice *dev, unsigned gpio) { u32 data; unsigned int bank_num, bank_pin_num; - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); if (check_gpio(gpio, dev) < 0) return -1; zynq_gpio_get_bank_pin(gpio, &bank_num, &bank_pin_num, dev); - data = readl(platdata->base + + data = readl(plat->base + ZYNQ_GPIO_DATA_RO_OFFSET(bank_num)); return (data >> bank_pin_num) & 1; @@ -249,7 +249,7 @@ static int zynq_gpio_get_value(struct udevice *dev, unsigned gpio) static int zynq_gpio_set_value(struct udevice *dev, unsigned gpio, int value) { unsigned int reg_offset, bank_num, bank_pin_num; - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); if (check_gpio(gpio, dev) < 0) return -1; @@ -272,7 +272,7 @@ static int zynq_gpio_set_value(struct udevice *dev, unsigned gpio, int value) value = ~(1 << (bank_pin_num + ZYNQ_GPIO_MID_PIN_NUM)) & ((value << bank_pin_num) | ZYNQ_GPIO_UPPER_MASK); - writel(value, platdata->base + reg_offset); + writel(value, plat->base + reg_offset); return 0; } @@ -281,7 +281,7 @@ static int zynq_gpio_direction_input(struct udevice *dev, unsigned gpio) { u32 reg; unsigned int bank_num, bank_pin_num; - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); if (check_gpio(gpio, dev) < 0) return -1; @@ -293,9 +293,9 @@ static int zynq_gpio_direction_input(struct udevice *dev, unsigned gpio) return -1; /* clear the bit in direction mode reg to set the pin as input */ - reg = readl(platdata->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); + reg = readl(plat->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); reg &= ~BIT(bank_pin_num); - writel(reg, platdata->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); + writel(reg, plat->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); return 0; } @@ -305,7 +305,7 @@ static int zynq_gpio_direction_output(struct udevice *dev, unsigned gpio, { u32 reg; unsigned int bank_num, bank_pin_num; - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); if (check_gpio(gpio, dev) < 0) return -1; @@ -313,14 +313,14 @@ static int zynq_gpio_direction_output(struct udevice *dev, unsigned gpio, zynq_gpio_get_bank_pin(gpio, &bank_num, &bank_pin_num, dev); /* set the GPIO pin as output */ - reg = readl(platdata->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); + reg = readl(plat->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); reg |= BIT(bank_pin_num); - writel(reg, platdata->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); + writel(reg, plat->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); /* configure the output enable reg for the pin */ - reg = readl(platdata->base + ZYNQ_GPIO_OUTEN_OFFSET(bank_num)); + reg = readl(plat->base + ZYNQ_GPIO_OUTEN_OFFSET(bank_num)); reg |= BIT(bank_pin_num); - writel(reg, platdata->base + ZYNQ_GPIO_OUTEN_OFFSET(bank_num)); + writel(reg, plat->base + ZYNQ_GPIO_OUTEN_OFFSET(bank_num)); /* set the state of the pin */ zynq_gpio_set_value(dev, gpio, value); @@ -331,7 +331,7 @@ static int zynq_gpio_get_function(struct udevice *dev, unsigned offset) { u32 reg; unsigned int bank_num, bank_pin_num; - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); if (check_gpio(offset, dev) < 0) return -1; @@ -339,7 +339,7 @@ static int zynq_gpio_get_function(struct udevice *dev, unsigned offset) zynq_gpio_get_bank_pin(offset, &bank_num, &bank_pin_num, dev); /* set the GPIO pin as output */ - reg = readl(platdata->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); + reg = readl(plat->base + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); reg &= BIT(bank_pin_num); if (reg) return GPIOF_OUTPUT; @@ -369,7 +369,7 @@ static const struct udevice_id zynq_gpio_ids[] = { static int zynq_gpio_probe(struct udevice *dev) { - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); const void *label_ptr; @@ -382,19 +382,19 @@ static int zynq_gpio_probe(struct udevice *dev) uc_priv->bank_name = dev->name; } - if (platdata->p_data) - uc_priv->gpio_count = platdata->p_data->ngpio; + if (plat->p_data) + uc_priv->gpio_count = plat->p_data->ngpio; return 0; } -static int zynq_gpio_ofdata_to_platdata(struct udevice *dev) +static int zynq_gpio_of_to_plat(struct udevice *dev) { - struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); + struct zynq_gpio_plat *plat = dev_get_plat(dev); - platdata->base = (phys_addr_t)dev_read_addr(dev); + plat->base = (phys_addr_t)dev_read_addr(dev); - platdata->p_data = + plat->p_data = (struct zynq_platform_data *)dev_get_driver_data(dev); return 0; @@ -405,7 +405,7 @@ U_BOOT_DRIVER(gpio_zynq) = { .id = UCLASS_GPIO, .ops = &gpio_zynq_ops, .of_match = zynq_gpio_ids, - .ofdata_to_platdata = zynq_gpio_ofdata_to_platdata, + .of_to_plat = zynq_gpio_of_to_plat, .probe = zynq_gpio_probe, - .platdata_auto_alloc_size = sizeof(struct zynq_gpio_platdata), + .plat_auto = sizeof(struct zynq_gpio_plat), }; diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c index 8be585a0c8..fdc1f6fd53 100644 --- a/drivers/hwspinlock/stm32_hwspinlock.c +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -90,5 +90,5 @@ U_BOOT_DRIVER(hwspinlock_stm32mp1) = { .of_match = stm32mp1_hwspinlock_ids, .ops = &stm32mp1_hwspinlock_ops, .probe = stm32mp1_hwspinlock_probe, - .priv_auto_alloc_size = sizeof(struct stm32mp1_hws_priv), + .priv_auto = sizeof(struct stm32mp1_hws_priv), }; diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 37958083af..403602fddf 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -11,7 +11,7 @@ config DM_I2C Enable driver model for I2C. The I2C uclass interface: probe, read, write and speed, is implemented with the bus drivers operations, which provide methods for bus setting and data transfer. Each chip - device (bus child) info is kept as parent platdata. The interface + device (bus child) info is kept as parent plat. The interface is defined in include/i2c.h. config I2C_CROS_EC_TUNNEL diff --git a/drivers/i2c/acpi_i2c.c b/drivers/i2c/acpi_i2c.c index 57d29683cb..142f41178c 100644 --- a/drivers/i2c/acpi_i2c.c +++ b/drivers/i2c/acpi_i2c.c @@ -174,7 +174,7 @@ int acpi_i2c_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) return 0; } -int acpi_i2c_ofdata_to_platdata(struct udevice *dev) +int acpi_i2c_of_to_plat(struct udevice *dev) { struct acpi_i2c_priv *priv = dev_get_priv(dev); @@ -210,7 +210,7 @@ int acpi_i2c_ofdata_to_platdata(struct udevice *dev) /* Use name specified in priv or build one from I2C address */ static int acpi_i2c_get_name(const struct udevice *dev, char *out_name) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct acpi_i2c_priv *priv = dev_get_priv(dev); snprintf(out_name, ACPI_NAME_MAX, diff --git a/drivers/i2c/acpi_i2c.h b/drivers/i2c/acpi_i2c.h index 1f4be29601..fc6616ade6 100644 --- a/drivers/i2c/acpi_i2c.h +++ b/drivers/i2c/acpi_i2c.h @@ -10,6 +10,6 @@ extern struct acpi_ops acpi_i2c_ops; -int acpi_i2c_ofdata_to_platdata(struct udevice *dev); +int acpi_i2c_of_to_plat(struct udevice *dev); #endif diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c index 2cdfb5561b..2d3fecaa14 100644 --- a/drivers/i2c/ast_i2c.c +++ b/drivers/i2c/ast_i2c.c @@ -87,7 +87,7 @@ static void ast_i2c_init_bus(struct udevice *dev) | I2CD_INTR_ABNORMAL, &priv->regs->icr); } -static int ast_i2c_ofdata_to_platdata(struct udevice *dev) +static int ast_i2c_of_to_plat(struct udevice *dev) { struct ast_i2c_priv *priv = dev_get_priv(dev); int ret; @@ -110,7 +110,7 @@ static int ast_i2c_probe(struct udevice *dev) { struct ast2500_scu *scu; - debug("Enabling I2C%u\n", dev->seq); + debug("Enabling I2C%u\n", dev_seq(dev)); /* * Get all I2C devices out of Reset. @@ -307,7 +307,7 @@ static int ast_i2c_set_speed(struct udevice *dev, unsigned int speed) struct ast_i2c_regs *regs = priv->regs; ulong i2c_rate, divider; - debug("Setting speed for I2C%d to <%u>\n", dev->seq, speed); + debug("Setting speed for I2C%d to <%u>\n", dev_seq(dev), speed); if (!speed) { debug("No valid speed specified\n"); return -EINVAL; @@ -351,7 +351,7 @@ U_BOOT_DRIVER(ast_i2c) = { .id = UCLASS_I2C, .of_match = ast_i2c_ids, .probe = ast_i2c_probe, - .ofdata_to_platdata = ast_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct ast_i2c_priv), + .of_to_plat = ast_i2c_of_to_plat, + .priv_auto = sizeof(struct ast_i2c_priv), .ops = &ast_i2c_ops, }; diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c index 9d6c6d80e2..3eb6db4878 100644 --- a/drivers/i2c/at91_i2c.c +++ b/drivers/i2c/at91_i2c.c @@ -219,7 +219,7 @@ int at91_i2c_get_bus_speed(struct udevice *dev) return bus->speed; } -static int at91_i2c_ofdata_to_platdata(struct udevice *dev) +static int at91_i2c_of_to_plat(struct udevice *dev) { const void *blob = gd->fdt_blob; struct at91_i2c_bus *bus = dev_get_priv(dev); @@ -317,8 +317,8 @@ U_BOOT_DRIVER(i2c_at91) = { .id = UCLASS_I2C, .of_match = at91_i2c_ids, .probe = at91_i2c_probe, - .ofdata_to_platdata = at91_i2c_ofdata_to_platdata, - .per_child_auto_alloc_size = sizeof(struct dm_i2c_chip), - .priv_auto_alloc_size = sizeof(struct at91_i2c_bus), + .of_to_plat = at91_i2c_of_to_plat, + .per_child_auto = sizeof(struct dm_i2c_chip), + .priv_auto = sizeof(struct at91_i2c_bus), .ops = &at91_i2c_ops, }; diff --git a/drivers/i2c/cros_ec_tunnel.c b/drivers/i2c/cros_ec_tunnel.c index a630817352..970b91cfd3 100644 --- a/drivers/i2c/cros_ec_tunnel.c +++ b/drivers/i2c/cros_ec_tunnel.c @@ -29,7 +29,7 @@ static int cros_ec_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, return cros_ec_i2c_tunnel(dev->parent, i2c_bus->remote_bus, msg, nmsgs); } -static int cros_ec_i2c_ofdata_to_platdata(struct udevice *dev) +static int cros_ec_i2c_of_to_plat(struct udevice *dev) { struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev); const void *blob = gd->fdt_blob; @@ -55,7 +55,7 @@ U_BOOT_DRIVER(cros_ec_tunnel) = { .name = "cros_ec_tunnel", .id = UCLASS_I2C, .of_match = cros_ec_i2c_ids, - .ofdata_to_platdata = cros_ec_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct cros_ec_i2c_bus), + .of_to_plat = cros_ec_i2c_of_to_plat, + .priv_auto = sizeof(struct cros_ec_i2c_bus), .ops = &cros_ec_i2c_ops, }; diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c index a54f2151fd..7811abad80 100644 --- a/drivers/i2c/davinci_i2c.c +++ b/drivers/i2c/davinci_i2c.c @@ -470,7 +470,7 @@ static int davinci_i2c_probe(struct udevice *dev) { struct i2c_bus *i2c_bus = dev_get_priv(dev); - i2c_bus->id = dev->seq; + i2c_bus->id = dev_seq(dev); i2c_bus->regs = dev_read_addr_ptr(dev); i2c_bus->speed = 100000; @@ -504,7 +504,7 @@ U_BOOT_DRIVER(i2c_davinci) = { .id = UCLASS_I2C, .of_match = davinci_i2c_ids, .probe = davinci_i2c_probe, - .priv_auto_alloc_size = sizeof(struct i2c_bus), + .priv_auto = sizeof(struct i2c_bus), .ops = &davinci_i2c_ops, }; diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index c54989504e..60111b8419 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -762,7 +762,7 @@ static int designware_i2c_probe_chip(struct udevice *bus, uint chip_addr, return ret; } -int designware_i2c_ofdata_to_platdata(struct udevice *bus) +int designware_i2c_of_to_plat(struct udevice *bus) { struct dw_i2c *priv = dev_get_priv(bus); int ret; @@ -842,9 +842,9 @@ U_BOOT_DRIVER(i2c_designware) = { .name = "i2c_designware", .id = UCLASS_I2C, .of_match = designware_i2c_ids, - .ofdata_to_platdata = designware_i2c_ofdata_to_platdata, + .of_to_plat = designware_i2c_of_to_plat, .probe = designware_i2c_probe, - .priv_auto_alloc_size = sizeof(struct dw_i2c), + .priv_auto = sizeof(struct dw_i2c), .remove = designware_i2c_remove, .flags = DM_FLAG_OS_PREPARE, .ops = &designware_i2c_ops, diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h index 18acf4e841..9b2349a0a2 100644 --- a/drivers/i2c/designware_i2c.h +++ b/drivers/i2c/designware_i2c.h @@ -212,7 +212,7 @@ extern const struct dm_i2c_ops designware_i2c_ops; int designware_i2c_probe(struct udevice *bus); int designware_i2c_remove(struct udevice *dev); -int designware_i2c_ofdata_to_platdata(struct udevice *bus); +int designware_i2c_of_to_plat(struct udevice *bus); /** * dw_i2c_gen_speed_config() - Calculate config info from requested speed diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c index d0d869c81a..ec0cdf6220 100644 --- a/drivers/i2c/designware_i2c_pci.c +++ b/drivers/i2c/designware_i2c_pci.c @@ -34,7 +34,7 @@ static struct dw_scl_sda_cfg byt_config = { /* Have a weak function for now - possibly should be a new uclass */ __weak void lpss_reset_release(void *regs); -static int designware_i2c_pci_ofdata_to_platdata(struct udevice *dev) +static int designware_i2c_pci_of_to_plat(struct udevice *dev) { struct dw_i2c *priv = dev_get_priv(dev); @@ -71,7 +71,7 @@ static int designware_i2c_pci_ofdata_to_platdata(struct udevice *dev) if (dev_get_driver_data(dev) == INTEL_APL) priv->has_spk_cnt = true; - return designware_i2c_ofdata_to_platdata(dev); + return designware_i2c_of_to_plat(dev); } static int designware_i2c_pci_probe(struct udevice *dev) @@ -92,24 +92,10 @@ static int designware_i2c_pci_bind(struct udevice *dev) { char name[20]; - if (dev_of_valid(dev)) + if (dev_has_ofnode(dev)) return 0; - /* - * Create a unique device name for PCI type devices - * ToDo: - * Setting req_seq in the driver is probably not recommended. - * But without a DT alias the number is not configured. And - * using this driver is impossible for PCIe I2C devices. - * This can be removed, once a better (correct) way for this - * is found and implemented. - * - * TODO(sjg@chromium.org): Perhaps if uclasses had platdata this would - * be possible. We cannot use static data in drivers since they may be - * used in SPL or before relocation. - */ - dev->req_seq = uclass_find_next_free_req_seq(UCLASS_I2C); - sprintf(name, "i2c_designware#%u", dev->req_seq); + sprintf(name, "i2c_designware#%u", dev_seq(dev)); device_set_name(dev, name); return 0; @@ -166,7 +152,7 @@ static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev, int ret; /* If no device-tree node, ignore this since we assume it isn't used */ - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; ret = acpi_device_path(dev, path, sizeof(path)); @@ -211,9 +197,9 @@ U_BOOT_DRIVER(i2c_designware_pci) = { .id = UCLASS_I2C, .of_match = designware_i2c_pci_ids, .bind = designware_i2c_pci_bind, - .ofdata_to_platdata = designware_i2c_pci_ofdata_to_platdata, + .of_to_plat = designware_i2c_pci_of_to_plat, .probe = designware_i2c_pci_probe, - .priv_auto_alloc_size = sizeof(struct dw_i2c), + .priv_auto = sizeof(struct dw_i2c), .remove = designware_i2c_remove, .flags = DM_FLAG_OS_PREPARE, .ops = &designware_i2c_ops, diff --git a/drivers/i2c/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c index 5785adedb6..879ddc67b6 100644 --- a/drivers/i2c/exynos_hs_i2c.c +++ b/drivers/i2c/exynos_hs_i2c.c @@ -517,7 +517,7 @@ static int s3c24x0_i2c_probe(struct udevice *dev, uint chip, uint chip_flags) return ret != I2C_OK; } -static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) +static int s3c_i2c_of_to_plat(struct udevice *dev) { const void *blob = gd->fdt_blob; struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev); @@ -533,7 +533,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) dev_read_u32_default(dev, "clock-frequency", I2C_SPEED_STANDARD_RATE); i2c_bus->node = node; - i2c_bus->bus_num = dev->seq; + i2c_bus->bus_num = dev_seq(dev); exynos_pinmux_config(i2c_bus->id, PINMUX_FLAG_HS_MODE); @@ -557,7 +557,7 @@ U_BOOT_DRIVER(hs_i2c) = { .name = "i2c_s3c_hs", .id = UCLASS_I2C, .of_match = exynos_hs_i2c_ids, - .ofdata_to_platdata = s3c_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct s3c24x0_i2c_bus), + .of_to_plat = s3c_i2c_of_to_plat, + .priv_auto = sizeof(struct s3c24x0_i2c_bus), .ops = &exynos_hs_i2c_ops, }; diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c index da933452f5..875d30762e 100644 --- a/drivers/i2c/fsl_i2c.c +++ b/drivers/i2c/fsl_i2c.c @@ -573,7 +573,7 @@ static int fsl_i2c_set_bus_speed(struct udevice *bus, uint speed) return __i2c_set_bus_speed(dev->base, speed, dev->i2c_clk); } -static int fsl_i2c_ofdata_to_platdata(struct udevice *bus) +static int fsl_i2c_of_to_plat(struct udevice *bus) { struct fsl_i2c_dev *dev = dev_get_priv(bus); struct clk clock; @@ -649,8 +649,8 @@ U_BOOT_DRIVER(i2c_fsl) = { .id = UCLASS_I2C, .of_match = fsl_i2c_ids, .probe = fsl_i2c_probe, - .ofdata_to_platdata = fsl_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct fsl_i2c_dev), + .of_to_plat = fsl_i2c_of_to_plat, + .priv_auto = sizeof(struct fsl_i2c_dev), .ops = &fsl_i2c_ops, }; diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c index 7144d39984..db3c04fa6e 100644 --- a/drivers/i2c/i2c-cdns.c +++ b/drivers/i2c/i2c-cdns.c @@ -460,7 +460,7 @@ static int cdns_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, return ret; } -static int cdns_i2c_ofdata_to_platdata(struct udevice *dev) +static int cdns_i2c_of_to_plat(struct udevice *dev) { struct i2c_cdns_bus *i2c_bus = dev_get_priv(dev); struct cdns_i2c_platform_data *pdata = @@ -503,7 +503,7 @@ U_BOOT_DRIVER(cdns_i2c) = { .name = "i2c_cdns", .id = UCLASS_I2C, .of_match = cdns_i2c_of_match, - .ofdata_to_platdata = cdns_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct i2c_cdns_bus), + .of_to_plat = cdns_i2c_of_to_plat, + .priv_auto = sizeof(struct i2c_cdns_bus), .ops = &cdns_i2c_ops, }; diff --git a/drivers/i2c/i2c-cortina.c b/drivers/i2c/i2c-cortina.c index 036fc4282b..960ae8c700 100644 --- a/drivers/i2c/i2c-cortina.c +++ b/drivers/i2c/i2c-cortina.c @@ -322,7 +322,7 @@ static int ca_i2c_probe(struct udevice *bus) return 0; } -static int ca_i2c_ofdata_to_platdata(struct udevice *bus) +static int ca_i2c_of_to_plat(struct udevice *bus) { struct ca_i2c *priv = dev_get_priv(bus); @@ -339,9 +339,9 @@ U_BOOT_DRIVER(i2c_cortina) = { .name = "i2c_cortina", .id = UCLASS_I2C, .of_match = ca_i2c_ids, - .ofdata_to_platdata = ca_i2c_ofdata_to_platdata, + .of_to_plat = ca_i2c_of_to_plat, .probe = ca_i2c_probe, - .priv_auto_alloc_size = sizeof(struct ca_i2c), + .priv_auto = sizeof(struct ca_i2c), .ops = &ca_i2c_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/i2c/i2c-emul-uclass.c b/drivers/i2c/i2c-emul-uclass.c index 84b6a219d1..085b824e89 100644 --- a/drivers/i2c/i2c-emul-uclass.c +++ b/drivers/i2c/i2c-emul-uclass.c @@ -14,7 +14,7 @@ * i2c emulation works using an 'emul' node at the bus level. Each device in * that node is in the UCLASS_I2C_EMUL uclass, and emulates one i2c device. A * pointer to the device it emulates is in the 'dev' property of the emul device - * uclass platdata (struct i2c_emul_platdata), put there by i2c_emul_find(). + * uclass plat (struct i2c_emul_plat), put there by i2c_emul_find(). * When sandbox wants an emulator for a device, it calls i2c_emul_find() which * searches for the emulator with the correct address. To find the device for an * emulator, call i2c_emul_get_device(). @@ -24,27 +24,27 @@ */ /** - * struct i2c_emul_uc_platdata - information about the emulator for this device + * struct i2c_emul_uc_plat - information about the emulator for this device * * This is used by devices in UCLASS_I2C_EMUL to record information about the - * device being emulated. It is accessible with dev_get_uclass_platdata() + * device being emulated. It is accessible with dev_get_uclass_plat() * * @dev: Device being emulated */ -struct i2c_emul_uc_platdata { +struct i2c_emul_uc_plat { struct udevice *dev; }; struct udevice *i2c_emul_get_device(struct udevice *emul) { - struct i2c_emul_uc_platdata *uc_plat = dev_get_uclass_platdata(emul); + struct i2c_emul_uc_plat *uc_plat = dev_get_uclass_plat(emul); return uc_plat->dev; } int i2c_emul_find(struct udevice *dev, struct udevice **emulp) { - struct i2c_emul_uc_platdata *uc_plat; + struct i2c_emul_uc_plat *uc_plat; struct udevice *emul; int ret; @@ -54,7 +54,7 @@ int i2c_emul_find(struct udevice *dev, struct udevice **emulp) log_err("No emulators for device '%s'\n", dev->name); return ret; } - uc_plat = dev_get_uclass_platdata(emul); + uc_plat = dev_get_uclass_plat(emul); uc_plat->dev = dev; *emulp = emul; @@ -64,14 +64,13 @@ int i2c_emul_find(struct udevice *dev, struct udevice **emulp) UCLASS_DRIVER(i2c_emul) = { .id = UCLASS_I2C_EMUL, .name = "i2c_emul", - .per_device_platdata_auto_alloc_size = - sizeof(struct i2c_emul_uc_platdata), + .per_device_plat_auto = sizeof(struct i2c_emul_uc_plat), }; /* - * This uclass is a child of the i2c bus. Its platdata is not defined here so + * This uclass is a child of the i2c bus. Its plat is not defined here so * is defined by its parent, UCLASS_I2C, which uses struct dm_i2c_chip. See - * per_child_platdata_auto_alloc_size in UCLASS_DRIVER(i2c). + * per_child_plat_auto in UCLASS_DRIVER(i2c). */ UCLASS_DRIVER(i2c_emul_parent) = { .id = UCLASS_I2C_EMUL_PARENT, diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c index 381938c956..387f00b2cd 100644 --- a/drivers/i2c/i2c-gpio.c +++ b/drivers/i2c/i2c-gpio.c @@ -298,7 +298,7 @@ static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags) i2c_gpio_send_stop(bus, delay); debug("%s: bus: %d (%s) chip: %x flags: %x ret: %d\n", - __func__, dev->seq, dev->name, chip, chip_flags, ret); + __func__, dev_seq(dev), dev->name, chip, chip_flags, ret); return ret; } @@ -329,7 +329,7 @@ static int i2c_gpio_drv_probe(struct udevice *dev) return 0; } -static int i2c_gpio_ofdata_to_platdata(struct udevice *dev) +static int i2c_gpio_of_to_plat(struct udevice *dev) { struct i2c_gpio_bus *bus = dev_get_priv(dev); int ret; @@ -371,7 +371,7 @@ U_BOOT_DRIVER(i2c_gpio) = { .id = UCLASS_I2C, .of_match = i2c_gpio_ids, .probe = i2c_gpio_drv_probe, - .ofdata_to_platdata = i2c_gpio_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct i2c_gpio_bus), + .of_to_plat = i2c_gpio_of_to_plat, + .priv_auto = sizeof(struct i2c_gpio_bus), .ops = &i2c_gpio_ops, }; diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 5c4626b044..be56785217 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -79,7 +79,7 @@ static int i2c_setup_offset(struct dm_i2c_chip *chip, uint offset, static int i2c_read_bytewise(struct udevice *dev, uint offset, uint8_t *buffer, int len) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct udevice *bus = dev_get_parent(dev); struct dm_i2c_ops *ops = i2c_get_ops(bus); struct i2c_msg msg[2], *ptr; @@ -108,7 +108,7 @@ static int i2c_read_bytewise(struct udevice *dev, uint offset, static int i2c_write_bytewise(struct udevice *dev, uint offset, const uint8_t *buffer, int len) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct udevice *bus = dev_get_parent(dev); struct dm_i2c_ops *ops = i2c_get_ops(bus); struct i2c_msg msg[1]; @@ -131,7 +131,7 @@ static int i2c_write_bytewise(struct udevice *dev, uint offset, int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct udevice *bus = dev_get_parent(dev); struct dm_i2c_ops *ops = i2c_get_ops(bus); struct i2c_msg msg[2], *ptr; @@ -162,7 +162,7 @@ int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len) int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, int len) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct udevice *bus = dev_get_parent(dev); struct dm_i2c_ops *ops = i2c_get_ops(bus); struct i2c_msg msg[1]; @@ -297,7 +297,7 @@ static int i2c_bind_driver(struct udevice *bus, uint chip_addr, uint offset_len, goto err_bind; /* Tell the device what we know about it */ - chip = dev_get_parent_platdata(dev); + chip = dev_get_parent_plat(dev); chip->chip_addr = chip_addr; chip->offset_len = offset_len; ret = device_probe(dev); @@ -328,7 +328,7 @@ int i2c_get_chip(struct udevice *bus, uint chip_addr, uint offset_len, bus->name, chip_addr); for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); int ret; if (chip->chip_addr == (chip_addr & @@ -433,7 +433,7 @@ int dm_i2c_get_bus_speed(struct udevice *bus) int i2c_set_chip_flags(struct udevice *dev, uint flags) { struct udevice *bus = dev->parent; - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct dm_i2c_ops *ops = i2c_get_ops(bus); int ret; @@ -449,7 +449,7 @@ int i2c_set_chip_flags(struct udevice *dev, uint flags) int i2c_get_chip_flags(struct udevice *dev, uint *flagsp) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); *flagsp = chip->flags; @@ -458,7 +458,7 @@ int i2c_get_chip_flags(struct udevice *dev, uint *flagsp) int i2c_set_chip_offset_len(struct udevice *dev, uint offset_len) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); if (offset_len > I2C_MAX_OFFSET_LEN) return log_ret(-EINVAL); @@ -469,14 +469,14 @@ int i2c_set_chip_offset_len(struct udevice *dev, uint offset_len) int i2c_get_chip_offset_len(struct udevice *dev) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); return chip->offset_len; } int i2c_set_chip_addr_offset_mask(struct udevice *dev, uint mask) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); chip->chip_addr_offset_mask = mask; @@ -485,7 +485,7 @@ int i2c_set_chip_addr_offset_mask(struct udevice *dev, uint mask) uint i2c_get_chip_addr_offset_mask(struct udevice *dev) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); return chip->chip_addr_offset_mask; } @@ -617,7 +617,7 @@ int i2c_deblock(struct udevice *bus) } #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip) +int i2c_chip_of_to_plat(struct udevice *dev, struct dm_i2c_chip *chip) { int addr; @@ -676,37 +676,21 @@ static int i2c_post_probe(struct udevice *dev) static int i2c_child_post_bind(struct udevice *dev) { #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) - struct dm_i2c_chip *plat = dev_get_parent_platdata(dev); + struct dm_i2c_chip *plat = dev_get_parent_plat(dev); - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; - return i2c_chip_ofdata_to_platdata(dev, plat); + return i2c_chip_of_to_plat(dev, plat); #else return 0; #endif } -struct i2c_priv { - int max_id; -}; - static int i2c_post_bind(struct udevice *dev) { - struct uclass *class = dev->uclass; - struct i2c_priv *priv = class->priv; int ret = 0; - /* Just for sure */ - if (!priv) - return -ENOMEM; - - debug("%s: %s, req_seq=%d\n", __func__, dev->name, dev->req_seq); - - /* if there is no alias ID, use the first free */ - if (dev->req_seq == -1) - dev->req_seq = ++priv->max_id; - - debug("%s: %s, new req_seq=%d\n", __func__, dev->name, dev->req_seq); + debug("%s: %s, seq=%d\n", __func__, dev->name, dev_seq(dev)); #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) ret = dm_scan_fdt_dev(dev); @@ -714,36 +698,15 @@ static int i2c_post_bind(struct udevice *dev) return ret; } -int i2c_uclass_init(struct uclass *class) -{ - struct i2c_priv *priv = class->priv; - - /* Just for sure */ - if (!priv) - return -ENOMEM; - - /* Get the last allocated alias. */ - if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) - priv->max_id = dev_read_alias_highest_id("i2c"); - else - priv->max_id = -1; - - debug("%s: highest alias id is %d\n", __func__, priv->max_id); - - return 0; -} - UCLASS_DRIVER(i2c) = { .id = UCLASS_I2C, .name = "i2c", .flags = DM_UC_FLAG_SEQ_ALIAS, .post_bind = i2c_post_bind, - .init = i2c_uclass_init, - .priv_auto_alloc_size = sizeof(struct i2c_priv), .pre_probe = i2c_pre_probe, .post_probe = i2c_post_probe, - .per_device_auto_alloc_size = sizeof(struct dm_i2c_bus), - .per_child_platdata_auto_alloc_size = sizeof(struct dm_i2c_chip), + .per_device_auto = sizeof(struct dm_i2c_bus), + .per_child_plat_auto = sizeof(struct dm_i2c_chip), .child_post_bind = i2c_child_post_bind, }; @@ -765,8 +728,8 @@ U_BOOT_DRIVER(i2c_generic_chip_drv) = { .id = UCLASS_I2C_GENERIC, .of_match = generic_chip_i2c_ids, #if CONFIG_IS_ENABLED(ACPIGEN) - .ofdata_to_platdata = acpi_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct acpi_i2c_priv), + .of_to_plat = acpi_i2c_of_to_plat, + .priv_auto = sizeof(struct acpi_i2c_priv), #endif ACPI_OPS_PTR(&acpi_i2c_ops) }; diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c index a110fe9e8d..9d6f1688cb 100644 --- a/drivers/i2c/i2c-uniphier-f.c +++ b/drivers/i2c/i2c-uniphier-f.c @@ -326,6 +326,6 @@ U_BOOT_DRIVER(uniphier_fi2c) = { .id = UCLASS_I2C, .of_match = uniphier_fi2c_of_match, .probe = uniphier_fi2c_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_fi2c_priv), + .priv_auto = sizeof(struct uniphier_fi2c_priv), .ops = &uniphier_fi2c_ops, }; diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c index e7f44e14e9..6eafbeeef4 100644 --- a/drivers/i2c/i2c-uniphier.c +++ b/drivers/i2c/i2c-uniphier.c @@ -214,6 +214,6 @@ U_BOOT_DRIVER(uniphier_i2c) = { .id = UCLASS_I2C, .of_match = uniphier_i2c_of_match, .probe = uniphier_i2c_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_i2c_priv), + .priv_auto = sizeof(struct uniphier_i2c_priv), .ops = &uniphier_i2c_ops, }; diff --git a/drivers/i2c/i2c-versatile.c b/drivers/i2c/i2c-versatile.c index 62831522bd..0a1a85dfc2 100644 --- a/drivers/i2c/i2c-versatile.c +++ b/drivers/i2c/i2c-versatile.c @@ -252,11 +252,6 @@ static int versatile_i2c_probe(struct udevice *dev) priv->base = (phys_addr_t)dev_read_addr(dev); priv->delay = 25; /* 25us * 4 = 100kHz */ - /* - * U-Boot still doesn't assign automatically - * sequence numbers to devices - */ - dev->req_seq = 1; return 0; } @@ -277,6 +272,6 @@ U_BOOT_DRIVER(versatile_i2c) = { .id = UCLASS_I2C, .of_match = versatile_i2c_of_match, .probe = versatile_i2c_probe, - .priv_auto_alloc_size = sizeof(struct versatile_i2c_priv), + .priv_auto = sizeof(struct versatile_i2c_priv), .ops = &versatile_i2c_ops, }; diff --git a/drivers/i2c/ihs_i2c.c b/drivers/i2c/ihs_i2c.c index cec38538da..f91a96a3aa 100644 --- a/drivers/i2c/ihs_i2c.c +++ b/drivers/i2c/ihs_i2c.c @@ -354,7 +354,7 @@ U_BOOT_DRIVER(i2c_ihs) = { .id = UCLASS_I2C, .of_match = ihs_i2c_ids, .probe = ihs_i2c_probe, - .priv_auto_alloc_size = sizeof(struct ihs_i2c_priv), + .priv_auto = sizeof(struct ihs_i2c_priv), .ops = &ihs_i2c_ops, }; diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c index feeed1e9a2..92c500327b 100644 --- a/drivers/i2c/imx_lpi2c.c +++ b/drivers/i2c/imx_lpi2c.c @@ -289,7 +289,7 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed) return clock_rate; } } else { - clock_rate = imx_get_i2cclk(bus->seq); + clock_rate = imx_get_i2cclk(dev_seq(bus)); if (!clock_rate) return -EPERM; } @@ -377,7 +377,7 @@ static int bus_i2c_init(struct udevice *bus, int speed) val = readl(®s->mcr) & ~LPI2C_MCR_MEN_MASK; writel(val | LPI2C_MCR_MEN(1), ®s->mcr); - debug("i2c : controller bus %d, speed %d:\n", bus->seq, speed); + debug("i2c : controller bus %d, speed %d:\n", dev_seq(bus), speed); return ret; } @@ -452,11 +452,11 @@ static int imx_lpi2c_probe(struct udevice *bus) return -EINVAL; i2c_bus->base = addr; - i2c_bus->index = bus->seq; + i2c_bus->index = dev_seq(bus); i2c_bus->bus = bus; /* power up i2c resource */ - ret = init_i2c_power(bus->seq); + ret = init_i2c_power(dev_seq(bus)); if (ret) { debug("init_i2c_power err = %d\n", ret); return ret; @@ -486,7 +486,7 @@ static int imx_lpi2c_probe(struct udevice *bus) } } else { /* To i.MX7ULP, only i2c4-7 can be handled by A7 core */ - ret = enable_i2c_clk(1, bus->seq); + ret = enable_i2c_clk(1, dev_seq(bus)); if (ret < 0) return ret; } @@ -496,7 +496,7 @@ static int imx_lpi2c_probe(struct udevice *bus) return ret; debug("i2c : controller bus %d at 0x%lx , speed %d: ", - bus->seq, i2c_bus->base, + dev_seq(bus), i2c_bus->base, i2c_bus->speed); return 0; @@ -519,6 +519,6 @@ U_BOOT_DRIVER(imx_lpi2c) = { .id = UCLASS_I2C, .of_match = imx_lpi2c_ids, .probe = imx_lpi2c_probe, - .priv_auto_alloc_size = sizeof(struct imx_lpi2c_bus), + .priv_auto = sizeof(struct imx_lpi2c_bus), .ops = &imx_lpi2c_ops, }; diff --git a/drivers/i2c/intel_i2c.c b/drivers/i2c/intel_i2c.c index 3b79cb40cd..52f7a528ef 100644 --- a/drivers/i2c/intel_i2c.c +++ b/drivers/i2c/intel_i2c.c @@ -269,21 +269,11 @@ static int intel_i2c_probe(struct udevice *dev) static int intel_i2c_bind(struct udevice *dev) { - static int num_cards __attribute__ ((section(".data"))); char name[20]; /* Create a unique device name for PCI type devices */ if (device_is_on_pci_bus(dev)) { - /* - * ToDo: - * Setting req_seq in the driver is probably not recommended. - * But without a DT alias the number is not configured. And - * using this driver is impossible for PCIe I2C devices. - * This can be removed, once a better (correct) way for this - * is found and implemented. - */ - dev->req_seq = num_cards; - sprintf(name, "intel_i2c#%u", num_cards++); + sprintf(name, "intel_i2c#%u", dev_seq(dev)); device_set_name(dev, name); } @@ -306,7 +296,7 @@ U_BOOT_DRIVER(intel_i2c) = { .id = UCLASS_I2C, .of_match = intel_i2c_ids, .ops = &intel_i2c_ops, - .priv_auto_alloc_size = sizeof(struct intel_i2c), + .priv_auto = sizeof(struct intel_i2c), .bind = intel_i2c_bind, .probe = intel_i2c_probe, }; diff --git a/drivers/i2c/iproc_i2c.c b/drivers/i2c/iproc_i2c.c index b7e9ced898..83301bbf1b 100644 --- a/drivers/i2c/iproc_i2c.c +++ b/drivers/i2c/iproc_i2c.c @@ -672,7 +672,7 @@ static int iproc_i2c_probe(struct udevice *bus) return iproc_i2c_init(bus); } -static int iproc_i2c_ofdata_to_platdata(struct udevice *bus) +static int iproc_i2c_of_to_plat(struct udevice *bus) { struct iproc_i2c *bus_prvdata = dev_get_priv(bus); int node = dev_of_offset(bus); @@ -705,9 +705,9 @@ U_BOOT_DRIVER(iproc_i2c) = { .name = "iproc_i2c", .id = UCLASS_I2C, .of_match = iproc_i2c_ids, - .ofdata_to_platdata = iproc_i2c_ofdata_to_platdata, + .of_to_plat = iproc_i2c_of_to_plat, .probe = iproc_i2c_probe, - .priv_auto_alloc_size = sizeof(struct iproc_i2c), + .priv_auto = sizeof(struct iproc_i2c), .ops = &iproc_i2c_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/i2c/lpc32xx_i2c.c b/drivers/i2c/lpc32xx_i2c.c index 6af2e975cf..ad11e978cc 100644 --- a/drivers/i2c/lpc32xx_i2c.c +++ b/drivers/i2c/lpc32xx_i2c.c @@ -281,8 +281,12 @@ U_BOOT_I2C_ADAP_COMPLETE(lpc32xx_2, lpc32xx_i2c_init, NULL, #else /* CONFIG_DM_I2C */ static int lpc32xx_i2c_probe(struct udevice *bus) { - struct lpc32xx_i2c_dev *dev = dev_get_platdata(bus); - bus->seq = dev->index; + struct lpc32xx_i2c_dev *dev = dev_get_plat(bus); + + /* + * FIXME: This is not permitted + * dev_seq(bus) = dev->index; + */ __i2c_init(dev->base, dev->speed, 0, dev->index); return 0; @@ -291,14 +295,14 @@ static int lpc32xx_i2c_probe(struct udevice *bus) static int lpc32xx_i2c_probe_chip(struct udevice *bus, u32 chip_addr, u32 chip_flags) { - struct lpc32xx_i2c_dev *dev = dev_get_platdata(bus); + struct lpc32xx_i2c_dev *dev = dev_get_plat(bus); return __i2c_probe_chip(dev->base, chip_addr); } static int lpc32xx_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) { - struct lpc32xx_i2c_dev *dev = dev_get_platdata(bus); + struct lpc32xx_i2c_dev *dev = dev_get_plat(bus); struct i2c_msg *dmsg, *omsg, dummy; uint i = 0, address = 0; @@ -330,13 +334,13 @@ static int lpc32xx_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, static int lpc32xx_i2c_set_bus_speed(struct udevice *bus, unsigned int speed) { - struct lpc32xx_i2c_dev *dev = dev_get_platdata(bus); + struct lpc32xx_i2c_dev *dev = dev_get_plat(bus); return __i2c_set_bus_speed(dev->base, speed, dev->index); } static int lpc32xx_i2c_reset(struct udevice *bus) { - struct lpc32xx_i2c_dev *dev = dev_get_platdata(bus); + struct lpc32xx_i2c_dev *dev = dev_get_plat(bus); __i2c_init(dev->base, dev->speed, 0, dev->index); return 0; diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c index e070caf43f..434e3461b1 100644 --- a/drivers/i2c/meson_i2c.c +++ b/drivers/i2c/meson_i2c.c @@ -308,6 +308,6 @@ U_BOOT_DRIVER(i2c_meson) = { .id = UCLASS_I2C, .of_match = meson_i2c_ids, .probe = meson_i2c_probe, - .priv_auto_alloc_size = sizeof(struct meson_i2c), + .priv_auto = sizeof(struct meson_i2c), .ops = &meson_i2c_ops, }; diff --git a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c index 584d0a4fef..928e02b7af 100644 --- a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c +++ b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c @@ -145,5 +145,5 @@ U_BOOT_DRIVER(i2c_arbitrator) = { .probe = i2c_arbitrator_probe, .remove = i2c_arbitrator_remove, .ops = &i2c_arbitrator_ops, - .priv_auto_alloc_size = sizeof(struct i2c_arbitrator_priv), + .priv_auto = sizeof(struct i2c_arbitrator_priv), }; diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 83dcb40213..8d6e208a0b 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -136,5 +136,5 @@ U_BOOT_DRIVER(i2c_mux_gpio) = { .of_match = i2c_mux_gpio_ids, .ops = &i2c_mux_gpio_ops, .probe = i2c_mux_gpio_probe, - .priv_auto_alloc_size = sizeof(struct i2c_mux_gpio_priv), + .priv_auto = sizeof(struct i2c_mux_gpio_priv), }; diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c index 26897554b0..dbca409ee3 100644 --- a/drivers/i2c/muxes/i2c-mux-uclass.c +++ b/drivers/i2c/muxes/i2c-mux-uclass.c @@ -36,7 +36,7 @@ struct i2c_mux_bus { /* Find out the mux channel number */ static int i2c_mux_child_post_bind(struct udevice *dev) { - struct i2c_mux_bus *plat = dev_get_parent_platdata(dev); + struct i2c_mux_bus *plat = dev_get_parent_plat(dev); int channel; channel = dev_read_u32_default(dev, "reg", -1); @@ -87,8 +87,8 @@ static int i2c_mux_post_bind(struct udevice *mux) ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv", full_name, node, &dev); - debug(" - bind ret=%d, %s, req_seq %d\n", ret, - dev ? dev->name : NULL, dev->req_seq); + debug(" - bind ret=%d, %s, seq %d\n", ret, + dev ? dev->name : NULL, dev_seq(dev)); if (ret) return ret; } @@ -126,7 +126,7 @@ static int i2c_mux_post_probe(struct udevice *mux) int i2c_mux_select(struct udevice *dev) { - struct i2c_mux_bus *plat = dev_get_parent_platdata(dev); + struct i2c_mux_bus *plat = dev_get_parent_plat(dev); struct udevice *mux = dev->parent; struct i2c_mux_ops *ops = i2c_mux_get_ops(mux); @@ -138,7 +138,7 @@ int i2c_mux_select(struct udevice *dev) int i2c_mux_deselect(struct udevice *dev) { - struct i2c_mux_bus *plat = dev_get_parent_platdata(dev); + struct i2c_mux_bus *plat = dev_get_parent_plat(dev); struct udevice *mux = dev->parent; struct i2c_mux_ops *ops = i2c_mux_get_ops(mux); @@ -220,7 +220,7 @@ UCLASS_DRIVER(i2c_mux) = { .name = "i2c_mux", .post_bind = i2c_mux_post_bind, .post_probe = i2c_mux_post_probe, - .per_device_auto_alloc_size = sizeof(struct i2c_mux), - .per_child_platdata_auto_alloc_size = sizeof(struct i2c_mux_bus), + .per_device_auto = sizeof(struct i2c_mux), + .per_child_plat_auto = sizeof(struct i2c_mux_bus), .child_post_bind = i2c_mux_child_post_bind, }; diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c index 7360e162ee..d21a84c4fa 100644 --- a/drivers/i2c/muxes/pca954x.c +++ b/drivers/i2c/muxes/pca954x.c @@ -108,7 +108,7 @@ static const struct udevice_id pca954x_ids[] = { { } }; -static int pca954x_ofdata_to_platdata(struct udevice *dev) +static int pca954x_of_to_plat(struct udevice *dev) { struct pca954x_priv *priv = dev_get_priv(dev); const struct chip_desc *chip = &chips[dev_get_driver_data(dev)]; @@ -171,6 +171,6 @@ U_BOOT_DRIVER(pca954x) = { .probe = pca954x_probe, .remove = pca954x_remove, .ops = &pca954x_ops, - .ofdata_to_platdata = pca954x_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct pca954x_priv), + .of_to_plat = pca954x_of_to_plat, + .priv_auto = sizeof(struct pca954x_priv), }; diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c index 82e8fdac41..ef1007de14 100644 --- a/drivers/i2c/mv_i2c.c +++ b/drivers/i2c/mv_i2c.c @@ -600,7 +600,7 @@ U_BOOT_DRIVER(i2c_mv) = { .id = UCLASS_I2C, .of_match = mv_i2c_ids, .probe = mv_i2c_probe, - .priv_auto_alloc_size = sizeof(struct mv_i2c_priv), + .priv_auto = sizeof(struct mv_i2c_priv), .ops = &mv_i2c_ops, }; #endif /* CONFIG_DM_I2C */ diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index 14c594d648..a4d59b67a2 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -794,7 +794,7 @@ static int mvtwsi_i2c_set_bus_speed(struct udevice *bus, uint speed) return 0; } -static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus) +static int mvtwsi_i2c_of_to_plat(struct udevice *bus) { struct mvtwsi_i2c_dev *dev = dev_get_priv(bus); @@ -823,9 +823,9 @@ static int mvtwsi_i2c_bind(struct udevice *bus) struct mvtwsi_registers *twsi = dev_read_addr_ptr(bus); /* Disable the hidden slave in i2c0 of these platforms */ - if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARCH_KIRKWOOD) - || IS_ENABLED(CONFIG_ARMADA_8K)) - && bus->req_seq == 0) + if ((IS_ENABLED(CONFIG_ARMADA_38X) || + IS_ENABLED(CONFIG_ARCH_KIRKWOOD) || + IS_ENABLED(CONFIG_ARMADA_8K)) && !dev_seq(bus)) twsi_disable_i2c_slave(twsi); return 0; @@ -888,8 +888,8 @@ U_BOOT_DRIVER(i2c_mvtwsi) = { .of_match = mvtwsi_i2c_ids, .bind = mvtwsi_i2c_bind, .probe = mvtwsi_i2c_probe, - .ofdata_to_platdata = mvtwsi_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct mvtwsi_i2c_dev), + .of_to_plat = mvtwsi_i2c_of_to_plat, + .priv_auto = sizeof(struct mvtwsi_i2c_dev), .ops = &mvtwsi_i2c_ops, }; #endif /* CONFIG_DM_I2C */ diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index d486dab043..0362ec6763 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -914,7 +914,7 @@ static int mxc_i2c_probe(struct udevice *bus) } i2c_bus->base = addr; - i2c_bus->index = bus->seq; + i2c_bus->index = dev_seq(bus); i2c_bus->bus = bus; /* Enable clk */ @@ -930,7 +930,7 @@ static int mxc_i2c_probe(struct udevice *bus) return ret; } #else - ret = enable_i2c_clk(1, bus->seq); + ret = enable_i2c_clk(1, dev_seq(bus)); if (ret < 0) return ret; #endif @@ -942,7 +942,7 @@ static int mxc_i2c_probe(struct udevice *bus) ret = fdt_stringlist_search(fdt, node, "pinctrl-names", "gpio"); if (ret < 0) { debug("i2c bus %d at 0x%2lx, no gpio pinctrl state.\n", - bus->seq, i2c_bus->base); + dev_seq(bus), i2c_bus->base); } else { ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "scl-gpios", 0, &i2c_bus->scl_gpio, @@ -955,7 +955,7 @@ static int mxc_i2c_probe(struct udevice *bus) ret || ret2) { dev_err(bus, "i2c bus %d at 0x%2lx, fail to request scl/sda gpio\n", - bus->seq, i2c_bus->base); + dev_seq(bus), i2c_bus->base); return -EINVAL; } } @@ -966,7 +966,7 @@ static int mxc_i2c_probe(struct udevice *bus) */ debug("i2c : controller bus %d at %lu , speed %d: ", - bus->seq, i2c_bus->base, + dev_seq(bus), i2c_bus->base, i2c_bus->speed); return 0; @@ -1072,7 +1072,7 @@ U_BOOT_DRIVER(i2c_mxc) = { .id = UCLASS_I2C, .of_match = mxc_i2c_ids, .probe = mxc_i2c_probe, - .priv_auto_alloc_size = sizeof(struct mxc_i2c_bus), + .priv_auto = sizeof(struct mxc_i2c_bus), .ops = &mxc_i2c_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/i2c/nx_i2c.c b/drivers/i2c/nx_i2c.c index ca14a0ecac..c63a732557 100644 --- a/drivers/i2c/nx_i2c.c +++ b/drivers/i2c/nx_i2c.c @@ -240,7 +240,7 @@ static int nx_i2c_probe(struct udevice *dev) return -EINVAL; bus->regs = (struct nx_i2c_regs *)addr; - bus->bus_num = dev->seq; + bus->bus_num = dev_seq(dev); /* i2c node parsing */ i2c_process_node(dev); @@ -621,6 +621,6 @@ U_BOOT_DRIVER(i2c_nexell) = { .id = UCLASS_I2C, .of_match = nx_i2c_ids, .probe = nx_i2c_probe, - .priv_auto_alloc_size = sizeof(struct nx_i2c_bus), + .priv_auto = sizeof(struct nx_i2c_bus), .ops = &nx_i2c_ops, }; diff --git a/drivers/i2c/ocores_i2c.c b/drivers/i2c/ocores_i2c.c index c4f2cc43f9..48ed1d5bff 100644 --- a/drivers/i2c/ocores_i2c.c +++ b/drivers/i2c/ocores_i2c.c @@ -632,6 +632,6 @@ U_BOOT_DRIVER(i2c_ocores) = { .id = UCLASS_I2C, .of_match = ocores_i2c_ids, .probe = ocores_i2c_probe, - .priv_auto_alloc_size = sizeof(struct ocores_i2c_bus), + .priv_auto = sizeof(struct ocores_i2c_bus), .ops = &ocores_i2c_ops, }; diff --git a/drivers/i2c/octeon_i2c.c b/drivers/i2c/octeon_i2c.c index 23dcb1563e..ea2cc33f9d 100644 --- a/drivers/i2c/octeon_i2c.c +++ b/drivers/i2c/octeon_i2c.c @@ -791,7 +791,6 @@ static int octeon_i2c_probe(struct udevice *dev) pci_dev_t bdf = dm_pci_get_bdf(dev); debug("TWSI PCI device: %x\n", bdf); - dev->req_seq = PCI_FUNC(bdf); twsi->base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); @@ -811,7 +810,7 @@ static int octeon_i2c_probe(struct udevice *dev) if (ret) return ret; - debug("TWSI bus %d at %p\n", dev->seq, twsi->base); + debug("TWSI bus %d at %p\n", dev_seq(dev), twsi->base); /* Start with standard speed, real speed set via DT or cmd */ return twsi_init(twsi->base, i2c_slave_addr); @@ -835,6 +834,6 @@ U_BOOT_DRIVER(octeon_pci_twsi) = { .id = UCLASS_I2C, .of_match = octeon_i2c_ids, .probe = octeon_i2c_probe, - .priv_auto_alloc_size = sizeof(struct octeon_twsi), + .priv_auto = sizeof(struct octeon_twsi), .ops = &octeon_i2c_ops, }; diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 0af4e333c4..1355dc274e 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -1049,7 +1049,7 @@ static int omap_i2c_probe_chip(struct udevice *bus, uint chip_addr, static int omap_i2c_probe(struct udevice *bus) { struct omap_i2c *priv = dev_get_priv(bus); - struct omap_i2c_platdata *plat = dev_get_platdata(bus); + struct omap_i2c_plat *plat = dev_get_plat(bus); priv->speed = plat->speed; priv->regs = map_physmem(plat->base, sizeof(void *), @@ -1063,9 +1063,9 @@ static int omap_i2c_probe(struct udevice *bus) } #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int omap_i2c_ofdata_to_platdata(struct udevice *bus) +static int omap_i2c_of_to_plat(struct udevice *bus) { - struct omap_i2c_platdata *plat = dev_get_platdata(bus); + struct omap_i2c_plat *plat = dev_get_plat(bus); plat->base = dev_read_addr(bus); plat->speed = dev_read_u32_default(bus, "clock-frequency", @@ -1093,11 +1093,11 @@ U_BOOT_DRIVER(i2c_omap) = { .id = UCLASS_I2C, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = omap_i2c_ids, - .ofdata_to_platdata = omap_i2c_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct omap_i2c_platdata), + .of_to_plat = omap_i2c_of_to_plat, + .plat_auto = sizeof(struct omap_i2c_plat), #endif .probe = omap_i2c_probe, - .priv_auto_alloc_size = sizeof(struct omap_i2c), + .priv_auto = sizeof(struct omap_i2c), .ops = &omap_i2c_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c index 663c342cd8..14bb6603d5 100644 --- a/drivers/i2c/rcar_i2c.c +++ b/drivers/i2c/rcar_i2c.c @@ -371,6 +371,6 @@ U_BOOT_DRIVER(i2c_rcar) = { .id = UCLASS_I2C, .of_match = rcar_i2c_ids, .probe = rcar_i2c_probe, - .priv_auto_alloc_size = sizeof(struct rcar_i2c_priv), + .priv_auto = sizeof(struct rcar_i2c_priv), .ops = &rcar_i2c_ops, }; diff --git a/drivers/i2c/rcar_iic.c b/drivers/i2c/rcar_iic.c index cad0a623d3..f0e50914c6 100644 --- a/drivers/i2c/rcar_iic.c +++ b/drivers/i2c/rcar_iic.c @@ -269,6 +269,6 @@ U_BOOT_DRIVER(iic_rcar) = { .id = UCLASS_I2C, .of_match = rcar_iic_ids, .probe = rcar_iic_probe, - .priv_auto_alloc_size = sizeof(struct rcar_iic_priv), + .priv_auto = sizeof(struct rcar_iic_priv), .ops = &rcar_iic_ops, }; diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c index 659461088b..f8fac45b6c 100644 --- a/drivers/i2c/rk_i2c.c +++ b/drivers/i2c/rk_i2c.c @@ -375,7 +375,7 @@ int rockchip_i2c_set_bus_speed(struct udevice *bus, unsigned int speed) return 0; } -static int rockchip_i2c_ofdata_to_platdata(struct udevice *bus) +static int rockchip_i2c_of_to_plat(struct udevice *bus) { struct rk_i2c *priv = dev_get_priv(bus); int ret; @@ -489,10 +489,10 @@ U_BOOT_DRIVER(rockchip_rk3066_i2c) = { .name = "rockchip_rk3066_i2c", .id = UCLASS_I2C, .of_match = rockchip_i2c_ids, - .ofdata_to_platdata = rockchip_i2c_ofdata_to_platdata, + .of_to_plat = rockchip_i2c_of_to_plat, .probe = rockchip_i2c_probe, - .priv_auto_alloc_size = sizeof(struct rk_i2c), + .priv_auto = sizeof(struct rk_i2c), .ops = &rockchip_i2c_ops, }; -U_BOOT_DRIVER_ALIAS(rockchip_rk3066_i2c, rockchip_rk3288_i2c) +DM_DRIVER_ALIAS(rockchip_rk3066_i2c, rockchip_rk3288_i2c) diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c index cb45d3c100..0c8915605d 100644 --- a/drivers/i2c/s3c24x0_i2c.c +++ b/drivers/i2c/s3c24x0_i2c.c @@ -302,7 +302,7 @@ static int s3c24x0_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, return ret ? -EREMOTEIO : 0; } -static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) +static int s3c_i2c_of_to_plat(struct udevice *dev) { const void *blob = gd->fdt_blob; struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev); @@ -318,7 +318,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) dev_read_u32_default(dev, "clock-frequency", I2C_SPEED_STANDARD_RATE); i2c_bus->node = node; - i2c_bus->bus_num = dev->seq; + i2c_bus->bus_num = dev_seq(dev); exynos_pinmux_config(i2c_bus->id, 0); @@ -342,7 +342,7 @@ U_BOOT_DRIVER(i2c_s3c) = { .name = "i2c_s3c", .id = UCLASS_I2C, .of_match = s3c_i2c_ids, - .ofdata_to_platdata = s3c_i2c_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct s3c24x0_i2c_bus), + .of_to_plat = s3c_i2c_of_to_plat, + .priv_auto = sizeof(struct s3c24x0_i2c_bus), .ops = &s3c_i2c_ops, }; diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c index 2cbdaf9cc7..c99e6de933 100644 --- a/drivers/i2c/sandbox_i2c.c +++ b/drivers/i2c/sandbox_i2c.c @@ -10,15 +10,12 @@ #include <errno.h> #include <i2c.h> #include <log.h> +#include <asm/i2c.h> #include <asm/test.h> #include <dm/acpi.h> #include <dm/lists.h> #include <dm/device-internal.h> -struct sandbox_i2c_priv { - bool test_mode; -}; - static int get_emul(struct udevice *dev, struct udevice **devp, struct dm_i2c_ops **opsp) { @@ -27,7 +24,7 @@ static int get_emul(struct udevice *dev, struct udevice **devp, *devp = NULL; *opsp = NULL; - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); if (!plat->emul) { ret = i2c_emul_find(dev, &plat->emul); if (ret) @@ -98,5 +95,5 @@ U_BOOT_DRIVER(sandbox_i2c) = { .id = UCLASS_I2C, .of_match = sandbox_i2c_ids, .ops = &sandbox_i2c_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_i2c_priv), + .priv_auto = sizeof(struct sandbox_i2c_priv), }; diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c index 2f60911549..6553bdc610 100644 --- a/drivers/i2c/stm32f7_i2c.c +++ b/drivers/i2c/stm32f7_i2c.c @@ -901,7 +901,7 @@ clk_free: return ret; } -static int stm32_ofdata_to_platdata(struct udevice *dev) +static int stm32_of_to_plat(struct udevice *dev) { struct stm32_i2c_priv *i2c_priv = dev_get_priv(dev); u32 rise_time, fall_time; @@ -953,8 +953,8 @@ U_BOOT_DRIVER(stm32f7_i2c) = { .name = "stm32f7-i2c", .id = UCLASS_I2C, .of_match = stm32_i2c_of_match, - .ofdata_to_platdata = stm32_ofdata_to_platdata, + .of_to_plat = stm32_of_to_plat, .probe = stm32_i2c_probe, - .priv_auto_alloc_size = sizeof(struct stm32_i2c_priv), + .priv_auto = sizeof(struct stm32_i2c_priv), .ops = &stm32_i2c_ops, }; diff --git a/drivers/i2c/tegra186_bpmp_i2c.c b/drivers/i2c/tegra186_bpmp_i2c.c index 37204718ca..88e4e9a5c9 100644 --- a/drivers/i2c/tegra186_bpmp_i2c.c +++ b/drivers/i2c/tegra186_bpmp_i2c.c @@ -122,6 +122,6 @@ U_BOOT_DRIVER(i2c_gpio) = { .id = UCLASS_I2C, .of_match = tegra186_bpmp_i2c_ids, .probe = tegra186_bpmp_i2c_probe, - .priv_auto_alloc_size = sizeof(struct tegra186_bpmp_i2c), + .priv_auto = sizeof(struct tegra186_bpmp_i2c), .ops = &tegra186_bpmp_i2c_ops, }; diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c index 65b3734348..1e74484542 100644 --- a/drivers/i2c/tegra_i2c.c +++ b/drivers/i2c/tegra_i2c.c @@ -362,7 +362,7 @@ static int tegra_i2c_probe(struct udevice *dev) int ret; bool is_dvc; - i2c_bus->id = dev->seq; + i2c_bus->id = dev_seq(dev); i2c_bus->type = dev_get_driver_data(dev); i2c_bus->regs = (struct i2c_ctlr *)dev_read_addr(dev); if ((ulong)i2c_bus->regs == FDT_ADDR_T_NONE) { @@ -408,7 +408,8 @@ static int tegra_i2c_probe(struct udevice *dev) } i2c_init_controller(i2c_bus); debug("%s: controller bus %d at %p, speed %d: ", - is_dvc ? "dvc" : "i2c", dev->seq, i2c_bus->regs, i2c_bus->speed); + is_dvc ? "dvc" : "i2c", dev_seq(dev), i2c_bus->regs, + i2c_bus->speed); return 0; } @@ -523,6 +524,6 @@ U_BOOT_DRIVER(i2c_tegra) = { .id = UCLASS_I2C, .of_match = tegra_i2c_ids, .probe = tegra_i2c_probe, - .priv_auto_alloc_size = sizeof(struct i2c_bus), + .priv_auto = sizeof(struct i2c_bus), .ops = &tegra_i2c_ops, }; diff --git a/drivers/i2c/xilinx_xiic.c b/drivers/i2c/xilinx_xiic.c index 149bd327bd..72199a62b2 100644 --- a/drivers/i2c/xilinx_xiic.c +++ b/drivers/i2c/xilinx_xiic.c @@ -348,6 +348,6 @@ U_BOOT_DRIVER(xilinx_xiic) = { .id = UCLASS_I2C, .of_match = xilinx_xiic_ids, .probe = xilinx_xiic_probe, - .priv_auto_alloc_size = sizeof(struct xilinx_xiic_priv), + .priv_auto = sizeof(struct xilinx_xiic_priv), .ops = &xilinx_xiic_ops, }; diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c index 0c0f52205b..dc3b08c0f6 100644 --- a/drivers/input/cros_ec_keyb.c +++ b/drivers/input/cros_ec_keyb.c @@ -251,5 +251,5 @@ U_BOOT_DRIVER(google_cros_ec_keyb) = { .of_match = cros_ec_kbd_ids, .probe = cros_ec_kbd_probe, .ops = &cros_ec_kbd_ops, - .priv_auto_alloc_size = sizeof(struct cros_ec_keyb_priv), + .priv_auto = sizeof(struct cros_ec_keyb_priv), }; diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index 7beaccca2c..1ea11fd67b 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -357,5 +357,5 @@ U_BOOT_DRIVER(i8042_kbd) = { .probe = i8042_kbd_probe, .remove = i8042_kbd_remove, .ops = &i8042_kbd_ops, - .priv_auto_alloc_size = sizeof(struct i8042_kbd_priv), + .priv_auto = sizeof(struct i8042_kbd_priv), }; diff --git a/drivers/input/keyboard-uclass.c b/drivers/input/keyboard-uclass.c index f19934e6bb..2c6680337d 100644 --- a/drivers/input/keyboard-uclass.c +++ b/drivers/input/keyboard-uclass.c @@ -87,5 +87,5 @@ UCLASS_DRIVER(keyboard) = { .id = UCLASS_KEYBOARD, .name = "keyboard", .pre_probe = keyboard_pre_probe, - .per_device_auto_alloc_size = sizeof(struct keyboard_priv), + .per_device_auto = sizeof(struct keyboard_priv), }; diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c index f07a51dc30..5113041d3e 100644 --- a/drivers/input/tegra-kbc.c +++ b/drivers/input/tegra-kbc.c @@ -350,5 +350,5 @@ U_BOOT_DRIVER(tegra_kbd) = { .of_match = tegra_kbd_ids, .probe = tegra_kbd_probe, .ops = &tegra_kbd_ops, - .priv_auto_alloc_size = sizeof(struct tegra_kbd_priv), + .priv_auto = sizeof(struct tegra_kbd_priv), }; diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 2859475a6b..e15a2967ff 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -22,7 +22,7 @@ int led_get_by_label(const char *label, struct udevice **devp) if (ret) return ret; uclass_foreach_dev(dev, uc) { - struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Ignore the top-level LED node */ if (uc_plat->label && !strcmp(label, uc_plat->label)) @@ -96,5 +96,5 @@ int led_default_state(void) UCLASS_DRIVER(led) = { .id = UCLASS_LED, .name = "led", - .per_device_platdata_auto_alloc_size = sizeof(struct led_uc_plat), + .per_device_plat_auto = sizeof(struct led_uc_plat), }; diff --git a/drivers/led/led_bcm6328.c b/drivers/led/led_bcm6328.c index 52946835de..bf8207d638 100644 --- a/drivers/led/led_bcm6328.c +++ b/drivers/led/led_bcm6328.c @@ -147,7 +147,7 @@ static const struct led_ops bcm6328_led_ops = { static int bcm6328_led_probe(struct udevice *dev) { - struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Top-level LED node */ if (!uc_plat->label) { @@ -222,7 +222,7 @@ static int bcm6328_led_bind(struct udevice *parent) if (ret) return ret; - uc_plat = dev_get_uclass_platdata(dev); + uc_plat = dev_get_uclass_plat(dev); uc_plat->label = label; } @@ -241,5 +241,5 @@ U_BOOT_DRIVER(bcm6328_led) = { .ops = &bcm6328_led_ops, .bind = bcm6328_led_bind, .probe = bcm6328_led_probe, - .priv_auto_alloc_size = sizeof(struct bcm6328_led_priv), + .priv_auto = sizeof(struct bcm6328_led_priv), }; diff --git a/drivers/led/led_bcm6358.c b/drivers/led/led_bcm6358.c index 307d418a17..3e57cdfd17 100644 --- a/drivers/led/led_bcm6358.c +++ b/drivers/led/led_bcm6358.c @@ -113,7 +113,7 @@ static const struct led_ops bcm6358_led_ops = { static int bcm6358_led_probe(struct udevice *dev) { - struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Top-level LED node */ if (!uc_plat->label) { @@ -192,7 +192,7 @@ static int bcm6358_led_bind(struct udevice *parent) if (ret) return ret; - uc_plat = dev_get_uclass_platdata(dev); + uc_plat = dev_get_uclass_plat(dev); uc_plat->label = label; } @@ -210,6 +210,6 @@ U_BOOT_DRIVER(bcm6358_led) = { .of_match = bcm6358_led_ids, .bind = bcm6358_led_bind, .probe = bcm6358_led_probe, - .priv_auto_alloc_size = sizeof(struct bcm6358_led_priv), + .priv_auto = sizeof(struct bcm6358_led_priv), .ops = &bcm6358_led_ops, }; diff --git a/drivers/led/led_bcm6858.c b/drivers/led/led_bcm6858.c index 511185ffad..fbf46a114c 100644 --- a/drivers/led/led_bcm6858.c +++ b/drivers/led/led_bcm6858.c @@ -154,7 +154,7 @@ static const struct led_ops bcm6858_led_ops = { static int bcm6858_led_probe(struct udevice *dev) { - struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Top-level LED node */ if (!uc_plat->label) { @@ -229,7 +229,7 @@ static int bcm6858_led_bind(struct udevice *parent) if (ret) return ret; - uc_plat = dev_get_uclass_platdata(dev); + uc_plat = dev_get_uclass_plat(dev); uc_plat->label = label; } @@ -247,6 +247,6 @@ U_BOOT_DRIVER(bcm6858_led) = { .of_match = bcm6858_led_ids, .bind = bcm6858_led_bind, .probe = bcm6858_led_probe, - .priv_auto_alloc_size = sizeof(struct bcm6858_led_priv), + .priv_auto = sizeof(struct bcm6858_led_priv), .ops = &bcm6858_led_ops, }; diff --git a/drivers/led/led_cortina.c b/drivers/led/led_cortina.c index 8fd6fd1539..598c0a03db 100644 --- a/drivers/led/led_cortina.c +++ b/drivers/led/led_cortina.c @@ -57,7 +57,7 @@ struct cortina_led_cfg { }; /* LED_control structures */ -struct cortina_led_platdata { +struct cortina_led_plat { void __iomem *ctrl_regs; u16 rate1; /* blink rate setting 0 */ u16 rate2; /* blink rate setting 1 */ @@ -130,13 +130,13 @@ static const struct led_ops cortina_led_ops = { .set_state = cortina_led_set_state, }; -static int ca_led_ofdata_to_platdata(struct udevice *dev) +static int ca_led_of_to_plat(struct udevice *dev) { - struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Top-level LED node */ if (!uc_plat->label) { - struct cortina_led_platdata *plt = dev_get_platdata(dev); + struct cortina_led_plat *plt = dev_get_plat(dev); plt->rate1 = dev_read_u32_default(dev, "Cortina,blink-rate1", 256); @@ -165,22 +165,22 @@ static int ca_led_ofdata_to_platdata(struct udevice *dev) static int cortina_led_probe(struct udevice *dev) { - struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Top-level LED node */ if (!uc_plat->label) { - struct cortina_led_platdata *platdata = dev_get_platdata(dev); + struct cortina_led_plat *plat = dev_get_plat(dev); u32 reg_value, val; u16 rate1, rate2; - if (!platdata->ctrl_regs) + if (!plat->ctrl_regs) return -EINVAL; reg_value = 0; reg_value |= LED_CLK_POLARITY; - rate1 = platdata->rate1; - rate2 = platdata->rate2; + rate1 = plat->rate1; + rate2 = plat->rate2; val = rate1 / 16 - 1; rate1 = val > LED_MAX_HW_BLINK ? @@ -194,7 +194,7 @@ static int cortina_led_probe(struct udevice *dev) reg_value |= (rate2 & LED_BLINK_RATE2_MASK) << LED_BLINK_RATE2_SHIFT; - cortina_led_write(platdata->ctrl_regs, reg_value); + cortina_led_write(plat->ctrl_regs, reg_value); } else { struct cortina_led_cfg *priv = dev_get_priv(dev); @@ -273,7 +273,7 @@ static int cortina_led_bind(struct udevice *parent) node, &dev); if (ret) return ret; - uc_plat = dev_get_uclass_platdata(dev); + uc_plat = dev_get_uclass_plat(dev); uc_plat->label = label; } @@ -289,10 +289,10 @@ U_BOOT_DRIVER(cortina_led) = { .name = "ca-leds", .id = UCLASS_LED, .of_match = ca_led_ids, - .ofdata_to_platdata = ca_led_ofdata_to_platdata, + .of_to_plat = ca_led_of_to_plat, .bind = cortina_led_bind, .probe = cortina_led_probe, - .platdata_auto_alloc_size = sizeof(struct cortina_led_platdata), - .priv_auto_alloc_size = sizeof(struct cortina_led_cfg), + .plat_auto = sizeof(struct cortina_led_plat), + .priv_auto = sizeof(struct cortina_led_cfg), .ops = &cortina_led_ops, }; diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c index 2cdb0269f4..67ece3cbcd 100644 --- a/drivers/led/led_gpio.c +++ b/drivers/led/led_gpio.c @@ -57,7 +57,7 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev) static int led_gpio_probe(struct udevice *dev) { - struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev); + struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct led_gpio_priv *priv = dev_get_priv(dev); int ret; @@ -106,7 +106,7 @@ static int led_gpio_bind(struct udevice *parent) node, &dev); if (ret) return ret; - uc_plat = dev_get_uclass_platdata(dev); + uc_plat = dev_get_uclass_plat(dev); uc_plat->label = label; } @@ -128,7 +128,7 @@ U_BOOT_DRIVER(led_gpio) = { .id = UCLASS_LED, .of_match = led_gpio_ids, .ops = &gpio_led_ops, - .priv_auto_alloc_size = sizeof(struct led_gpio_priv), + .priv_auto = sizeof(struct led_gpio_priv), .bind = led_gpio_bind, .probe = led_gpio_probe, .remove = led_gpio_remove, diff --git a/drivers/mailbox/k3-sec-proxy.c b/drivers/mailbox/k3-sec-proxy.c index 27ccc6eab0..8dd93a3e11 100644 --- a/drivers/mailbox/k3-sec-proxy.c +++ b/drivers/mailbox/k3-sec-proxy.c @@ -438,6 +438,6 @@ U_BOOT_DRIVER(k3_sec_proxy) = { .of_match = k3_sec_proxy_ids, .probe = k3_sec_proxy_probe, .remove = k3_sec_proxy_remove, - .priv_auto_alloc_size = sizeof(struct k3_sec_proxy_mbox), + .priv_auto = sizeof(struct k3_sec_proxy_mbox), .ops = &k3_sec_proxy_mbox_ops, }; diff --git a/drivers/mailbox/sandbox-mbox-test.c b/drivers/mailbox/sandbox-mbox-test.c index faca8fcc44..ffd4674d1e 100644 --- a/drivers/mailbox/sandbox-mbox-test.c +++ b/drivers/mailbox/sandbox-mbox-test.c @@ -50,5 +50,5 @@ U_BOOT_DRIVER(sandbox_mbox_test) = { .name = "sandbox_mbox_test", .id = UCLASS_MISC, .of_match = sandbox_mbox_test_ids, - .priv_auto_alloc_size = sizeof(struct sandbox_mbox_test), + .priv_auto = sizeof(struct sandbox_mbox_test), }; diff --git a/drivers/mailbox/sandbox-mbox.c b/drivers/mailbox/sandbox-mbox.c index 19704dd5da..87d38de0cb 100644 --- a/drivers/mailbox/sandbox-mbox.c +++ b/drivers/mailbox/sandbox-mbox.c @@ -100,6 +100,6 @@ U_BOOT_DRIVER(sandbox_mbox) = { .of_match = sandbox_mbox_ids, .bind = sandbox_mbox_bind, .probe = sandbox_mbox_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_mbox), + .priv_auto = sizeof(struct sandbox_mbox), .ops = &sandbox_mbox_mbox_ops, }; diff --git a/drivers/mailbox/stm32-ipcc.c b/drivers/mailbox/stm32-ipcc.c index 81a4115986..093b570414 100644 --- a/drivers/mailbox/stm32-ipcc.c +++ b/drivers/mailbox/stm32-ipcc.c @@ -163,6 +163,6 @@ U_BOOT_DRIVER(stm32_ipcc) = { .id = UCLASS_MAILBOX, .of_match = stm32_ipcc_ids, .probe = stm32_ipcc_probe, - .priv_auto_alloc_size = sizeof(struct stm32_ipcc), + .priv_auto = sizeof(struct stm32_ipcc), .ops = &stm32_ipcc_mbox_ops, }; diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index e91dac201d..1d66d95fe4 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -189,6 +189,6 @@ U_BOOT_DRIVER(tegra_hsp) = { .of_match = tegra_hsp_ids, .bind = tegra_hsp_bind, .probe = tegra_hsp_probe, - .priv_auto_alloc_size = sizeof(struct tegra_hsp), + .priv_auto = sizeof(struct tegra_hsp), .ops = &tegra_hsp_mbox_ops, }; diff --git a/drivers/mailbox/zynqmp-ipi.c b/drivers/mailbox/zynqmp-ipi.c index 847a03648b..959cce923c 100644 --- a/drivers/mailbox/zynqmp-ipi.c +++ b/drivers/mailbox/zynqmp-ipi.c @@ -137,6 +137,6 @@ U_BOOT_DRIVER(zynqmp_ipi) = { .id = UCLASS_MAILBOX, .of_match = zynqmp_ipi_ids, .probe = zynqmp_ipi_probe, - .priv_auto_alloc_size = sizeof(struct zynqmp_ipi), + .priv_auto = sizeof(struct zynqmp_ipi), .ops = &zynqmp_ipi_mbox_ops, }; diff --git a/drivers/memory/stm32-fmc2-ebi.c b/drivers/memory/stm32-fmc2-ebi.c index d887a1e09d..f3f48f8b38 100644 --- a/drivers/memory/stm32-fmc2-ebi.c +++ b/drivers/memory/stm32-fmc2-ebi.c @@ -1051,6 +1051,6 @@ U_BOOT_DRIVER(stm32_fmc2_ebi) = { .id = UCLASS_NOP, .of_match = stm32_fmc2_ebi_match, .probe = stm32_fmc2_ebi_probe, - .priv_auto_alloc_size = sizeof(struct stm32_fmc2_ebi), + .priv_auto = sizeof(struct stm32_fmc2_ebi), .bind = dm_scan_fdt_dev, }; diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 29432ae7eb..7d2a299779 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -343,6 +343,15 @@ config TEGRA186_BPMP can make requests to the BPMP. This driver is similar to an MFD driver in the Linux kernel. +config TEST_DRV + bool "Enable support for test drivers" + default y if SANDBOX + help + This enables drivers and uclasses that provides a way of testing the + operations of memory allocation and driver/uclass methods in driver + model. This should only be enabled for testing as it is not useful for + anything else. + config TWL4030_LED bool "Enable TWL4030 LED controller" help diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 947bd3a647..d737203704 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -67,6 +67,7 @@ obj-$(CONFIG_STM32_RCC) += stm32_rcc.o obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o obj-$(CONFIG_TEGRA186_BPMP) += tegra186_bpmp.o obj-$(CONFIG_TEGRA_CAR) += tegra_car.o +obj-$(CONFIG_TEST_DRV) += test_drv.o obj-$(CONFIG_TWL4030_LED) += twl4030_led.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress_config.o obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o diff --git a/drivers/misc/altera_sysid.c b/drivers/misc/altera_sysid.c index c6502650b7..878df12771 100644 --- a/drivers/misc/altera_sysid.c +++ b/drivers/misc/altera_sysid.c @@ -17,7 +17,7 @@ struct altera_sysid_regs { u32 timestamp; /* Timestamp */ }; -struct altera_sysid_platdata { +struct altera_sysid_plat { struct altera_sysid_regs *regs; }; @@ -59,7 +59,7 @@ U_BOOT_CMD( static int altera_sysid_read(struct udevice *dev, int offset, void *buf, int size) { - struct altera_sysid_platdata *plat = dev->platdata; + struct altera_sysid_plat *plat = dev_get_plat(dev); struct altera_sysid_regs *const regs = plat->regs; u32 *sysid = buf; @@ -69,9 +69,9 @@ static int altera_sysid_read(struct udevice *dev, return 0; } -static int altera_sysid_ofdata_to_platdata(struct udevice *dev) +static int altera_sysid_of_to_plat(struct udevice *dev) { - struct altera_sysid_platdata *plat = dev_get_platdata(dev); + struct altera_sysid_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_sysid_regs), @@ -93,7 +93,7 @@ U_BOOT_DRIVER(altera_sysid) = { .name = "altera_sysid", .id = UCLASS_MISC, .of_match = altera_sysid_ids, - .ofdata_to_platdata = altera_sysid_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_sysid_platdata), + .of_to_plat = altera_sysid_of_to_plat, + .plat_auto = sizeof(struct altera_sysid_plat), .ops = &altera_sysid_ops, }; diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c index 422ea6f3e5..90f9cd246a 100644 --- a/drivers/misc/atsha204a-i2c.c +++ b/drivers/misc/atsha204a-i2c.c @@ -382,7 +382,7 @@ int atsha204a_get_random(struct udevice *dev, u8 *buffer, size_t max) return 0; } -static int atsha204a_ofdata_to_platdata(struct udevice *dev) +static int atsha204a_of_to_plat(struct udevice *dev) { fdt_addr_t *priv = dev_get_priv(dev); fdt_addr_t addr; @@ -406,6 +406,6 @@ U_BOOT_DRIVER(atsha204) = { .name = "atsha204", .id = UCLASS_MISC, .of_match = atsha204a_ids, - .ofdata_to_platdata = atsha204a_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(fdt_addr_t), + .of_to_plat = atsha204a_of_to_plat, + .priv_auto = sizeof(fdt_addr_t), }; diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 1b22f1883e..f03b7d55d6 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -1505,7 +1505,7 @@ int cros_ec_set_lid_shutdown_mask(struct udevice *dev, int enable) UCLASS_DRIVER(cros_ec) = { .id = UCLASS_CROS_EC, .name = "cros-ec", - .per_device_auto_alloc_size = sizeof(struct cros_ec_dev), + .per_device_auto = sizeof(struct cros_ec_dev), .post_bind = dm_scan_fdt_dev, .flags = DM_UC_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/misc/cros_ec_i2c.c b/drivers/misc/cros_ec_i2c.c index 664bd2b938..a1b78a3045 100644 --- a/drivers/misc/cros_ec_i2c.c +++ b/drivers/misc/cros_ec_i2c.c @@ -52,7 +52,7 @@ struct ec_host_response_i2c { static int cros_ec_i2c_packet(struct udevice *udev, int out_bytes, int in_bytes) { struct cros_ec_dev *dev = dev_get_uclass_priv(udev); - struct dm_i2c_chip *chip = dev_get_parent_platdata(udev); + struct dm_i2c_chip *chip = dev_get_parent_plat(udev); struct ec_host_request_i2c *ec_request_i2c = (struct ec_host_request_i2c *)dev->dout; struct ec_host_response_i2c *ec_response_i2c = @@ -112,7 +112,7 @@ static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd, int dout_len, uint8_t **dinp, int din_len) { struct cros_ec_dev *dev = dev_get_uclass_priv(udev); - struct dm_i2c_chip *chip = dev_get_parent_platdata(udev); + struct dm_i2c_chip *chip = dev_get_parent_plat(udev); struct i2c_msg i2c_msg[2]; /* version8, cmd8, arglen8, out8[dout_len], csum8 */ int out_bytes = dout_len + 4; diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index d72db3eace..9fd6cc2086 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -520,8 +520,8 @@ void cros_ec_check_keyboard(struct udevice *dev) int cros_ec_probe(struct udevice *dev) { - struct ec_state *ec = dev->priv; - struct cros_ec_dev *cdev = dev->uclass_priv; + struct ec_state *ec = dev_get_priv(dev); + struct cros_ec_dev *cdev = dev_get_uclass_priv(dev); struct udevice *keyb_dev; ofnode node; int err; @@ -585,6 +585,6 @@ U_BOOT_DRIVER(google_cros_ec_sandbox) = { .id = UCLASS_CROS_EC, .of_match = cros_ec_ids, .probe = cros_ec_probe, - .priv_auto_alloc_size = sizeof(struct ec_state), + .priv_auto = sizeof(struct ec_state), .ops = &cros_ec_ops, }; diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c index 56406aa1dd..f460b1a64c 100644 --- a/drivers/misc/fs_loader.c +++ b/drivers/misc/fs_loader.c @@ -61,7 +61,7 @@ static int mount_ubifs(char *mtdpart, char *ubivol) } #endif -static int select_fs_dev(struct device_platdata *plat) +static int select_fs_dev(struct device_plat *plat) { int ret; @@ -161,7 +161,7 @@ static int fw_get_filesystem_firmware(struct udevice *dev) else ret = -ENODEV; } else { - ret = select_fs_dev(dev->platdata); + ret = select_fs_dev(dev_get_plat(dev)); } if (ret) @@ -219,16 +219,16 @@ int request_firmware_into_buf(struct udevice *dev, return ret; } -static int fs_loader_ofdata_to_platdata(struct udevice *dev) +static int fs_loader_of_to_plat(struct udevice *dev) { u32 phandlepart[2]; ofnode fs_loader_node = dev_ofnode(dev); if (ofnode_valid(fs_loader_node)) { - struct device_platdata *plat; + struct device_plat *plat; - plat = dev->platdata; + plat = dev_get_plat(dev); if (!ofnode_read_u32_array(fs_loader_node, "phandlepart", phandlepart, 2)) { @@ -250,7 +250,7 @@ static int fs_loader_probe(struct udevice *dev) { #if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(BLK) int ret; - struct device_platdata *plat = dev->platdata; + struct device_plat *plat = dev_get_plat(dev); if (plat->phandlepart.phandle) { ofnode node = ofnode_get_by_phandle(plat->phandlepart.phandle); @@ -284,9 +284,9 @@ U_BOOT_DRIVER(fs_loader) = { .id = UCLASS_FS_FIRMWARE_LOADER, .of_match = fs_loader_ids, .probe = fs_loader_probe, - .ofdata_to_platdata = fs_loader_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct device_platdata), - .priv_auto_alloc_size = sizeof(struct firmware), + .of_to_plat = fs_loader_of_to_plat, + .plat_auto = sizeof(struct device_plat), + .priv_auto = sizeof(struct firmware), }; UCLASS_DRIVER(fs_loader) = { diff --git a/drivers/misc/gdsys_ioep.c b/drivers/misc/gdsys_ioep.c index 69e16a06a0..145cfa23c6 100644 --- a/drivers/misc/gdsys_ioep.c +++ b/drivers/misc/gdsys_ioep.c @@ -206,5 +206,5 @@ U_BOOT_DRIVER(gdsys_ioep) = { .flags = DM_UC_FLAG_SEQ_ALIAS, .of_match = gdsys_ioep_ids, .probe = gdsys_ioep_probe, - .priv_auto_alloc_size = sizeof(struct gdsys_ioep_priv), + .priv_auto = sizeof(struct gdsys_ioep_priv), }; diff --git a/drivers/misc/gdsys_rxaui_ctrl.c b/drivers/misc/gdsys_rxaui_ctrl.c index c56abce4d4..8f5cbe420f 100644 --- a/drivers/misc/gdsys_rxaui_ctrl.c +++ b/drivers/misc/gdsys_rxaui_ctrl.c @@ -77,5 +77,5 @@ U_BOOT_DRIVER(gdsys_rxaui_ctrl) = { .ops = &gdsys_rxaui_ctrl_ops, .of_match = gdsys_rxaui_ctrl_ids, .probe = gdsys_rxaui_ctrl_probe, - .priv_auto_alloc_size = sizeof(struct gdsys_rxaui_ctrl_priv), + .priv_auto = sizeof(struct gdsys_rxaui_ctrl_priv), }; diff --git a/drivers/misc/gdsys_soc.c b/drivers/misc/gdsys_soc.c index b4c721c6fe..27e7dc4832 100644 --- a/drivers/misc/gdsys_soc.c +++ b/drivers/misc/gdsys_soc.c @@ -71,5 +71,5 @@ U_BOOT_DRIVER(gdsys_soc_bus) = { .id = UCLASS_SIMPLE_BUS, .of_match = gdsys_soc_ids, .probe = gdsys_soc_probe, - .priv_auto_alloc_size = sizeof(struct gdsys_soc_priv), + .priv_auto = sizeof(struct gdsys_soc_priv), }; diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c index 3651ba4871..5926c91a2e 100644 --- a/drivers/misc/i2c_eeprom.c +++ b/drivers/misc/i2c_eeprom.c @@ -93,7 +93,7 @@ static const struct i2c_eeprom_ops i2c_eeprom_std_ops = { .size = i2c_eeprom_std_size, }; -static int i2c_eeprom_std_ofdata_to_platdata(struct udevice *dev) +static int i2c_eeprom_std_of_to_plat(struct udevice *dev) { struct i2c_eeprom *priv = dev_get_priv(dev); struct i2c_eeprom_drv_data *data = @@ -131,8 +131,8 @@ static int i2c_eeprom_std_bind(struct udevice *dev) if (!name) continue; - device_bind_ofnode(dev, DM_GET_DRIVER(i2c_eeprom_partition), - name, NULL, partition, NULL); + device_bind(dev, DM_DRIVER_GET(i2c_eeprom_partition), name, + NULL, partition, NULL); } return 0; @@ -283,8 +283,8 @@ U_BOOT_DRIVER(i2c_eeprom_std) = { .of_match = i2c_eeprom_std_ids, .bind = i2c_eeprom_std_bind, .probe = i2c_eeprom_std_probe, - .ofdata_to_platdata = i2c_eeprom_std_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct i2c_eeprom), + .of_to_plat = i2c_eeprom_std_of_to_plat, + .priv_auto = sizeof(struct i2c_eeprom), .ops = &i2c_eeprom_std_ops, }; @@ -298,7 +298,7 @@ static int i2c_eeprom_partition_probe(struct udevice *dev) return 0; } -static int i2c_eeprom_partition_ofdata_to_platdata(struct udevice *dev) +static int i2c_eeprom_partition_of_to_plat(struct udevice *dev) { struct i2c_eeprom_partition *priv = dev_get_priv(dev); u32 reg[2]; @@ -365,8 +365,8 @@ U_BOOT_DRIVER(i2c_eeprom_partition) = { .name = "i2c_eeprom_partition", .id = UCLASS_I2C_EEPROM, .probe = i2c_eeprom_partition_probe, - .ofdata_to_platdata = i2c_eeprom_partition_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct i2c_eeprom_partition), + .of_to_plat = i2c_eeprom_partition_of_to_plat, + .priv_auto = sizeof(struct i2c_eeprom_partition), .ops = &i2c_eeprom_partition_ops, }; diff --git a/drivers/misc/i2c_eeprom_emul.c b/drivers/misc/i2c_eeprom_emul.c index 6be76ad02e..85b127c406 100644 --- a/drivers/misc/i2c_eeprom_emul.c +++ b/drivers/misc/i2c_eeprom_emul.c @@ -36,14 +36,14 @@ struct sandbox_i2c_flash { void sandbox_i2c_eeprom_set_test_mode(struct udevice *dev, enum sandbox_i2c_eeprom_test_mode mode) { - struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_flash_plat_data *plat = dev_get_plat(dev); plat->test_mode = mode; } void sandbox_i2c_eeprom_set_offset_len(struct udevice *dev, int offset_len) { - struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_flash_plat_data *plat = dev_get_plat(dev); plat->offset_len = offset_len; } @@ -51,7 +51,7 @@ void sandbox_i2c_eeprom_set_offset_len(struct udevice *dev, int offset_len) void sandbox_i2c_eeprom_set_chip_addr_offset_mask(struct udevice *dev, uint mask) { - struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_flash_plat_data *plat = dev_get_plat(dev); plat->chip_addr_offset_mask = mask; } @@ -74,7 +74,7 @@ static int sandbox_i2c_eeprom_xfer(struct udevice *emul, struct i2c_msg *msg, int nmsgs) { struct sandbox_i2c_flash *priv = dev_get_priv(emul); - struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_flash_plat_data *plat = dev_get_plat(emul); uint offset = msg->addr & plat->chip_addr_offset_mask; debug("\n%s\n", __func__); @@ -149,9 +149,9 @@ struct dm_i2c_ops sandbox_i2c_emul_ops = { .xfer = sandbox_i2c_eeprom_xfer, }; -static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev) +static int sandbox_i2c_eeprom_of_to_plat(struct udevice *dev) { - struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_flash_plat_data *plat = dev_get_plat(dev); plat->size = dev_read_u32_default(dev, "sandbox,size", 32); plat->filename = dev_read_string(dev, "sandbox,filename"); @@ -169,7 +169,7 @@ static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev) static int sandbox_i2c_eeprom_probe(struct udevice *dev) { - struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_flash_plat_data *plat = dev_get_plat(dev); struct sandbox_i2c_flash *priv = dev_get_priv(dev); priv->data = calloc(1, plat->size); @@ -197,10 +197,10 @@ U_BOOT_DRIVER(sandbox_i2c_emul) = { .name = "sandbox_i2c_eeprom_emul", .id = UCLASS_I2C_EMUL, .of_match = sandbox_i2c_ids, - .ofdata_to_platdata = sandbox_i2c_eeprom_ofdata_to_platdata, + .of_to_plat = sandbox_i2c_eeprom_of_to_plat, .probe = sandbox_i2c_eeprom_probe, .remove = sandbox_i2c_eeprom_remove, - .priv_auto_alloc_size = sizeof(struct sandbox_i2c_flash), - .platdata_auto_alloc_size = sizeof(struct sandbox_i2c_flash_plat_data), + .priv_auto = sizeof(struct sandbox_i2c_flash), + .plat_auto = sizeof(struct sandbox_i2c_flash_plat_data), .ops = &sandbox_i2c_emul_ops, }; diff --git a/drivers/misc/ihs_fpga.c b/drivers/misc/ihs_fpga.c index 00d34a3adc..a0fece985d 100644 --- a/drivers/misc/ihs_fpga.c +++ b/drivers/misc/ihs_fpga.c @@ -866,5 +866,5 @@ U_BOOT_DRIVER(ihs_fpga_bus) = { .id = UCLASS_MISC, .of_match = ihs_fpga_ids, .probe = ihs_fpga_probe, - .priv_auto_alloc_size = sizeof(struct ihs_fpga_priv), + .priv_auto = sizeof(struct ihs_fpga_priv), }; diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c index 223aac8518..72a3473263 100644 --- a/drivers/misc/imx8/scu.c +++ b/drivers/misc/imx8/scu.c @@ -158,7 +158,7 @@ static int sc_ipc_write(struct mu_type *base, void *data) static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg, int tx_size, void *rx_msg, int rx_size) { - struct imx8_scu *plat = dev_get_platdata(dev); + struct imx8_scu *plat = dev_get_plat(dev); sc_err_t result; int ret; @@ -182,7 +182,7 @@ static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg, static int imx8_scu_probe(struct udevice *dev) { - struct imx8_scu *plat = dev_get_platdata(dev); + struct imx8_scu *plat = dev_get_plat(dev); fdt_addr_t addr; debug("%s(dev=%p) (plat=%p)\n", __func__, dev, plat); @@ -245,6 +245,6 @@ U_BOOT_DRIVER(imx8_scu) = { .bind = imx8_scu_bind, .remove = imx8_scu_remove, .ops = &imx8_scu_ops, - .platdata_auto_alloc_size = sizeof(struct imx8_scu), + .plat_auto = sizeof(struct imx8_scu), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/misc/irq_sandbox.c b/drivers/misc/irq_sandbox.c index a2511b32fc..1f7e62e661 100644 --- a/drivers/misc/irq_sandbox.c +++ b/drivers/misc/irq_sandbox.c @@ -108,5 +108,5 @@ U_BOOT_DRIVER(sandbox_irq_drv) = { .id = UCLASS_IRQ, .of_match = sandbox_irq_ids, .ops = &sandbox_irq_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_irq_priv), + .priv_auto = sizeof(struct sandbox_irq_priv), }; diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c index 408c89315a..840148d090 100644 --- a/drivers/misc/k3_avs.c +++ b/drivers/misc/k3_avs.c @@ -390,5 +390,5 @@ U_BOOT_DRIVER(k3_avs) = { .of_match = k3_avs_ids, .id = UCLASS_MISC, .probe = k3_avs_probe, - .priv_auto_alloc_size = sizeof(struct k3_avs_privdata), + .priv_auto = sizeof(struct k3_avs_privdata), }; diff --git a/drivers/misc/microchip_flexcom.c b/drivers/misc/microchip_flexcom.c index 64cc4ae7b6..e0a6f2d388 100644 --- a/drivers/misc/microchip_flexcom.c +++ b/drivers/misc/microchip_flexcom.c @@ -16,14 +16,14 @@ struct microchip_flexcom_regs { u32 cr; }; -struct microchip_flexcom_platdata { +struct microchip_flexcom_plat { struct microchip_flexcom_regs *regs; u32 flexcom_mode; }; -static int microchip_flexcom_ofdata_to_platdata(struct udevice *dev) +static int microchip_flexcom_of_to_plat(struct udevice *dev) { - struct microchip_flexcom_platdata *plat = dev_get_platdata(dev); + struct microchip_flexcom_plat *plat = dev_get_plat(dev); int ret; plat->regs = map_physmem(dev_read_addr(dev), @@ -61,6 +61,6 @@ U_BOOT_DRIVER(microchip_flexcom) = { .name = "microchip_flexcom", .id = UCLASS_MISC, .of_match = microchip_flexcom_ids, - .ofdata_to_platdata = microchip_flexcom_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct microchip_flexcom_platdata), + .of_to_plat = microchip_flexcom_of_to_plat, + .plat_auto = sizeof(struct microchip_flexcom_plat), }; diff --git a/drivers/misc/misc_sandbox.c b/drivers/misc/misc_sandbox.c index f7c5b2e25f..0e4292fd0a 100644 --- a/drivers/misc/misc_sandbox.c +++ b/drivers/misc/misc_sandbox.c @@ -129,5 +129,5 @@ U_BOOT_DRIVER(misc_sandbox) = { .ops = &misc_sandbox_ops, .of_match = misc_sandbox_ids, .probe = misc_sandbox_probe, - .priv_auto_alloc_size = sizeof(struct misc_sandbox_priv), + .priv_auto = sizeof(struct misc_sandbox_priv), }; diff --git a/drivers/misc/mpc83xx_serdes.c b/drivers/misc/mpc83xx_serdes.c index ab1e34e6f4..93c87e998c 100644 --- a/drivers/misc/mpc83xx_serdes.c +++ b/drivers/misc/mpc83xx_serdes.c @@ -183,5 +183,5 @@ U_BOOT_DRIVER(mpc83xx_serdes) = { .id = UCLASS_MISC, .of_match = mpc83xx_serdes_ids, .probe = mpc83xx_serdes_probe, - .priv_auto_alloc_size = sizeof(struct mpc83xx_serdes_priv), + .priv_auto = sizeof(struct mpc83xx_serdes_priv), }; diff --git a/drivers/misc/p2sb-uclass.c b/drivers/misc/p2sb-uclass.c index 12abcff2da..ac2852559f 100644 --- a/drivers/misc/p2sb-uclass.c +++ b/drivers/misc/p2sb-uclass.c @@ -30,7 +30,7 @@ int p2sb_set_hide(struct udevice *dev, bool hide) void *pcr_reg_address(struct udevice *dev, uint offset) { - struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); + struct p2sb_child_plat *pplat = dev_get_parent_plat(dev); struct udevice *p2sb = dev_get_parent(dev); struct p2sb_uc_priv *upriv = dev_get_uclass_priv(p2sb); uintptr_t reg_addr; @@ -161,34 +161,19 @@ void pcr_clrsetbits8(struct udevice *dev, uint offset, uint clr, uint set) int p2sb_get_port_id(struct udevice *dev) { - struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); + struct p2sb_child_plat *pplat = dev_get_parent_plat(dev); return pplat->pid; } int p2sb_set_port_id(struct udevice *dev, int portid) { - struct udevice *ps2b; - struct p2sb_child_platdata *pplat; + struct p2sb_child_plat *pplat; if (!CONFIG_IS_ENABLED(OF_PLATDATA)) return -ENOSYS; - if (!CONFIG_IS_ENABLED(OF_PLATDATA_PARENT)) { - uclass_find_first_device(UCLASS_P2SB, &ps2b); - if (!ps2b) - return -EDEADLK; - dev->parent = ps2b; - - /* - * We must allocate this, since when the device was bound it did - * not have a parent. - */ - dev->parent_platdata = malloc(sizeof(*pplat)); - if (!dev->parent_platdata) - return -ENOMEM; - } - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); pplat->pid = portid; return 0; @@ -197,7 +182,7 @@ int p2sb_set_port_id(struct udevice *dev, int portid) static int p2sb_child_post_bind(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); + struct p2sb_child_plat *pplat = dev_get_parent_plat(dev); int ret; u32 pid; @@ -221,9 +206,8 @@ static int p2sb_post_bind(struct udevice *dev) UCLASS_DRIVER(p2sb) = { .id = UCLASS_P2SB, .name = "p2sb", - .per_device_auto_alloc_size = sizeof(struct p2sb_uc_priv), + .per_device_auto = sizeof(struct p2sb_uc_priv), .post_bind = p2sb_post_bind, .child_post_bind = p2sb_child_post_bind, - .per_child_platdata_auto_alloc_size = - sizeof(struct p2sb_child_platdata), + .per_child_plat_auto = sizeof(struct p2sb_child_plat), }; diff --git a/drivers/misc/p2sb_emul.c b/drivers/misc/p2sb_emul.c index a4b6dba516..973d02d678 100644 --- a/drivers/misc/p2sb_emul.c +++ b/drivers/misc/p2sb_emul.c @@ -18,12 +18,12 @@ #include <p2sb.h> /** - * struct p2sb_emul_platdata - platform data for this device + * struct p2sb_emul_plat - platform data for this device * * @command: Current PCI command value * @bar: Current base address values */ -struct p2sb_emul_platdata { +struct p2sb_emul_plat { u16 command; u32 bar[6]; }; @@ -53,7 +53,7 @@ static int sandbox_p2sb_emul_read_config(const struct udevice *emul, uint offset, ulong *valuep, enum pci_size_t size) { - struct p2sb_emul_platdata *plat = dev_get_platdata(emul); + struct p2sb_emul_plat *plat = dev_get_plat(emul); switch (offset) { case PCI_COMMAND: @@ -106,7 +106,7 @@ static int sandbox_p2sb_emul_read_config(const struct udevice *emul, static int sandbox_p2sb_emul_write_config(struct udevice *emul, uint offset, ulong value, enum pci_size_t size) { - struct p2sb_emul_platdata *plat = dev_get_platdata(emul); + struct p2sb_emul_plat *plat = dev_get_plat(emul); switch (offset) { case PCI_COMMAND: @@ -134,7 +134,7 @@ static int sandbox_p2sb_emul_write_config(struct udevice *emul, uint offset, static int sandbox_p2sb_emul_find_bar(struct udevice *emul, unsigned int addr, int *barnump, unsigned int *offsetp) { - struct p2sb_emul_platdata *plat = dev_get_platdata(emul); + struct p2sb_emul_plat *plat = dev_get_plat(emul); int barnum; for (barnum = 0; barnum < ARRAY_SIZE(barinfo); barnum++) { @@ -197,8 +197,8 @@ static int find_p2sb_channel(struct udevice *emul, uint offset, return log_msg_ret("No client", ret); device_foreach_child(dev, p2sb) { - struct p2sb_child_platdata *pplat = - dev_get_parent_platdata(dev); + struct p2sb_child_plat *pplat = + dev_get_parent_plat(dev); log_debug(" - child %s, pid %d, want %d\n", dev->name, pplat->pid, pid); @@ -262,8 +262,8 @@ U_BOOT_DRIVER(sandbox_p2sb_emul_emul) = { .id = UCLASS_PCI_EMUL, .of_match = sandbox_p2sb_emul_ids, .ops = &sandbox_p2sb_emul_emul_ops, - .priv_auto_alloc_size = sizeof(struct p2sb_emul_priv), - .platdata_auto_alloc_size = sizeof(struct p2sb_emul_platdata), + .priv_auto = sizeof(struct p2sb_emul_priv), + .plat_auto = sizeof(struct p2sb_emul_plat), }; static struct pci_device_id sandbox_p2sb_emul_supported[] = { diff --git a/drivers/misc/p2sb_sandbox.c b/drivers/misc/p2sb_sandbox.c index ce50a9732e..d80bca22a6 100644 --- a/drivers/misc/p2sb_sandbox.c +++ b/drivers/misc/p2sb_sandbox.c @@ -35,5 +35,5 @@ U_BOOT_DRIVER(p2sb_sandbox) = { .id = UCLASS_P2SB, .of_match = sandbox_p2sb_ids, .probe = sandbox_p2sb_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_p2sb_priv), + .priv_auto = sizeof(struct sandbox_p2sb_priv), }; diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c index 46ce6305fe..083ee65e0a 100644 --- a/drivers/misc/rockchip-efuse.c +++ b/drivers/misc/rockchip-efuse.c @@ -37,7 +37,7 @@ struct rockchip_efuse_regs { /* 0x14 efuse strobe finish control register */ }; -struct rockchip_efuse_platdata { +struct rockchip_efuse_plat { void __iomem *base; struct clk *clk; }; @@ -58,7 +58,7 @@ static int dump_efuses(struct cmd_tbl *cmdtp, int flag, /* retrieve the device */ ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(rockchip_efuse), &dev); + DM_DRIVER_GET(rockchip_efuse), &dev); if (ret) { printf("%s: no misc-device found\n", __func__); return 0; @@ -86,7 +86,7 @@ U_BOOT_CMD( static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset, void *buf, int size) { - struct rockchip_efuse_platdata *plat = dev_get_platdata(dev); + struct rockchip_efuse_plat *plat = dev_get_plat(dev); struct rockchip_efuse_regs *efuse = (struct rockchip_efuse_regs *)plat->base; @@ -137,9 +137,9 @@ static const struct misc_ops rockchip_efuse_ops = { .read = rockchip_efuse_read, }; -static int rockchip_efuse_ofdata_to_platdata(struct udevice *dev) +static int rockchip_efuse_of_to_plat(struct udevice *dev) { - struct rockchip_efuse_platdata *plat = dev_get_platdata(dev); + struct rockchip_efuse_plat *plat = dev_get_plat(dev); plat->base = dev_read_addr_ptr(dev); return 0; @@ -154,7 +154,7 @@ U_BOOT_DRIVER(rockchip_efuse) = { .name = "rockchip_efuse", .id = UCLASS_MISC, .of_match = rockchip_efuse_ids, - .ofdata_to_platdata = rockchip_efuse_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct rockchip_efuse_platdata), + .of_to_plat = rockchip_efuse_of_to_plat, + .plat_auto = sizeof(struct rockchip_efuse_plat), .ops = &rockchip_efuse_ops, }; diff --git a/drivers/misc/rockchip-otp.c b/drivers/misc/rockchip-otp.c index bdd443b3db..cc9a5450e0 100644 --- a/drivers/misc/rockchip-otp.c +++ b/drivers/misc/rockchip-otp.c @@ -47,13 +47,13 @@ #define OTPC_TIMEOUT 10000 -struct rockchip_otp_platdata { +struct rockchip_otp_plat { void __iomem *base; unsigned long secure_conf_base; unsigned long otp_mask_base; }; -static int rockchip_otp_wait_status(struct rockchip_otp_platdata *otp, +static int rockchip_otp_wait_status(struct rockchip_otp_plat *otp, u32 flag) { int delay = OTPC_TIMEOUT; @@ -73,7 +73,7 @@ static int rockchip_otp_wait_status(struct rockchip_otp_platdata *otp, return 0; } -static int rockchip_otp_ecc_enable(struct rockchip_otp_platdata *otp, +static int rockchip_otp_ecc_enable(struct rockchip_otp_plat *otp, bool enable) { int ret = 0; @@ -102,7 +102,7 @@ static int rockchip_otp_ecc_enable(struct rockchip_otp_platdata *otp, static int rockchip_px30_otp_read(struct udevice *dev, int offset, void *buf, int size) { - struct rockchip_otp_platdata *otp = dev_get_platdata(dev); + struct rockchip_otp_plat *otp = dev_get_plat(dev); u8 *buffer = buf; int ret = 0; @@ -145,9 +145,9 @@ static const struct misc_ops rockchip_otp_ops = { .read = rockchip_otp_read, }; -static int rockchip_otp_ofdata_to_platdata(struct udevice *dev) +static int rockchip_otp_of_to_plat(struct udevice *dev) { - struct rockchip_otp_platdata *otp = dev_get_platdata(dev); + struct rockchip_otp_plat *otp = dev_get_plat(dev); otp->base = dev_read_addr_ptr(dev); @@ -171,6 +171,6 @@ U_BOOT_DRIVER(rockchip_otp) = { .id = UCLASS_MISC, .of_match = rockchip_otp_ids, .ops = &rockchip_otp_ops, - .ofdata_to_platdata = rockchip_otp_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct rockchip_otp_platdata), + .of_to_plat = rockchip_otp_of_to_plat, + .plat_auto = sizeof(struct rockchip_otp_plat), }; diff --git a/drivers/misc/sandbox_adder.c b/drivers/misc/sandbox_adder.c index df262e6255..3ea33e46e9 100644 --- a/drivers/misc/sandbox_adder.c +++ b/drivers/misc/sandbox_adder.c @@ -21,7 +21,7 @@ struct sandbox_adder_priv { int sandbox_adder_read(struct udevice *dev, ulong address, void *data, enum axi_size_t size) { - struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); + struct p2sb_child_plat *pplat = dev_get_parent_plat(dev); u32 *val = data; *val = pplat->pid << 24 | address; @@ -56,5 +56,5 @@ U_BOOT_DRIVER(adder_sandbox) = { .of_match = sandbox_adder_ids, .probe = sandbox_adder_probe, .ops = &sandbox_adder_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_adder_priv), + .priv_auto = sizeof(struct sandbox_adder_priv), }; diff --git a/drivers/misc/sifive-otp.c b/drivers/misc/sifive-otp.c index 92f08dde01..3e658b3566 100644 --- a/drivers/misc/sifive-otp.c +++ b/drivers/misc/sifive-otp.c @@ -89,7 +89,7 @@ struct sifive_otp_regs { u32 pwe; /* Write enable input (defines program cycle) */ }; -struct sifive_otp_platdata { +struct sifive_otp_plat { struct sifive_otp_regs __iomem *regs; u32 total_fuses; }; @@ -100,7 +100,7 @@ struct sifive_otp_platdata { static int sifive_otp_read(struct udevice *dev, int offset, void *buf, int size) { - struct sifive_otp_platdata *plat = dev_get_platdata(dev); + struct sifive_otp_plat *plat = dev_get_plat(dev); struct sifive_otp_regs *regs = (struct sifive_otp_regs *)plat->regs; /* Check if offset and size are multiple of BYTES_PER_FUSE */ @@ -162,7 +162,7 @@ static int sifive_otp_read(struct udevice *dev, int offset, static int sifive_otp_write(struct udevice *dev, int offset, const void *buf, int size) { - struct sifive_otp_platdata *plat = dev_get_platdata(dev); + struct sifive_otp_plat *plat = dev_get_plat(dev); struct sifive_otp_regs *regs = (struct sifive_otp_regs *)plat->regs; /* Check if offset and size are multiple of BYTES_PER_FUSE */ @@ -239,9 +239,9 @@ static int sifive_otp_write(struct udevice *dev, int offset, return size; } -static int sifive_otp_ofdata_to_platdata(struct udevice *dev) +static int sifive_otp_of_to_plat(struct udevice *dev) { - struct sifive_otp_platdata *plat = dev_get_platdata(dev); + struct sifive_otp_plat *plat = dev_get_plat(dev); int ret; plat->regs = dev_read_addr_ptr(dev); @@ -269,7 +269,7 @@ U_BOOT_DRIVER(sifive_otp) = { .name = "sifive_otp", .id = UCLASS_MISC, .of_match = sifive_otp_ids, - .ofdata_to_platdata = sifive_otp_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct sifive_otp_platdata), + .of_to_plat = sifive_otp_of_to_plat, + .plat_auto = sizeof(struct sifive_otp_plat), .ops = &sifive_otp_ops, }; diff --git a/drivers/misc/spltest_sandbox.c b/drivers/misc/spltest_sandbox.c index 3ae6707593..6b9701a06a 100644 --- a/drivers/misc/spltest_sandbox.c +++ b/drivers/misc/spltest_sandbox.c @@ -8,8 +8,14 @@ #include <dm.h> #include <dt-structs.h> +static const struct udevice_id sandbox_spl_ids[] = { + { .compatible = "sandbox,spl-test", }, + {} /* sentinel */ +}; + U_BOOT_DRIVER(sandbox_spl_test) = { .name = "sandbox_spl_test", .id = UCLASS_MISC, + .of_match = sandbox_spl_ids, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/misc/stm32mp_fuse.c b/drivers/misc/stm32mp_fuse.c index 0eed345973..9fd6c367dc 100644 --- a/drivers/misc/stm32mp_fuse.c +++ b/drivers/misc/stm32mp_fuse.c @@ -26,7 +26,7 @@ int fuse_read(u32 bank, u32 word, u32 *val) switch (bank) { case STM32MP_OTP_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) return ret; @@ -41,7 +41,7 @@ int fuse_read(u32 bank, u32 word, u32 *val) #ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; @@ -71,7 +71,7 @@ int fuse_prog(u32 bank, u32 word, u32 val) switch (bank) { case STM32MP_OTP_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) return ret; @@ -86,7 +86,7 @@ int fuse_prog(u32 bank, u32 word, u32 val) #ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; @@ -115,7 +115,7 @@ int fuse_sense(u32 bank, u32 word, u32 *val) switch (bank) { case STM32MP_OTP_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) return ret; @@ -129,7 +129,7 @@ int fuse_sense(u32 bank, u32 word, u32 *val) #ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; @@ -159,7 +159,7 @@ int fuse_override(u32 bank, u32 word, u32 val) switch (bank) { case STM32MP_OTP_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stm32mp_bsec), + DM_DRIVER_GET(stm32mp_bsec), &dev); if (ret) return ret; @@ -174,7 +174,7 @@ int fuse_override(u32 bank, u32 word, u32 val) #ifdef CONFIG_PMIC_STPMIC1 case STM32MP_NVM_BANK: ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(stpmic1_nvm), + DM_DRIVER_GET(stpmic1_nvm), &dev); if (ret) return ret; diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c index 07c67577d5..3cbc8f37ec 100644 --- a/drivers/misc/swap_case.c +++ b/drivers/misc/swap_case.c @@ -15,12 +15,12 @@ #include <linux/ctype.h> /** - * struct swap_case_platdata - platform data for this device + * struct swap_case_plat - platform data for this device * * @command: Current PCI command value * @bar: Current base address values */ -struct swap_case_platdata { +struct swap_case_plat { u16 command; u32 bar[6]; }; @@ -54,7 +54,7 @@ struct swap_case_priv { static int sandbox_swap_case_use_ea(const struct udevice *dev) { - return !!ofnode_get_property(dev->node, "use-ea", NULL); + return !!ofnode_get_property(dev_ofnode(dev), "use-ea", NULL); } /* Please keep these macros in sync with ea_regs below */ @@ -100,7 +100,7 @@ static int sandbox_swap_case_read_config(const struct udevice *emul, uint offset, ulong *valuep, enum pci_size_t size) { - struct swap_case_platdata *plat = dev_get_platdata(emul); + struct swap_case_plat *plat = dev_get_plat(emul); /* * The content of the EA capability structure is handled elsewhere to @@ -200,7 +200,7 @@ static int sandbox_swap_case_read_config(const struct udevice *emul, static int sandbox_swap_case_write_config(struct udevice *emul, uint offset, ulong value, enum pci_size_t size) { - struct swap_case_platdata *plat = dev_get_platdata(emul); + struct swap_case_plat *plat = dev_get_plat(emul); switch (offset) { case PCI_COMMAND: @@ -228,7 +228,7 @@ static int sandbox_swap_case_write_config(struct udevice *emul, uint offset, static int sandbox_swap_case_find_bar(struct udevice *emul, unsigned int addr, int *barnump, unsigned int *offsetp) { - struct swap_case_platdata *plat = dev_get_platdata(emul); + struct swap_case_plat *plat = dev_get_plat(emul); int barnum; for (barnum = 0; barnum < ARRAY_SIZE(barinfo); barnum++) { @@ -391,8 +391,8 @@ U_BOOT_DRIVER(sandbox_swap_case_emul) = { .id = UCLASS_PCI_EMUL, .of_match = sandbox_swap_case_ids, .ops = &sandbox_swap_case_emul_ops, - .priv_auto_alloc_size = sizeof(struct swap_case_priv), - .platdata_auto_alloc_size = sizeof(struct swap_case_platdata), + .priv_auto = sizeof(struct swap_case_priv), + .plat_auto = sizeof(struct swap_case_plat), }; static struct pci_device_id sandbox_swap_case_supported[] = { diff --git a/drivers/misc/tegra186_bpmp.c b/drivers/misc/tegra186_bpmp.c index 18da138507..f2366d6592 100644 --- a/drivers/misc/tegra186_bpmp.c +++ b/drivers/misc/tegra186_bpmp.c @@ -257,5 +257,5 @@ U_BOOT_DRIVER(tegra186_bpmp) = { .probe = tegra186_bpmp_probe, .remove = tegra186_bpmp_remove, .ops = &tegra186_bpmp_ops, - .priv_auto_alloc_size = sizeof(struct tegra186_bpmp), + .priv_auto = sizeof(struct tegra186_bpmp), }; diff --git a/drivers/misc/test_drv.c b/drivers/misc/test_drv.c new file mode 100644 index 0000000000..7dd3de34c9 --- /dev/null +++ b/drivers/misc/test_drv.c @@ -0,0 +1,222 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2014 Google, Inc + */ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> + +/* Records the last testbus device that was removed */ +static struct udevice *testbus_removed; + +struct udevice *testbus_get_clear_removed(void) +{ + struct udevice *removed = testbus_removed; + + testbus_removed = NULL; + + return removed; +} + +static int testbus_drv_probe(struct udevice *dev) +{ + if (!CONFIG_IS_ENABLED(OF_PLATDATA)) { + int ret; + + ret = dm_scan_fdt_dev(dev); + if (ret) + return ret; + } + + return 0; +} + +static int testbus_child_post_bind(struct udevice *dev) +{ + struct dm_test_parent_plat *plat; + + plat = dev_get_parent_plat(dev); + plat->bind_flag = 1; + plat->uclass_bind_flag = 2; + + return 0; +} + +static int testbus_child_pre_probe(struct udevice *dev) +{ + struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev); + + parent_data->flag += TEST_FLAG_CHILD_PROBED; + + return 0; +} + +static int testbus_child_pre_probe_uclass(struct udevice *dev) +{ + struct dm_test_priv *priv = dev_get_priv(dev); + + priv->uclass_flag++; + + return 0; +} + +static int testbus_child_post_probe_uclass(struct udevice *dev) +{ + struct dm_test_priv *priv = dev_get_priv(dev); + + priv->uclass_postp++; + + return 0; +} + +static int testbus_child_post_remove(struct udevice *dev) +{ + struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev); + + parent_data->flag += TEST_FLAG_CHILD_REMOVED; + testbus_removed = dev; + + return 0; +} + +static const struct udevice_id testbus_ids[] = { + { .compatible = "denx,u-boot-test-bus", .data = DM_TEST_TYPE_FIRST }, + { } +}; + +U_BOOT_DRIVER(testbus_drv) = { + .name = "testbus_drv", + .of_match = testbus_ids, + .id = UCLASS_TEST_BUS, + .probe = testbus_drv_probe, + .child_post_bind = testbus_child_post_bind, + .priv_auto = sizeof(struct dm_test_priv), + .plat_auto = sizeof(struct dm_test_pdata), + .per_child_auto = sizeof(struct dm_test_parent_data), + .per_child_plat_auto = sizeof(struct dm_test_parent_plat), + .child_pre_probe = testbus_child_pre_probe, + .child_post_remove = testbus_child_post_remove, +}; + +UCLASS_DRIVER(testbus) = { + .name = "testbus", + .id = UCLASS_TEST_BUS, + .flags = DM_UC_FLAG_SEQ_ALIAS, + .child_pre_probe = testbus_child_pre_probe_uclass, + .child_post_probe = testbus_child_post_probe_uclass, +}; + +static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret) +{ + const struct dm_test_pdata *pdata = dev_get_plat(dev); + struct dm_test_priv *priv = dev_get_priv(dev); + + *pingret = pingval + pdata->ping_add; + priv->ping_total += *pingret; + + return 0; +} + +static const struct test_ops test_ops = { + .ping = testfdt_drv_ping, +}; + +static int testfdt_of_to_plat(struct udevice *dev) +{ + struct dm_test_pdata *pdata = dev_get_plat(dev); + + pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), + "ping-add", -1); + pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), + "ping-expect"); + + return 0; +} + +static int testfdt_drv_probe(struct udevice *dev) +{ + struct dm_test_priv *priv = dev_get_priv(dev); + + priv->ping_total += DM_TEST_START_TOTAL; + + /* + * If this device is on a bus, the uclass_flag will be set before + * calling this function. In the meantime the uclass_postp is + * initlized to a value -1. These are used respectively by + * dm_test_bus_child_pre_probe_uclass() and + * dm_test_bus_child_post_probe_uclass(). + */ + priv->uclass_total += priv->uclass_flag; + priv->uclass_postp = -1; + + return 0; +} + +static const struct udevice_id testfdt_ids[] = { + { .compatible = "denx,u-boot-fdt-test", .data = DM_TEST_TYPE_FIRST }, + { .compatible = "google,another-fdt-test", .data = DM_TEST_TYPE_SECOND }, + { } +}; + +U_BOOT_DRIVER(testfdt_drv) = { + .name = "testfdt_drv", + .of_match = testfdt_ids, + .id = UCLASS_TEST_FDT, + .of_to_plat = testfdt_of_to_plat, + .probe = testfdt_drv_probe, + .ops = &test_ops, + .priv_auto = sizeof(struct dm_test_priv), + .plat_auto = sizeof(struct dm_test_pdata), +}; + +static const struct udevice_id testfdt1_ids[] = { + { .compatible = "denx,u-boot-fdt-test1", .data = DM_TEST_TYPE_FIRST }, + { } +}; + +U_BOOT_DRIVER(testfdt1_drv) = { + .name = "testfdt1_drv", + .of_match = testfdt1_ids, + .id = UCLASS_TEST_FDT, + .of_to_plat = testfdt_of_to_plat, + .probe = testfdt_drv_probe, + .ops = &test_ops, + .priv_auto = sizeof(struct dm_test_priv), + .plat_auto = sizeof(struct dm_test_pdata), + .flags = DM_FLAG_PRE_RELOC, +}; + +/* From here is the testfdt uclass code */ +int testfdt_ping(struct udevice *dev, int pingval, int *pingret) +{ + const struct test_ops *ops = device_get_ops(dev); + + if (!ops->ping) + return -ENOSYS; + + return ops->ping(dev, pingval, pingret); +} + +UCLASS_DRIVER(testfdt) = { + .name = "testfdt", + .id = UCLASS_TEST_FDT, + .flags = DM_UC_FLAG_SEQ_ALIAS, +}; + +static const struct udevice_id testfdtm_ids[] = { + { .compatible = "denx,u-boot-fdtm-test" }, + { } +}; + +U_BOOT_DRIVER(testfdtm_drv) = { + .name = "testfdtm_drv", + .of_match = testfdtm_ids, + .id = UCLASS_TEST_FDT_MANUAL, +}; + +UCLASS_DRIVER(testfdtm) = { + .name = "testfdtm", + .id = UCLASS_TEST_FDT_MANUAL, + .flags = DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ, +}; diff --git a/drivers/misc/vexpress_config.c b/drivers/misc/vexpress_config.c index 02e5b586e2..2baca48109 100644 --- a/drivers/misc/vexpress_config.c +++ b/drivers/misc/vexpress_config.c @@ -109,7 +109,7 @@ static int vexpress_config_probe(struct udevice *dev) if (!priv) return -ENOMEM; - dev->uclass_priv = priv; + dev_get_uclass_priv(dev) = priv; priv->addr = ofnode_get_addr(args.node); return dev_read_u32(dev, "arm,vexpress,site", &priv->site); diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c index 82abf484e4..baa935e0d5 100644 --- a/drivers/mmc/am654_sdhci.c +++ b/drivers/mmc/am654_sdhci.c @@ -129,7 +129,7 @@ static void am654_sdhci_set_control_reg(struct sdhci_host *host) static int am654_sdhci_set_ios_post(struct sdhci_host *host) { struct udevice *dev = host->mmc->dev; - struct am654_sdhci_plat *plat = dev_get_platdata(dev); + struct am654_sdhci_plat *plat = dev_get_plat(dev); unsigned int speed = host->mmc->clock; int sel50, sel100, freqsel; u32 otap_del_sel; @@ -269,7 +269,7 @@ int am654_sdhci_init(struct am654_sdhci_plat *plat) static int am654_sdhci_deferred_probe(struct sdhci_host *host) { struct udevice *dev = host->mmc->dev; - struct am654_sdhci_plat *plat = dev_get_platdata(dev); + struct am654_sdhci_plat *plat = dev_get_plat(dev); unsigned long start; int val; @@ -311,7 +311,7 @@ const struct am654_driver_data j721e_8bit_drv_data = { static int j721e_4bit_sdhci_set_ios_post(struct sdhci_host *host) { struct udevice *dev = host->mmc->dev; - struct am654_sdhci_plat *plat = dev_get_platdata(dev); + struct am654_sdhci_plat *plat = dev_get_plat(dev); u32 otap_del_sel, mask, val; otap_del_sel = plat->otap_del_sel[host->mmc->selected_mode]; @@ -335,7 +335,7 @@ const struct am654_driver_data j721e_4bit_drv_data = { static int sdhci_am654_get_otap_delay(struct udevice *dev, struct mmc_config *cfg) { - struct am654_sdhci_plat *plat = dev_get_platdata(dev); + struct am654_sdhci_plat *plat = dev_get_plat(dev); int ret; int i; @@ -367,7 +367,7 @@ static int am654_sdhci_probe(struct udevice *dev) { struct am654_driver_data *drv_data = (struct am654_driver_data *)dev_get_driver_data(dev); - struct am654_sdhci_plat *plat = dev_get_platdata(dev); + struct am654_sdhci_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct sdhci_host *host = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; @@ -408,9 +408,9 @@ static int am654_sdhci_probe(struct udevice *dev) return 0; } -static int am654_sdhci_ofdata_to_platdata(struct udevice *dev) +static int am654_sdhci_of_to_plat(struct udevice *dev) { - struct am654_sdhci_plat *plat = dev_get_platdata(dev); + struct am654_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; u32 drv_strength; @@ -463,7 +463,7 @@ static int am654_sdhci_bind(struct udevice *dev) { struct am654_driver_data *drv_data = (struct am654_driver_data *)dev_get_driver_data(dev); - struct am654_sdhci_plat *plat = dev_get_platdata(dev); + struct am654_sdhci_plat *plat = dev_get_plat(dev); plat->flags = drv_data->flags; @@ -490,10 +490,10 @@ U_BOOT_DRIVER(am654_sdhci_drv) = { .name = "am654_sdhci", .id = UCLASS_MMC, .of_match = am654_sdhci_ids, - .ofdata_to_platdata = am654_sdhci_ofdata_to_platdata, + .of_to_plat = am654_sdhci_of_to_plat, .ops = &sdhci_ops, .bind = am654_sdhci_bind, .probe = am654_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct am654_sdhci_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct am654_sdhci_plat), }; diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c index 846622892a..b2d1b4f9aa 100644 --- a/drivers/mmc/arm_pl180_mmci.c +++ b/drivers/mmc/arm_pl180_mmci.c @@ -418,10 +418,10 @@ static void arm_pl180_mmc_init(struct pl180_mmc_host *host) static int arm_pl180_mmc_probe(struct udevice *dev) { - struct arm_pl180_mmc_plat *pdata = dev_get_platdata(dev); + struct arm_pl180_mmc_plat *pdata = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct mmc *mmc = &pdata->mmc; - struct pl180_mmc_host *host = dev->priv; + struct pl180_mmc_host *host = dev_get_priv(dev); struct mmc_config *cfg = &pdata->cfg; struct clk clk; u32 bus_width; @@ -486,7 +486,7 @@ static int arm_pl180_mmc_probe(struct udevice *dev) int arm_pl180_mmc_bind(struct udevice *dev) { - struct arm_pl180_mmc_plat *plat = dev_get_platdata(dev); + struct arm_pl180_mmc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -508,7 +508,7 @@ static int dm_host_set_ios(struct udevice *dev) static int dm_mmc_getcd(struct udevice *dev) { - struct pl180_mmc_host *host = dev->priv; + struct pl180_mmc_host *host = dev_get_priv(dev); int value = 1; if (dm_gpio_is_valid(&host->cd_gpio)) @@ -523,9 +523,9 @@ static const struct dm_mmc_ops arm_pl180_dm_mmc_ops = { .get_cd = dm_mmc_getcd, }; -static int arm_pl180_mmc_ofdata_to_platdata(struct udevice *dev) +static int arm_pl180_mmc_of_to_plat(struct udevice *dev) { - struct pl180_mmc_host *host = dev->priv; + struct pl180_mmc_host *host = dev_get_priv(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -549,9 +549,9 @@ U_BOOT_DRIVER(arm_pl180_mmc) = { .of_match = arm_pl180_mmc_match, .ops = &arm_pl180_dm_mmc_ops, .probe = arm_pl180_mmc_probe, - .ofdata_to_platdata = arm_pl180_mmc_ofdata_to_platdata, + .of_to_plat = arm_pl180_mmc_of_to_plat, .bind = arm_pl180_mmc_bind, - .priv_auto_alloc_size = sizeof(struct pl180_mmc_host), - .platdata_auto_alloc_size = sizeof(struct arm_pl180_mmc_plat), + .priv_auto = sizeof(struct pl180_mmc_host), + .plat_auto = sizeof(struct arm_pl180_mmc_plat), }; #endif diff --git a/drivers/mmc/aspeed_sdhci.c b/drivers/mmc/aspeed_sdhci.c index 543c65a8e3..4537315719 100644 --- a/drivers/mmc/aspeed_sdhci.c +++ b/drivers/mmc/aspeed_sdhci.c @@ -19,7 +19,7 @@ struct aspeed_sdhci_plat { static int aspeed_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct aspeed_sdhci_plat *plat = dev_get_platdata(dev); + struct aspeed_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); u32 max_clk; struct clk clk; @@ -67,7 +67,7 @@ free: static int aspeed_sdhci_bind(struct udevice *dev) { - struct aspeed_sdhci_plat *plat = dev_get_platdata(dev); + struct aspeed_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -86,6 +86,6 @@ U_BOOT_DRIVER(aspeed_sdhci_drv) = { .ops = &sdhci_ops, .bind = aspeed_sdhci_bind, .probe = aspeed_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct aspeed_sdhci_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct aspeed_sdhci_plat), }; diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c index ca7a98bf1d..d7dbc23fd0 100644 --- a/drivers/mmc/atmel_sdhci.c +++ b/drivers/mmc/atmel_sdhci.c @@ -54,7 +54,7 @@ struct atmel_sdhci_plat { static int atmel_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct atmel_sdhci_plat *plat = dev_get_platdata(dev); + struct atmel_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); u32 max_clk; struct clk clk; @@ -112,7 +112,7 @@ static int atmel_sdhci_probe(struct udevice *dev) static int atmel_sdhci_bind(struct udevice *dev) { - struct atmel_sdhci_plat *plat = dev_get_platdata(dev); + struct atmel_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -131,7 +131,7 @@ U_BOOT_DRIVER(atmel_sdhci_drv) = { .ops = &sdhci_ops, .bind = atmel_sdhci_bind, .probe = atmel_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct atmel_sdhci_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct atmel_sdhci_plat), }; #endif diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 7a410d1dd3..5e48394fd0 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -166,7 +166,7 @@ static const struct sdhci_ops bcm2835_ops = { static int bcm2835_sdhci_bind(struct udevice *dev) { - struct bcm2835_sdhci_plat *plat = dev_get_platdata(dev); + struct bcm2835_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -174,7 +174,7 @@ static int bcm2835_sdhci_bind(struct udevice *dev) static int bcm2835_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct bcm2835_sdhci_plat *plat = dev_get_platdata(dev); + struct bcm2835_sdhci_plat *plat = dev_get_plat(dev); struct bcm2835_sdhci_host *priv = dev_get_priv(dev); struct sdhci_host *host = &priv->host; fdt_addr_t base; @@ -250,7 +250,7 @@ U_BOOT_DRIVER(sdhci_cdns) = { .of_match = bcm2835_sdhci_match, .bind = bcm2835_sdhci_bind, .probe = bcm2835_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct bcm2835_sdhci_host), - .platdata_auto_alloc_size = sizeof(struct bcm2835_sdhci_plat), + .priv_auto = sizeof(struct bcm2835_sdhci_host), + .plat_auto = sizeof(struct bcm2835_sdhci_plat), .ops = &sdhci_ops, }; diff --git a/drivers/mmc/bcm2835_sdhost.c b/drivers/mmc/bcm2835_sdhost.c index ea8b385d7e..894dbdd686 100644 --- a/drivers/mmc/bcm2835_sdhost.c +++ b/drivers/mmc/bcm2835_sdhost.c @@ -755,7 +755,7 @@ static void bcm2835_add_host(struct bcm2835_host *host) static int bcm2835_probe(struct udevice *dev) { - struct bcm2835_plat *plat = dev_get_platdata(dev); + struct bcm2835_plat *plat = dev_get_plat(dev); struct bcm2835_host *host = dev_get_priv(dev); struct mmc *mmc = mmc_get_mmc_dev(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); @@ -795,7 +795,7 @@ static const struct dm_mmc_ops bcm2835_ops = { static int bcm2835_bind(struct udevice *dev) { - struct bcm2835_plat *plat = dev_get_platdata(dev); + struct bcm2835_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -806,7 +806,7 @@ U_BOOT_DRIVER(bcm2835_sdhost) = { .of_match = bcm2835_match, .bind = bcm2835_bind, .probe = bcm2835_probe, - .priv_auto_alloc_size = sizeof(struct bcm2835_host), - .platdata_auto_alloc_size = sizeof(struct bcm2835_plat), + .priv_auto = sizeof(struct bcm2835_host), + .plat_auto = sizeof(struct bcm2835_plat), .ops = &bcm2835_ops, }; diff --git a/drivers/mmc/bcmstb_sdhci.c b/drivers/mmc/bcmstb_sdhci.c index 5269aa77ce..dc96818cff 100644 --- a/drivers/mmc/bcmstb_sdhci.c +++ b/drivers/mmc/bcmstb_sdhci.c @@ -49,7 +49,7 @@ struct sdhci_bcmstb_plat { static int sdhci_bcmstb_bind(struct udevice *dev) { - struct sdhci_bcmstb_plat *plat = dev_get_platdata(dev); + struct sdhci_bcmstb_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -57,7 +57,7 @@ static int sdhci_bcmstb_bind(struct udevice *dev) static int sdhci_bcmstb_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct sdhci_bcmstb_plat *plat = dev_get_platdata(dev); + struct sdhci_bcmstb_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); fdt_addr_t base; int ret; @@ -100,6 +100,6 @@ U_BOOT_DRIVER(sdhci_bcmstb) = { .ops = &sdhci_ops, .bind = sdhci_bcmstb_bind, .probe = sdhci_bcmstb_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct sdhci_bcmstb_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct sdhci_bcmstb_plat), }; diff --git a/drivers/mmc/ca_dw_mmc.c b/drivers/mmc/ca_dw_mmc.c index 198c41f451..fad2ff5aaf 100644 --- a/drivers/mmc/ca_dw_mmc.c +++ b/drivers/mmc/ca_dw_mmc.c @@ -87,7 +87,7 @@ unsigned int ca_dwmci_get_mmc_clock(struct dwmci_host *host, uint freq) return SD_SCLK_MAX / clk_div / (host->div + 1); } -static int ca_dwmmc_ofdata_to_platdata(struct udevice *dev) +static int ca_dwmmc_of_to_plat(struct udevice *dev) { struct ca_dwmmc_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -124,7 +124,7 @@ struct dm_mmc_ops ca_dwmci_dm_ops; static int ca_dwmmc_probe(struct udevice *dev) { - struct ca_mmc_plat *plat = dev_get_platdata(dev); + struct ca_mmc_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct ca_dwmmc_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -148,7 +148,7 @@ static int ca_dwmmc_probe(struct udevice *dev) static int ca_dwmmc_bind(struct udevice *dev) { - struct ca_mmc_plat *plat = dev_get_platdata(dev); + struct ca_mmc_plat *plat = dev_get_plat(dev); return dwmci_bind(dev, &plat->mmc, &plat->cfg); } @@ -162,10 +162,10 @@ U_BOOT_DRIVER(ca_dwmmc_drv) = { .name = "cortina_dwmmc", .id = UCLASS_MMC, .of_match = ca_dwmmc_ids, - .ofdata_to_platdata = ca_dwmmc_ofdata_to_platdata, + .of_to_plat = ca_dwmmc_of_to_plat, .bind = ca_dwmmc_bind, .ops = &ca_dwmci_dm_ops, .probe = ca_dwmmc_probe, - .priv_auto_alloc_size = sizeof(struct ca_dwmmc_priv_data), - .platdata_auto_alloc_size = sizeof(struct ca_mmc_plat), + .priv_auto = sizeof(struct ca_dwmmc_priv_data), + .plat_auto = sizeof(struct ca_mmc_plat), }; diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c index 0a05fb13bc..05ca361280 100644 --- a/drivers/mmc/davinci_mmc.c +++ b/drivers/mmc/davinci_mmc.c @@ -478,7 +478,7 @@ int davinci_mmc_init(struct bd_info *bis, struct davinci_mmc *host) static int davinci_mmc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct davinci_mmc_plat *plat = dev_get_platdata(dev); + struct davinci_mmc_plat *plat = dev_get_plat(dev); struct davinci_mmc_priv *priv = dev_get_priv(dev); priv->reg_base = plat->reg_base; @@ -495,15 +495,15 @@ static int davinci_mmc_probe(struct udevice *dev) static int davinci_mmc_bind(struct udevice *dev) { - struct davinci_mmc_plat *plat = dev_get_platdata(dev); + struct davinci_mmc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } #if CONFIG_IS_ENABLED(OF_CONTROL) -static int davinci_mmc_ofdata_to_platdata(struct udevice *dev) +static int davinci_mmc_of_to_plat(struct udevice *dev) { - struct davinci_mmc_plat *plat = dev_get_platdata(dev); + struct davinci_mmc_plat *plat = dev_get_plat(dev); struct mmc_config *cfg = &plat->cfg; plat->reg_base = (struct davinci_mmc_regs *)dev_read_addr(dev); @@ -527,15 +527,15 @@ U_BOOT_DRIVER(ti_da830_mmc) = { .id = UCLASS_MMC, #if CONFIG_IS_ENABLED(OF_CONTROL) .of_match = davinci_mmc_ids, - .platdata_auto_alloc_size = sizeof(struct davinci_mmc_plat), - .ofdata_to_platdata = davinci_mmc_ofdata_to_platdata, + .plat_auto = sizeof(struct davinci_mmc_plat), + .of_to_plat = davinci_mmc_of_to_plat, #endif #if CONFIG_BLK .bind = davinci_mmc_bind, #endif .probe = davinci_mmc_probe, .ops = &davinci_mmc_ops, - .priv_auto_alloc_size = sizeof(struct davinci_mmc_priv), + .priv_auto = sizeof(struct davinci_mmc_priv), #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, #endif diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 435ccac594..3aa9fb3c89 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -263,7 +263,7 @@ int exynos_dwmmc_init(const void *blob) #ifdef CONFIG_DM_MMC static int exynos_dwmmc_probe(struct udevice *dev) { - struct exynos_mmc_plat *plat = dev_get_platdata(dev); + struct exynos_mmc_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct dwmci_exynos_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -288,7 +288,7 @@ static int exynos_dwmmc_probe(struct udevice *dev) static int exynos_dwmmc_bind(struct udevice *dev) { - struct exynos_mmc_plat *plat = dev_get_platdata(dev); + struct exynos_mmc_plat *plat = dev_get_plat(dev); return dwmci_bind(dev, &plat->mmc, &plat->cfg); } @@ -306,7 +306,7 @@ U_BOOT_DRIVER(exynos_dwmmc_drv) = { .bind = exynos_dwmmc_bind, .ops = &dm_dwmci_ops, .probe = exynos_dwmmc_probe, - .priv_auto_alloc_size = sizeof(struct dwmci_exynos_priv_data), - .platdata_auto_alloc_size = sizeof(struct exynos_mmc_plat), + .priv_auto = sizeof(struct dwmci_exynos_priv_data), + .plat_auto = sizeof(struct exynos_mmc_plat), }; #endif diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index a18316eda7..b5f3fd134d 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -955,7 +955,7 @@ int fsl_esdhc_mmc_init(struct bd_info *bis) static int fsl_esdhc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); u32 caps, hostver; fdt_addr_t addr; @@ -1022,7 +1022,7 @@ static int fsl_esdhc_probe(struct udevice *dev) static int fsl_esdhc_get_cd(struct udevice *dev) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); if (plat->cfg.host_caps & MMC_CAP_NONREMOVABLE) @@ -1034,7 +1034,7 @@ static int fsl_esdhc_get_cd(struct udevice *dev) static int fsl_esdhc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); return esdhc_send_cmd_common(priv, &plat->mmc, cmd, data); @@ -1042,7 +1042,7 @@ static int fsl_esdhc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, static int fsl_esdhc_set_ios(struct udevice *dev) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); return esdhc_set_ios_common(priv, &plat->mmc); @@ -1050,7 +1050,7 @@ static int fsl_esdhc_set_ios(struct udevice *dev) static int fsl_esdhc_reinit(struct udevice *dev) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); return esdhc_init_common(priv, &plat->mmc); @@ -1059,7 +1059,7 @@ static int fsl_esdhc_reinit(struct udevice *dev) #ifdef MMC_SUPPORTS_TUNING static int fsl_esdhc_execute_tuning(struct udevice *dev, uint32_t opcode) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); struct fsl_esdhc *regs = priv->esdhc_regs; u32 val, irqstaten; @@ -1124,7 +1124,7 @@ static const struct udevice_id fsl_esdhc_ids[] = { static int fsl_esdhc_bind(struct udevice *dev) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -1136,7 +1136,7 @@ U_BOOT_DRIVER(fsl_esdhc) = { .ops = &fsl_esdhc_ops, .bind = fsl_esdhc_bind, .probe = fsl_esdhc_probe, - .platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat), - .priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv), + .plat_auto = sizeof(struct fsl_esdhc_plat), + .priv_auto = sizeof(struct fsl_esdhc_priv), }; #endif diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index e5409ade1b..f47a095c50 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -850,7 +850,7 @@ static void esdhc_stop_tuning(struct mmc *mmc) static int fsl_esdhc_execute_tuning(struct udevice *dev, uint32_t opcode) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); struct fsl_esdhc *regs = priv->esdhc_regs; struct mmc *mmc = &plat->mmc; @@ -1400,7 +1400,7 @@ __weak void init_clk_usdhc(u32 index) { } -static int fsl_esdhc_ofdata_to_platdata(struct udevice *dev) +static int fsl_esdhc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct fsl_esdhc_priv *priv = dev_get_priv(dev); @@ -1490,7 +1490,7 @@ static int fsl_esdhc_ofdata_to_platdata(struct udevice *dev) static int fsl_esdhc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); struct esdhc_soc_data *data = (struct esdhc_soc_data *)dev_get_driver_data(dev); @@ -1558,7 +1558,7 @@ static int fsl_esdhc_probe(struct udevice *dev) * work as expected. */ - init_clk_usdhc(dev->seq); + init_clk_usdhc(dev_seq(dev)); #if CONFIG_IS_ENABLED(CLK) /* Assigned clock already set clock */ @@ -1575,7 +1575,7 @@ static int fsl_esdhc_probe(struct udevice *dev) priv->sdhc_clk = clk_get_rate(&priv->per_clk); #else - priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev->seq); + priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev_seq(dev)); if (priv->sdhc_clk <= 0) { dev_err(dev, "Unable to get clk for %s\n", dev->name); return -EINVAL; @@ -1633,7 +1633,7 @@ static int fsl_esdhc_get_cd(struct udevice *dev) static int fsl_esdhc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); return esdhc_send_cmd_common(priv, &plat->mmc, cmd, data); @@ -1641,7 +1641,7 @@ static int fsl_esdhc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, static int fsl_esdhc_set_ios(struct udevice *dev) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); struct fsl_esdhc_priv *priv = dev_get_priv(dev); return esdhc_set_ios_common(priv, &plat->mmc); @@ -1722,7 +1722,7 @@ static const struct udevice_id fsl_esdhc_ids[] = { #if CONFIG_IS_ENABLED(BLK) static int fsl_esdhc_bind(struct udevice *dev) { - struct fsl_esdhc_plat *plat = dev_get_platdata(dev); + struct fsl_esdhc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -1732,15 +1732,15 @@ U_BOOT_DRIVER(fsl_esdhc) = { .name = "fsl_esdhc", .id = UCLASS_MMC, .of_match = fsl_esdhc_ids, - .ofdata_to_platdata = fsl_esdhc_ofdata_to_platdata, + .of_to_plat = fsl_esdhc_of_to_plat, .ops = &fsl_esdhc_ops, #if CONFIG_IS_ENABLED(BLK) .bind = fsl_esdhc_bind, #endif .probe = fsl_esdhc_probe, - .platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat), - .priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv), + .plat_auto = sizeof(struct fsl_esdhc_plat), + .priv_auto = sizeof(struct fsl_esdhc_priv), }; -U_BOOT_DRIVER_ALIAS(fsl_esdhc, fsl_imx6q_usdhc) +DM_DRIVER_ALIAS(fsl_esdhc, fsl_imx6q_usdhc) #endif diff --git a/drivers/mmc/ftsdc010_mci.c b/drivers/mmc/ftsdc010_mci.c index bc0d5ffed5..fa6181d85f 100644 --- a/drivers/mmc/ftsdc010_mci.c +++ b/drivers/mmc/ftsdc010_mci.c @@ -389,7 +389,7 @@ static void ftsdc_setup_cfg(struct mmc_config *cfg, const char *name, int buswid cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; } -static int ftsdc010_mmc_ofdata_to_platdata(struct udevice *dev) +static int ftsdc010_mmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct ftsdc_priv *priv = dev_get_priv(dev); @@ -424,7 +424,7 @@ static int ftsdc010_mmc_ofdata_to_platdata(struct udevice *dev) static int ftsdc010_mmc_probe(struct udevice *dev) { - struct ftsdc010_plat *plat = dev_get_platdata(dev); + struct ftsdc010_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct ftsdc_priv *priv = dev_get_priv(dev); struct ftsdc010_chip *chip = &priv->chip; @@ -459,7 +459,7 @@ static int ftsdc010_mmc_probe(struct udevice *dev) int ftsdc010_mmc_bind(struct udevice *dev) { - struct ftsdc010_plat *plat = dev_get_platdata(dev); + struct ftsdc010_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -473,10 +473,10 @@ U_BOOT_DRIVER(ftsdc010_mmc) = { .name = "ftsdc010_mmc", .id = UCLASS_MMC, .of_match = ftsdc010_mmc_ids, - .ofdata_to_platdata = ftsdc010_mmc_ofdata_to_platdata, + .of_to_plat = ftsdc010_mmc_of_to_plat, .ops = &dm_ftsdc010_mmc_ops, .bind = ftsdc010_mmc_bind, .probe = ftsdc010_mmc_probe, - .priv_auto_alloc_size = sizeof(struct ftsdc_priv), - .platdata_auto_alloc_size = sizeof(struct ftsdc010_plat), + .priv_auto = sizeof(struct ftsdc_priv), + .plat_auto = sizeof(struct ftsdc010_plat), }; diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c index 0a347b2fb2..da81425038 100644 --- a/drivers/mmc/gen_atmel_mci.c +++ b/drivers/mmc/gen_atmel_mci.c @@ -91,7 +91,7 @@ static inline void mci_set_blklen(atmel_mci_t *mci, int blklen) #ifdef CONFIG_DM_MMC static void mci_set_mode(struct udevice *dev, u32 hz, u32 blklen) { - struct atmel_mci_plat *plat = dev_get_platdata(dev); + struct atmel_mci_plat *plat = dev_get_plat(dev); struct atmel_mci_priv *priv = dev_get_priv(dev); struct mmc *mmc = &plat->mmc; u32 bus_hz = priv->bus_clk_rate; @@ -242,7 +242,7 @@ io_fail: static int atmel_mci_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { - struct atmel_mci_plat *plat = dev_get_platdata(dev); + struct atmel_mci_plat *plat = dev_get_plat(dev); struct atmel_mci_priv *priv = dev_get_priv(dev); atmel_mci_t *mci = plat->mci; #else @@ -373,7 +373,7 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) #ifdef CONFIG_DM_MMC static int atmel_mci_set_ios(struct udevice *dev) { - struct atmel_mci_plat *plat = dev_get_platdata(dev); + struct atmel_mci_plat *plat = dev_get_plat(dev); struct mmc *mmc = mmc_get_mmc_dev(dev); atmel_mci_t *mci = plat->mci; #else @@ -424,7 +424,7 @@ static int mci_set_ios(struct mmc *mmc) #ifdef CONFIG_DM_MMC static int atmel_mci_hw_init(struct udevice *dev) { - struct atmel_mci_plat *plat = dev_get_platdata(dev); + struct atmel_mci_plat *plat = dev_get_plat(dev); atmel_mci_t *mci = plat->mci; #else /* Entered into mmc structure during driver init */ @@ -525,7 +525,7 @@ static const struct dm_mmc_ops atmel_mci_mmc_ops = { static void atmel_mci_setup_cfg(struct udevice *dev) { - struct atmel_mci_plat *plat = dev_get_platdata(dev); + struct atmel_mci_plat *plat = dev_get_plat(dev); struct atmel_mci_priv *priv = dev_get_priv(dev); struct mmc_config *cfg; u32 version; @@ -584,7 +584,7 @@ failed: static int atmel_mci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct atmel_mci_plat *plat = dev_get_platdata(dev); + struct atmel_mci_plat *plat = dev_get_plat(dev); struct mmc *mmc; int ret; @@ -608,7 +608,7 @@ static int atmel_mci_probe(struct udevice *dev) static int atmel_mci_bind(struct udevice *dev) { - struct atmel_mci_plat *plat = dev_get_platdata(dev); + struct atmel_mci_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -624,8 +624,8 @@ U_BOOT_DRIVER(atmel_mci) = { .of_match = atmel_mci_ids, .bind = atmel_mci_bind, .probe = atmel_mci_probe, - .platdata_auto_alloc_size = sizeof(struct atmel_mci_plat), - .priv_auto_alloc_size = sizeof(struct atmel_mci_priv), + .plat_auto = sizeof(struct atmel_mci_plat), + .priv_auto = sizeof(struct atmel_mci_priv), .ops = &atmel_mci_mmc_ops, }; #endif diff --git a/drivers/mmc/hi6220_dw_mmc.c b/drivers/mmc/hi6220_dw_mmc.c index 67d6a05b3b..bb5d0922be 100644 --- a/drivers/mmc/hi6220_dw_mmc.c +++ b/drivers/mmc/hi6220_dw_mmc.c @@ -27,7 +27,7 @@ struct hisi_mmc_data { bool use_fifo; }; -static int hi6220_dwmmc_ofdata_to_platdata(struct udevice *dev) +static int hi6220_dwmmc_of_to_plat(struct udevice *dev) { struct hi6220_dwmmc_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -50,7 +50,7 @@ static int hi6220_dwmmc_ofdata_to_platdata(struct udevice *dev) static int hi6220_dwmmc_probe(struct udevice *dev) { - struct hi6220_dwmmc_plat *plat = dev_get_platdata(dev); + struct hi6220_dwmmc_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct hi6220_dwmmc_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -74,7 +74,7 @@ static int hi6220_dwmmc_probe(struct udevice *dev) static int hi6220_dwmmc_bind(struct udevice *dev) { - struct hi6220_dwmmc_plat *plat = dev_get_platdata(dev); + struct hi6220_dwmmc_plat *plat = dev_get_plat(dev); int ret; ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); @@ -108,10 +108,10 @@ U_BOOT_DRIVER(hi6220_dwmmc_drv) = { .name = "hi6220_dwmmc", .id = UCLASS_MMC, .of_match = hi6220_dwmmc_ids, - .ofdata_to_platdata = hi6220_dwmmc_ofdata_to_platdata, + .of_to_plat = hi6220_dwmmc_of_to_plat, .ops = &dm_dwmci_ops, .bind = hi6220_dwmmc_bind, .probe = hi6220_dwmmc_probe, - .priv_auto_alloc_size = sizeof(struct hi6220_dwmmc_priv_data), - .platdata_auto_alloc_size = sizeof(struct hi6220_dwmmc_plat), + .priv_auto = sizeof(struct hi6220_dwmmc_priv_data), + .plat_auto = sizeof(struct hi6220_dwmmc_plat), }; diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c index 9f530638e3..f931e4b3c1 100644 --- a/drivers/mmc/iproc_sdhci.c +++ b/drivers/mmc/iproc_sdhci.c @@ -172,7 +172,7 @@ struct iproc_sdhci_plat { static int iproc_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct iproc_sdhci_plat *plat = dev_get_platdata(dev); + struct iproc_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); struct sdhci_iproc_host *iproc_host; int node = dev_of_offset(dev); @@ -230,7 +230,7 @@ static int iproc_sdhci_probe(struct udevice *dev) static int iproc_sdhci_bind(struct udevice *dev) { - struct iproc_sdhci_plat *plat = dev_get_platdata(dev); + struct iproc_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -247,6 +247,6 @@ U_BOOT_DRIVER(iproc_sdhci_drv) = { .ops = &sdhci_ops, .bind = iproc_sdhci_bind, .probe = iproc_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct iproc_sdhci_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct iproc_sdhci_plat), }; diff --git a/drivers/mmc/jz_mmc.c b/drivers/mmc/jz_mmc.c index b33f085073..ae3af3927d 100644 --- a/drivers/mmc/jz_mmc.c +++ b/drivers/mmc/jz_mmc.c @@ -443,10 +443,10 @@ static const struct dm_mmc_ops jz_msc_ops = { .set_ios = jz_mmc_dm_set_ios, }; -static int jz_mmc_ofdata_to_platdata(struct udevice *dev) +static int jz_mmc_of_to_plat(struct udevice *dev) { struct jz_mmc_priv *priv = dev_get_priv(dev); - struct jz_mmc_plat *plat = dev_get_platdata(dev); + struct jz_mmc_plat *plat = dev_get_plat(dev); struct mmc_config *cfg; int ret; @@ -473,7 +473,7 @@ static int jz_mmc_ofdata_to_platdata(struct udevice *dev) static int jz_mmc_bind(struct udevice *dev) { - struct jz_mmc_plat *plat = dev_get_platdata(dev); + struct jz_mmc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -482,7 +482,7 @@ static int jz_mmc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct jz_mmc_priv *priv = dev_get_priv(dev); - struct jz_mmc_plat *plat = dev_get_platdata(dev); + struct jz_mmc_plat *plat = dev_get_plat(dev); plat->mmc.priv = priv; upriv->mmc = &plat->mmc; @@ -498,11 +498,11 @@ U_BOOT_DRIVER(jz_mmc_drv) = { .name = "jz_mmc", .id = UCLASS_MMC, .of_match = jz_mmc_ids, - .ofdata_to_platdata = jz_mmc_ofdata_to_platdata, + .of_to_plat = jz_mmc_of_to_plat, .bind = jz_mmc_bind, .probe = jz_mmc_probe, - .priv_auto_alloc_size = sizeof(struct jz_mmc_priv), - .platdata_auto_alloc_size = sizeof(struct jz_mmc_plat), + .priv_auto = sizeof(struct jz_mmc_priv), + .plat_auto = sizeof(struct jz_mmc_plat), .ops = &jz_msc_ops, }; #endif /* CONFIG_DM_MMC */ diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c index a5e9ac5637..8b6dfa3b96 100644 --- a/drivers/mmc/meson_gx_mmc.c +++ b/drivers/mmc/meson_gx_mmc.c @@ -27,7 +27,7 @@ bool meson_gx_mmc_is_compatible(struct udevice *dev, static inline void *get_regbase(const struct mmc *mmc) { - struct meson_mmc_platdata *pdata = mmc->priv; + struct meson_mmc_plat *pdata = mmc->priv; return pdata->regbase; } @@ -160,7 +160,7 @@ static void meson_mmc_setup_cmd(struct mmc *mmc, struct mmc_data *data, static void meson_mmc_setup_addr(struct mmc *mmc, struct mmc_data *data) { - struct meson_mmc_platdata *pdata = mmc->priv; + struct meson_mmc_plat *pdata = mmc->priv; unsigned int data_size; uint32_t data_addr = 0; @@ -198,7 +198,7 @@ static int meson_dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { struct mmc *mmc = mmc_get_mmc_dev(dev); - struct meson_mmc_platdata *pdata = mmc->priv; + struct meson_mmc_plat *pdata = mmc->priv; uint32_t status; ulong start; int ret = 0; @@ -241,9 +241,9 @@ static const struct dm_mmc_ops meson_dm_mmc_ops = { .set_ios = meson_dm_mmc_set_ios, }; -static int meson_mmc_ofdata_to_platdata(struct udevice *dev) +static int meson_mmc_of_to_plat(struct udevice *dev) { - struct meson_mmc_platdata *pdata = dev_get_platdata(dev); + struct meson_mmc_plat *pdata = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -257,7 +257,7 @@ static int meson_mmc_ofdata_to_platdata(struct udevice *dev) static int meson_mmc_probe(struct udevice *dev) { - struct meson_mmc_platdata *pdata = dev_get_platdata(dev); + struct meson_mmc_plat *pdata = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct mmc *mmc = &pdata->mmc; struct mmc_config *cfg = &pdata->cfg; @@ -320,7 +320,7 @@ static int meson_mmc_probe(struct udevice *dev) int meson_mmc_bind(struct udevice *dev) { - struct meson_mmc_platdata *pdata = dev_get_platdata(dev); + struct meson_mmc_plat *pdata = dev_get_plat(dev); return mmc_bind(dev, &pdata->mmc, &pdata->cfg); } @@ -339,8 +339,8 @@ U_BOOT_DRIVER(meson_mmc) = { .ops = &meson_dm_mmc_ops, .probe = meson_mmc_probe, .bind = meson_mmc_bind, - .ofdata_to_platdata = meson_mmc_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct meson_mmc_platdata), + .of_to_plat = meson_mmc_of_to_plat, + .plat_auto = sizeof(struct meson_mmc_plat), }; #ifdef CONFIG_PWRSEQ diff --git a/drivers/mmc/meson_gx_mmc.h b/drivers/mmc/meson_gx_mmc.h index 92aec5329f..8974b78f55 100644 --- a/drivers/mmc/meson_gx_mmc.h +++ b/drivers/mmc/meson_gx_mmc.h @@ -84,7 +84,7 @@ enum meson_gx_mmc_compatible { #define MESON_SD_EMMC_CMD_RSP2 0x64 #define MESON_SD_EMMC_CMD_RSP3 0x68 -struct meson_mmc_platdata { +struct meson_mmc_plat { struct mmc_config cfg; struct mmc mmc; void *regbase; diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 285ac48061..53eabc9e61 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -321,7 +321,7 @@ struct blk_desc *mmc_get_blk_desc(struct mmc *mmc) device_find_first_child(mmc->dev, &dev); if (!dev) return NULL; - desc = dev_get_uclass_platdata(dev); + desc = dev_get_uclass_plat(dev); return desc; } @@ -399,7 +399,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) debug("Cannot create block device\n"); return ret; } - bdesc = dev_get_uclass_platdata(bdev); + bdesc = dev_get_uclass_plat(bdev); mmc->cfg = cfg; mmc->priv = dev; @@ -435,7 +435,7 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart) { struct udevice *mmc_dev = dev_get_parent(bdev); struct mmc *mmc = mmc_get_mmc_dev(mmc_dev); - struct blk_desc *desc = dev_get_uclass_platdata(bdev); + struct blk_desc *desc = dev_get_uclass_plat(bdev); int ret; if (desc->hwpart == hwpart) @@ -508,5 +508,5 @@ UCLASS_DRIVER(mmc) = { .id = UCLASS_MMC, .name = "mmc", .flags = DM_UC_FLAG_SEQ_ALIAS, - .per_device_auto_alloc_size = sizeof(struct mmc_uclass_priv), + .per_device_auto = sizeof(struct mmc_uclass_priv), }; diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index a6394bcf30..36aab50f64 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -454,7 +454,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, #endif { #if CONFIG_IS_ENABLED(BLK) - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); #endif int dev_num = block_dev->devnum; int err; diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c index 50fcd32674..46800bbed2 100644 --- a/drivers/mmc/mmc_spi.c +++ b/drivers/mmc/mmc_spi.c @@ -411,14 +411,13 @@ done: static int mmc_spi_probe(struct udevice *dev) { struct mmc_spi_priv *priv = dev_get_priv(dev); - struct mmc_spi_plat *plat = dev_get_platdata(dev); + struct mmc_spi_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); char *name; priv->spi = dev_get_parent_priv(dev); if (!priv->spi->max_hz) priv->spi->max_hz = MMC_SPI_MAX_CLOCK; - priv->spi->speed = 0; priv->spi->mode = SPI_MODE_0; priv->spi->wordlen = 8; @@ -446,7 +445,7 @@ static int mmc_spi_probe(struct udevice *dev) static int mmc_spi_bind(struct udevice *dev) { - struct mmc_spi_plat *plat = dev_get_platdata(dev); + struct mmc_spi_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -468,6 +467,6 @@ U_BOOT_DRIVER(mmc_spi) = { .ops = &mmc_spi_ops, .probe = mmc_spi_probe, .bind = mmc_spi_bind, - .platdata_auto_alloc_size = sizeof(struct mmc_spi_plat), - .priv_auto_alloc_size = sizeof(struct mmc_spi_priv), + .plat_auto = sizeof(struct mmc_spi_plat), + .priv_auto = sizeof(struct mmc_spi_priv), }; diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c index 6a4453ca02..d23b7d9729 100644 --- a/drivers/mmc/mmc_write.c +++ b/drivers/mmc/mmc_write.c @@ -73,7 +73,7 @@ ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt) #endif { #if CONFIG_IS_ENABLED(BLK) - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); #endif int dev_num = block_dev->devnum; int err = 0; @@ -193,7 +193,7 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, #endif { #if CONFIG_IS_ENABLED(BLK) - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); #endif int dev_num = block_dev->devnum; lbaint_t cur, blocks_todo = blkcnt; diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c index 2a1f412278..bfbba46c5d 100644 --- a/drivers/mmc/msm_sdhci.c +++ b/drivers/mmc/msm_sdhci.c @@ -87,7 +87,7 @@ static int msm_sdc_clk_init(struct udevice *dev) static int msm_sdc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct msm_sdhc_plat *plat = dev_get_platdata(dev); + struct msm_sdhc_plat *plat = dev_get_plat(dev); struct msm_sdhc *prv = dev_get_priv(dev); struct sdhci_host *host = &prv->host; u32 core_version, core_minor, core_major; @@ -167,7 +167,7 @@ static int msm_sdc_remove(struct udevice *dev) return 0; } -static int msm_ofdata_to_platdata(struct udevice *dev) +static int msm_of_to_plat(struct udevice *dev) { struct udevice *parent = dev->parent; struct msm_sdhc *priv = dev_get_priv(dev); @@ -189,7 +189,7 @@ static int msm_ofdata_to_platdata(struct udevice *dev) static int msm_sdc_bind(struct udevice *dev) { - struct msm_sdhc_plat *plat = dev_get_platdata(dev); + struct msm_sdhc_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -203,11 +203,11 @@ U_BOOT_DRIVER(msm_sdc_drv) = { .name = "msm_sdc", .id = UCLASS_MMC, .of_match = msm_mmc_ids, - .ofdata_to_platdata = msm_ofdata_to_platdata, + .of_to_plat = msm_of_to_plat, .ops = &sdhci_ops, .bind = msm_sdc_bind, .probe = msm_sdc_probe, .remove = msm_sdc_remove, - .priv_auto_alloc_size = sizeof(struct msm_sdhc), - .platdata_auto_alloc_size = sizeof(struct msm_sdhc_plat), + .priv_auto = sizeof(struct msm_sdhc), + .plat_auto = sizeof(struct msm_sdhc_plat), }; diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c index 4f9fa7d0ec..95dc9daee9 100644 --- a/drivers/mmc/mtk-sd.c +++ b/drivers/mmc/mtk-sd.c @@ -885,7 +885,7 @@ static void msdc_set_mclk(struct udevice *dev, static int msdc_ops_set_ios(struct udevice *dev) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc *mmc = &plat->mmc; uint clock = mmc->clock; @@ -1031,7 +1031,7 @@ static inline void msdc_set_data_delay(struct msdc_host *host, u32 value) static int hs400_tune_response(struct udevice *dev, u32 opcode) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc *mmc = &plat->mmc; u32 cmd_delay = 0; @@ -1081,7 +1081,7 @@ static int hs400_tune_response(struct udevice *dev, u32 opcode) static int msdc_tune_response(struct udevice *dev, u32 opcode) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc *mmc = &plat->mmc; u32 rise_delay = 0, fall_delay = 0; @@ -1185,7 +1185,7 @@ skip_internal: static int msdc_tune_data(struct udevice *dev, u32 opcode) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc *mmc = &plat->mmc; u32 rise_delay = 0, fall_delay = 0; @@ -1276,7 +1276,7 @@ skip_fall: */ static int msdc_tune_together(struct udevice *dev, u32 opcode) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc *mmc = &plat->mmc; u32 rise_delay = 0, fall_delay = 0; @@ -1334,7 +1334,7 @@ skip_fall: static int msdc_execute_tuning(struct udevice *dev, uint opcode) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc *mmc = &plat->mmc; int ret = 0; @@ -1511,7 +1511,7 @@ static void msdc_ungate_clock(struct msdc_host *host) static int msdc_drv_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; @@ -1545,9 +1545,9 @@ static int msdc_drv_probe(struct udevice *dev) return 0; } -static int msdc_ofdata_to_platdata(struct udevice *dev) +static int msdc_of_to_plat(struct udevice *dev) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); struct msdc_host *host = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; fdt_addr_t base, top_base; @@ -1598,7 +1598,7 @@ static int msdc_ofdata_to_platdata(struct udevice *dev) static int msdc_drv_bind(struct udevice *dev) { - struct msdc_plat *plat = dev_get_platdata(dev); + struct msdc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -1688,10 +1688,10 @@ U_BOOT_DRIVER(mtk_sd_drv) = { .name = "mtk_sd", .id = UCLASS_MMC, .of_match = msdc_ids, - .ofdata_to_platdata = msdc_ofdata_to_platdata, + .of_to_plat = msdc_of_to_plat, .bind = msdc_drv_bind, .probe = msdc_drv_probe, .ops = &msdc_ops, - .platdata_auto_alloc_size = sizeof(struct msdc_plat), - .priv_auto_alloc_size = sizeof(struct msdc_host), + .plat_auto = sizeof(struct msdc_plat), + .priv_auto = sizeof(struct msdc_host), }; diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c index 9b3dfa13e6..556dd38046 100644 --- a/drivers/mmc/mv_sdhci.c +++ b/drivers/mmc/mv_sdhci.c @@ -107,7 +107,7 @@ struct mv_sdhci_plat { static int mv_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct mv_sdhci_plat *plat = dev_get_platdata(dev); + struct mv_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); int ret; @@ -134,7 +134,7 @@ static int mv_sdhci_probe(struct udevice *dev) static int mv_sdhci_bind(struct udevice *dev) { - struct mv_sdhci_plat *plat = dev_get_platdata(dev); + struct mv_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -151,7 +151,7 @@ U_BOOT_DRIVER(mv_sdhci_drv) = { .bind = mv_sdhci_bind, .probe = mv_sdhci_probe, .ops = &sdhci_ops, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct mv_sdhci_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct mv_sdhci_plat), }; #endif /* CONFIG_DM_MMC */ diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c index 2b3a3a992c..8fd4176415 100644 --- a/drivers/mmc/mxsmmc.c +++ b/drivers/mmc/mxsmmc.c @@ -52,7 +52,7 @@ struct mxsmmc_priv { #include <dm/read.h> #include <dt-structs.h> -struct mxsmmc_platdata { +struct mxsmmc_plat { #if CONFIG_IS_ENABLED(OF_PLATDATA) struct dtd_fsl_imx23_mmc dtplat; #endif @@ -310,7 +310,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) static int mxsmmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { - struct mxsmmc_platdata *plat = dev_get_platdata(dev); + struct mxsmmc_plat *plat = dev_get_plat(dev); struct mxsmmc_priv *priv = dev_get_priv(dev); struct mxs_ssp_regs *ssp_regs = priv->regs; struct mmc *mmc = &plat->mmc; @@ -490,7 +490,7 @@ mxsmmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) static int mxsmmc_get_cd(struct udevice *dev) { - struct mxsmmc_platdata *plat = dev_get_platdata(dev); + struct mxsmmc_plat *plat = dev_get_plat(dev); struct mxsmmc_priv *priv = dev_get_priv(dev); struct mxs_ssp_regs *ssp_regs = priv->regs; @@ -502,7 +502,7 @@ static int mxsmmc_get_cd(struct udevice *dev) static int mxsmmc_set_ios(struct udevice *dev) { - struct mxsmmc_platdata *plat = dev_get_platdata(dev); + struct mxsmmc_plat *plat = dev_get_plat(dev); struct mxsmmc_priv *priv = dev_get_priv(dev); struct mxs_ssp_regs *ssp_regs = priv->regs; struct mmc *mmc = &plat->mmc; @@ -567,7 +567,7 @@ static int mxsmmc_init(struct udevice *dev) static int mxsmmc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct mxsmmc_platdata *plat = dev_get_platdata(dev); + struct mxsmmc_plat *plat = dev_get_plat(dev); struct mxsmmc_priv *priv = dev_get_priv(dev); struct blk_desc *bdesc; struct mmc *mmc; @@ -653,7 +653,7 @@ static int mxsmmc_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(BLK) static int mxsmmc_bind(struct udevice *dev) { - struct mxsmmc_platdata *plat = dev_get_platdata(dev); + struct mxsmmc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -666,9 +666,9 @@ static const struct dm_mmc_ops mxsmmc_ops = { }; #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int mxsmmc_ofdata_to_platdata(struct udevice *bus) +static int mxsmmc_of_to_plat(struct udevice *bus) { - struct mxsmmc_platdata *plat = bus->platdata; + struct mxsmmc_plat *plat = dev_get_plat(bus); u32 prop[2]; int ret; @@ -711,16 +711,16 @@ U_BOOT_DRIVER(fsl_imx23_mmc) = { .id = UCLASS_MMC, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = mxsmmc_ids, - .ofdata_to_platdata = mxsmmc_ofdata_to_platdata, + .of_to_plat = mxsmmc_of_to_plat, #endif .ops = &mxsmmc_ops, #if CONFIG_IS_ENABLED(BLK) .bind = mxsmmc_bind, #endif .probe = mxsmmc_probe, - .priv_auto_alloc_size = sizeof(struct mxsmmc_priv), - .platdata_auto_alloc_size = sizeof(struct mxsmmc_platdata), + .priv_auto = sizeof(struct mxsmmc_priv), + .plat_auto = sizeof(struct mxsmmc_plat), }; -U_BOOT_DRIVER_ALIAS(fsl_imx23_mmc, fsl_imx28_mmc) +DM_DRIVER_ALIAS(fsl_imx23_mmc, fsl_imx28_mmc) #endif /* CONFIG_DM_MMC */ diff --git a/drivers/mmc/nexell_dw_mmc.c b/drivers/mmc/nexell_dw_mmc.c index 0462759444..753c89d278 100644 --- a/drivers/mmc/nexell_dw_mmc.c +++ b/drivers/mmc/nexell_dw_mmc.c @@ -139,7 +139,7 @@ static unsigned long nx_dw_mmc_set_clk(struct dwmci_host *host, return rate; } -static int nexell_dwmmc_ofdata_to_platdata(struct udevice *dev) +static int nexell_dwmmc_of_to_plat(struct udevice *dev) { struct nexell_dwmmc_priv *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -179,7 +179,7 @@ static int nexell_dwmmc_ofdata_to_platdata(struct udevice *dev) static int nexell_dwmmc_probe(struct udevice *dev) { - struct nexell_mmc_plat *plat = dev_get_platdata(dev); + struct nexell_mmc_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct nexell_dwmmc_priv *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -214,7 +214,7 @@ static int nexell_dwmmc_probe(struct udevice *dev) static int nexell_dwmmc_bind(struct udevice *dev) { - struct nexell_mmc_plat *plat = dev_get_platdata(dev); + struct nexell_mmc_plat *plat = dev_get_plat(dev); return dwmci_bind(dev, &plat->mmc, &plat->cfg); } @@ -228,10 +228,10 @@ U_BOOT_DRIVER(nexell_dwmmc_drv) = { .name = "nexell_dwmmc", .id = UCLASS_MMC, .of_match = nexell_dwmmc_ids, - .ofdata_to_platdata = nexell_dwmmc_ofdata_to_platdata, + .of_to_plat = nexell_dwmmc_of_to_plat, .ops = &dm_dwmci_ops, .bind = nexell_dwmmc_bind, .probe = nexell_dwmmc_probe, - .priv_auto_alloc_size = sizeof(struct nexell_dwmmc_priv), - .platdata_auto_alloc_size = sizeof(struct nexell_mmc_plat), + .priv_auto = sizeof(struct nexell_dwmmc_priv), + .plat_auto = sizeof(struct nexell_mmc_plat), }; diff --git a/drivers/mmc/octeontx_hsmmc.c b/drivers/mmc/octeontx_hsmmc.c index 38ca373684..442ca493d7 100644 --- a/drivers/mmc/octeontx_hsmmc.c +++ b/drivers/mmc/octeontx_hsmmc.c @@ -30,6 +30,7 @@ #include <asm/arch/clock.h> #include <asm/arch/csrs/csrs-mio_emm.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <power/regulator.h> @@ -3438,7 +3439,7 @@ static u32 xlate_voltage(u32 voltage) */ static bool octeontx_mmc_get_valid(struct udevice *dev) { - const char *stat = ofnode_read_string(dev->node, "status"); + const char *stat = ofnode_read_string(dev_ofnode(dev), "status"); if (!stat || !strncmp(stat, "ok", 2)) return true; @@ -3460,14 +3461,15 @@ static int octeontx_mmc_get_config(struct udevice *dev) uint low, high; char env_name[32]; int err; - ofnode node = dev->node; + ofnode node = dev_ofnode(dev); int bus_width = 1; ulong new_max_freq; debug("%s(%s)", __func__, dev->name); slot->cfg.name = dev->name; - slot->cfg.f_max = ofnode_read_s32_default(dev->node, "max-frequency", + slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev), + "max-frequency", 26000000); snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d", slot->bus_id); @@ -3485,25 +3487,26 @@ static int octeontx_mmc_get_config(struct udevice *dev) if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) { slot->hs400_tuning_block = - ofnode_read_s32_default(dev->node, + ofnode_read_s32_default(dev_ofnode(dev), "marvell,hs400-tuning-block", -1); debug("%s(%s): mmc HS400 tuning block: %d\n", __func__, dev->name, slot->hs400_tuning_block); slot->hs200_tap_adj = - ofnode_read_s32_default(dev->node, + ofnode_read_s32_default(dev_ofnode(dev), "marvell,hs200-tap-adjust", 0); debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name, slot->hs200_tap_adj); slot->hs400_tap_adj = - ofnode_read_s32_default(dev->node, + ofnode_read_s32_default(dev_ofnode(dev), "marvell,hs400-tap-adjust", 0); debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name, slot->hs400_tap_adj); } - err = ofnode_read_u32_array(dev->node, "voltage-ranges", voltages, 2); + err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges", + voltages, 2); if (err) { slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34; } else { @@ -3731,7 +3734,6 @@ U_BOOT_DRIVER(octeontx_hsmmc_slot) = { */ static int octeontx_mmc_host_probe(struct udevice *dev) { - pci_dev_t bdf = dm_pci_get_bdf(dev); struct octeontx_mmc_host *host = dev_get_priv(dev); union mio_emm_int emm_int; u8 rev; @@ -3752,19 +3754,19 @@ static int octeontx_mmc_host_probe(struct udevice *dev) host->dev = dev; debug("%s(%s): Base address: %p\n", __func__, dev->name, host->base_addr); - if (!dev_has_of_node(dev)) { + if (!dev_has_ofnode(dev)) { pr_err("%s: No device tree information found\n", __func__); return -1; } - host->node = dev->node; - dev->req_seq = PCI_FUNC(bdf); + host->node = dev_ofnode(dev); host->last_slotid = -1; if (otx_is_platform(PLATFORM_ASIM)) host->is_asim = true; if (otx_is_platform(PLATFORM_EMULATOR)) host->is_emul = true; host->dma_wait_delay = - ofnode_read_u32_default(dev->node, "marvell,dma-wait-delay", 1); + ofnode_read_u32_default(dev_ofnode(dev), + "marvell,dma-wait-delay", 1); /* Force reset of eMMC */ writeq(0, host->base_addr + MIO_EMM_CFG()); debug("%s: Clearing MIO_EMM_CFG\n", __func__); @@ -3825,7 +3827,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev) struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev)); struct octeontx_mmc_slot *slot; struct mmc_uclass_priv *upriv; - ofnode node = dev->node; + ofnode node = dev_ofnode(dev); u32 bus_id; char name[16]; int err; @@ -3843,7 +3845,7 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev) } slot = &host->slots[bus_id]; - dev->priv = slot; + dev_set_priv(dev, slot); slot->host = host; slot->bus_id = bus_id; slot->dev = dev; @@ -3854,16 +3856,21 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev) snprintf(name, sizeof(name), "octeontx-mmc%d", bus_id); err = device_set_name(dev, name); - if (!dev->uclass_priv) { + /* FIXME: This code should not be needed */ + if (!dev_get_uclass_priv(dev)) { debug("%s(%s): Allocating uclass priv\n", __func__, dev->name); upriv = calloc(1, sizeof(struct mmc_uclass_priv)); if (!upriv) return -ENOMEM; - dev->uclass_priv = upriv; - dev->uclass->priv = upriv; + + /* + * FIXME: This is not allowed + * dev_set_uclass_priv(dev, upriv); + * uclass_set_priv(dev->uclass, upriv); + */ } else { - upriv = dev->uclass_priv; + upriv = dev_get_uclass_priv(dev); } upriv->mmc = &slot->mmc; @@ -3880,10 +3887,11 @@ static const struct udevice_id octeontx_hsmmc_host_ids[] = { U_BOOT_DRIVER(octeontx_hsmmc_host) = { .name = "octeontx_hsmmc_host", + /* FIXME: Why is this not UCLASS_MMC? */ .id = UCLASS_MISC, .of_match = of_match_ptr(octeontx_hsmmc_host_ids), .probe = octeontx_mmc_host_probe, - .priv_auto_alloc_size = sizeof(struct octeontx_mmc_host), + .priv_auto = sizeof(struct octeontx_mmc_host), .child_pre_probe = octeontx_mmc_host_child_pre_probe, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c index 715eee0e3e..52f044e37a 100644 --- a/drivers/mmc/omap_hsmmc.c +++ b/drivers/mmc/omap_hsmmc.c @@ -180,7 +180,7 @@ static inline struct omap_hsmmc_data *omap_hsmmc_get_data(struct mmc *mmc) static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc) { #if CONFIG_IS_ENABLED(DM_MMC) - struct omap_hsmmc_plat *plat = dev_get_platdata(mmc->dev); + struct omap_hsmmc_plat *plat = dev_get_plat(mmc->dev); return &plat->cfg; #else return &((struct omap_hsmmc_data *)mmc->priv)->cfg; @@ -1898,9 +1898,9 @@ __weak const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr) } #endif -static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev) +static int omap_hsmmc_of_to_plat(struct udevice *dev) { - struct omap_hsmmc_plat *plat = dev_get_platdata(dev); + struct omap_hsmmc_plat *plat = dev_get_plat(dev); struct omap_mmc_of_data *of_data = (void *)dev_get_driver_data(dev); struct mmc_config *cfg = &plat->cfg; @@ -1949,14 +1949,14 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev) static int omap_hsmmc_bind(struct udevice *dev) { - struct omap_hsmmc_plat *plat = dev_get_platdata(dev); + struct omap_hsmmc_plat *plat = dev_get_plat(dev); plat->mmc = calloc(1, sizeof(struct mmc)); return mmc_bind(dev, plat->mmc, &plat->cfg); } #endif static int omap_hsmmc_probe(struct udevice *dev) { - struct omap_hsmmc_plat *plat = dev_get_platdata(dev); + struct omap_hsmmc_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct omap_hsmmc_data *priv = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; @@ -2028,15 +2028,15 @@ U_BOOT_DRIVER(omap_hsmmc) = { .id = UCLASS_MMC, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = omap_hsmmc_ids, - .ofdata_to_platdata = omap_hsmmc_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat), + .of_to_plat = omap_hsmmc_of_to_plat, + .plat_auto = sizeof(struct omap_hsmmc_plat), #endif #ifdef CONFIG_BLK .bind = omap_hsmmc_bind, #endif .ops = &omap_hsmmc_ops, .probe = omap_hsmmc_probe, - .priv_auto_alloc_size = sizeof(struct omap_hsmmc_data), + .priv_auto = sizeof(struct omap_hsmmc_data), #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, #endif diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c index 0c45e1b893..c71c495d58 100644 --- a/drivers/mmc/pci_mmc.c +++ b/drivers/mmc/pci_mmc.c @@ -31,7 +31,7 @@ struct pci_mmc_priv { static int pci_mmc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct pci_mmc_plat *plat = dev_get_platdata(dev); + struct pci_mmc_plat *plat = dev_get_plat(dev); struct pci_mmc_priv *priv = dev_get_priv(dev); struct sdhci_host *host = &priv->host; int ret; @@ -50,7 +50,7 @@ static int pci_mmc_probe(struct udevice *dev) return sdhci_probe(dev); } -static int pci_mmc_ofdata_to_platdata(struct udevice *dev) +static int pci_mmc_of_to_plat(struct udevice *dev) { struct pci_mmc_priv *priv = dev_get_priv(dev); @@ -61,7 +61,7 @@ static int pci_mmc_ofdata_to_platdata(struct udevice *dev) static int pci_mmc_bind(struct udevice *dev) { - struct pci_mmc_plat *plat = dev_get_platdata(dev); + struct pci_mmc_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -75,7 +75,7 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev, struct acpi_dp *dp; int ret; - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; ret = gpio_get_acpi(&priv->cd_gpio, &gpio); @@ -129,11 +129,11 @@ U_BOOT_DRIVER(pci_mmc) = { .id = UCLASS_MMC, .of_match = pci_mmc_match, .bind = pci_mmc_bind, - .ofdata_to_platdata = pci_mmc_ofdata_to_platdata, + .of_to_plat = pci_mmc_of_to_plat, .probe = pci_mmc_probe, .ops = &sdhci_ops, - .priv_auto_alloc_size = sizeof(struct pci_mmc_priv), - .platdata_auto_alloc_size = sizeof(struct pci_mmc_plat), + .priv_auto = sizeof(struct pci_mmc_priv), + .plat_auto = sizeof(struct pci_mmc_plat), ACPI_OPS_PTR(&pci_mmc_acpi_ops) }; diff --git a/drivers/mmc/pic32_sdhci.c b/drivers/mmc/pic32_sdhci.c index e201bdb8f4..fb37c6756c 100644 --- a/drivers/mmc/pic32_sdhci.c +++ b/drivers/mmc/pic32_sdhci.c @@ -18,7 +18,7 @@ struct pic32_sdhci_plat { static int pic32_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct pic32_sdhci_plat *plat = dev_get_platdata(dev); + struct pic32_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); struct clk clk; @@ -71,7 +71,7 @@ static int pic32_sdhci_probe(struct udevice *dev) static int pic32_sdhci_bind(struct udevice *dev) { - struct pic32_sdhci_plat *plat = dev_get_platdata(dev); + struct pic32_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -88,6 +88,6 @@ U_BOOT_DRIVER(pic32_sdhci_drv) = { .ops = &sdhci_ops, .bind = pic32_sdhci_bind, .probe = pic32_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct pic32_sdhci_plat) + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct pic32_sdhci_plat) }; diff --git a/drivers/mmc/pxa_mmc_gen.c b/drivers/mmc/pxa_mmc_gen.c index 2c081fdc69..2b45549a14 100644 --- a/drivers/mmc/pxa_mmc_gen.c +++ b/drivers/mmc/pxa_mmc_gen.c @@ -459,7 +459,7 @@ err0: static int pxa_mmc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct pxa_mmc_plat *plat = dev_get_platdata(dev); + struct pxa_mmc_plat *plat = dev_get_plat(dev); struct mmc_config *cfg = &plat->cfg; struct mmc *mmc = &plat->mmc; struct pxa_mmc_priv *priv = dev_get_priv(dev); @@ -494,7 +494,7 @@ static int pxa_mmc_probe(struct udevice *dev) static int pxa_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { - struct pxa_mmc_plat *plat = dev_get_platdata(dev); + struct pxa_mmc_plat *plat = dev_get_plat(dev); struct pxa_mmc_priv *priv = dev_get_priv(dev); return pxa_mmc_send_cmd_common(priv, &plat->mmc, cmd, data); @@ -502,7 +502,7 @@ static int pxa_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, static int pxa_mmc_set_ios(struct udevice *dev) { - struct pxa_mmc_plat *plat = dev_get_platdata(dev); + struct pxa_mmc_plat *plat = dev_get_plat(dev); struct pxa_mmc_priv *priv = dev_get_priv(dev); return pxa_mmc_set_ios_common(priv, &plat->mmc); @@ -517,7 +517,7 @@ static const struct dm_mmc_ops pxa_mmc_ops = { #if CONFIG_IS_ENABLED(BLK) static int pxa_mmc_bind(struct udevice *dev) { - struct pxa_mmc_plat *plat = dev_get_platdata(dev); + struct pxa_mmc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -530,7 +530,7 @@ U_BOOT_DRIVER(pxa_mmc) = { .id = UCLASS_MMC, .name = "pxa_mmc", .ops = &pxa_mmc_ops, - .priv_auto_alloc_size = sizeof(struct pxa_mmc_priv), + .priv_auto = sizeof(struct pxa_mmc_priv), .probe = pxa_mmc_probe, }; #endif /* !CONFIG_IS_ENABLED(DM_MMC) */ diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c index d80b3fc28f..24130e620b 100644 --- a/drivers/mmc/renesas-sdhi.c +++ b/drivers/mmc/renesas-sdhi.c @@ -865,7 +865,7 @@ static void renesas_sdhi_filter_caps(struct udevice *dev) #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \ CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \ CONFIG_IS_ENABLED(MMC_HS400_SUPPORT) - struct tmio_sd_plat *plat = dev_get_platdata(dev); + struct tmio_sd_plat *plat = dev_get_plat(dev); /* HS400 is not supported on H3 ES1.x and M3W ES1.0, ES1.1 */ if (((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7795) && @@ -1014,7 +1014,7 @@ U_BOOT_DRIVER(renesas_sdhi) = { .of_match = renesas_sdhi_match, .bind = tmio_sd_bind, .probe = renesas_sdhi_probe, - .priv_auto_alloc_size = sizeof(struct tmio_sd_priv), - .platdata_auto_alloc_size = sizeof(struct tmio_sd_plat), + .priv_auto = sizeof(struct tmio_sd_priv), + .plat_auto = sizeof(struct tmio_sd_plat), .ops = &renesas_sdhi_ops, }; diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index f1dafa6ce7..1be3c1741f 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -50,7 +50,7 @@ static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq) return freq; } -static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev) +static int rockchip_dwmmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rockchip_dwmmc_priv *priv = dev_get_priv(dev); @@ -101,7 +101,7 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev) static int rockchip_dwmmc_probe(struct udevice *dev) { - struct rockchip_mmc_plat *plat = dev_get_platdata(dev); + struct rockchip_mmc_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct rockchip_dwmmc_priv *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -157,7 +157,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev) static int rockchip_dwmmc_bind(struct udevice *dev) { - struct rockchip_mmc_plat *plat = dev_get_platdata(dev); + struct rockchip_mmc_plat *plat = dev_get_plat(dev); return dwmci_bind(dev, &plat->mmc, &plat->cfg); } @@ -172,16 +172,16 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = { .name = "rockchip_rk3288_dw_mshc", .id = UCLASS_MMC, .of_match = rockchip_dwmmc_ids, - .ofdata_to_platdata = rockchip_dwmmc_ofdata_to_platdata, + .of_to_plat = rockchip_dwmmc_of_to_plat, .ops = &dm_dwmci_ops, .bind = rockchip_dwmmc_bind, .probe = rockchip_dwmmc_probe, - .priv_auto_alloc_size = sizeof(struct rockchip_dwmmc_priv), - .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), + .priv_auto = sizeof(struct rockchip_dwmmc_priv), + .plat_auto = sizeof(struct rockchip_mmc_plat), }; -U_BOOT_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc) -U_BOOT_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc) +DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc) +DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc) #ifdef CONFIG_PWRSEQ static int rockchip_dwmmc_pwrseq_set_power(struct udevice *dev, bool enable) diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index b073f1a08d..d95f8b2a15 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -34,7 +34,7 @@ struct rockchip_sdhc { static int arasan_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct rockchip_sdhc_plat *plat = dev_get_platdata(dev); + struct rockchip_sdhc_plat *plat = dev_get_plat(dev); struct rockchip_sdhc *prv = dev_get_priv(dev); struct sdhci_host *host = &prv->host; int max_frequency, ret; @@ -81,7 +81,7 @@ static int arasan_sdhci_probe(struct udevice *dev) return sdhci_probe(dev); } -static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) +static int arasan_sdhci_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct sdhci_host *host = dev_get_priv(dev); @@ -96,7 +96,7 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) static int rockchip_sdhci_bind(struct udevice *dev) { - struct rockchip_sdhc_plat *plat = dev_get_platdata(dev); + struct rockchip_sdhc_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -110,10 +110,10 @@ U_BOOT_DRIVER(arasan_sdhci_drv) = { .name = "rockchip_rk3399_sdhci_5_1", .id = UCLASS_MMC, .of_match = arasan_sdhci_ids, - .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata, + .of_to_plat = arasan_sdhci_of_to_plat, .ops = &sdhci_ops, .bind = rockchip_sdhci_bind, .probe = arasan_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct rockchip_sdhc), - .platdata_auto_alloc_size = sizeof(struct rockchip_sdhc_plat), + .priv_auto = sizeof(struct rockchip_sdhc), + .plat_auto = sizeof(struct rockchip_sdhc_plat), }; diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c index 24f599e868..3cf56e0ac4 100644 --- a/drivers/mmc/s5p_sdhci.c +++ b/drivers/mmc/s5p_sdhci.c @@ -192,7 +192,7 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host) #ifdef CONFIG_DM_MMC static int s5p_sdhci_probe(struct udevice *dev) { - struct s5p_sdhci_plat *plat = dev_get_platdata(dev); + struct s5p_sdhci_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct sdhci_host *host = dev_get_priv(dev); int ret; @@ -224,7 +224,7 @@ static int s5p_sdhci_probe(struct udevice *dev) static int s5p_sdhci_bind(struct udevice *dev) { - struct s5p_sdhci_plat *plat = dev_get_platdata(dev); + struct s5p_sdhci_plat *plat = dev_get_plat(dev); int ret; ret = sdhci_bind(dev, &plat->mmc, &plat->cfg); @@ -246,7 +246,7 @@ U_BOOT_DRIVER(s5p_sdhci_drv) = { .bind = s5p_sdhci_bind, .ops = &sdhci_ops, .probe = s5p_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct s5p_sdhci_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct s5p_sdhci_plat), }; #endif /* CONFIG_DM_MMC */ diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c index e86ea8fe09..8a2391d651 100644 --- a/drivers/mmc/sandbox_mmc.c +++ b/drivers/mmc/sandbox_mmc.c @@ -108,14 +108,14 @@ static const struct dm_mmc_ops sandbox_mmc_ops = { int sandbox_mmc_probe(struct udevice *dev) { - struct sandbox_mmc_plat *plat = dev_get_platdata(dev); + struct sandbox_mmc_plat *plat = dev_get_plat(dev); return mmc_init(&plat->mmc); } int sandbox_mmc_bind(struct udevice *dev) { - struct sandbox_mmc_plat *plat = dev_get_platdata(dev); + struct sandbox_mmc_plat *plat = dev_get_plat(dev); struct mmc_config *cfg = &plat->cfg; cfg->name = dev->name; @@ -148,5 +148,5 @@ U_BOOT_DRIVER(mmc_sandbox) = { .bind = sandbox_mmc_bind, .unbind = sandbox_mmc_unbind, .probe = sandbox_mmc_probe, - .platdata_auto_alloc_size = sizeof(struct sandbox_mmc_plat), + .plat_auto = sizeof(struct sandbox_mmc_plat), }; diff --git a/drivers/mmc/sdhci-cadence.c b/drivers/mmc/sdhci-cadence.c index cc99bebc30..2b726c26b8 100644 --- a/drivers/mmc/sdhci-cadence.c +++ b/drivers/mmc/sdhci-cadence.c @@ -135,7 +135,7 @@ static int sdhci_cdns_phy_init(struct sdhci_cdns_plat *plat, static void sdhci_cdns_set_control_reg(struct sdhci_host *host) { struct mmc *mmc = host->mmc; - struct sdhci_cdns_plat *plat = dev_get_platdata(mmc->dev); + struct sdhci_cdns_plat *plat = dev_get_plat(mmc->dev); unsigned int clock = mmc->clock; u32 mode, tmp; @@ -203,7 +203,7 @@ static int sdhci_cdns_set_tune_val(struct sdhci_cdns_plat *plat, static int __maybe_unused sdhci_cdns_execute_tuning(struct udevice *dev, unsigned int opcode) { - struct sdhci_cdns_plat *plat = dev_get_platdata(dev); + struct sdhci_cdns_plat *plat = dev_get_plat(dev); struct mmc *mmc = &plat->mmc; int cur_streak = 0; int max_streak = 0; @@ -246,7 +246,7 @@ static struct dm_mmc_ops sdhci_cdns_mmc_ops; static int sdhci_cdns_bind(struct udevice *dev) { - struct sdhci_cdns_plat *plat = dev_get_platdata(dev); + struct sdhci_cdns_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -255,7 +255,7 @@ static int sdhci_cdns_probe(struct udevice *dev) { DECLARE_GLOBAL_DATA_PTR; struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct sdhci_cdns_plat *plat = dev_get_platdata(dev); + struct sdhci_cdns_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); fdt_addr_t base; int ret; @@ -309,7 +309,7 @@ U_BOOT_DRIVER(sdhci_cdns) = { .of_match = sdhci_cdns_match, .bind = sdhci_cdns_bind, .probe = sdhci_cdns_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct sdhci_cdns_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct sdhci_cdns_plat), .ops = &sdhci_cdns_mmc_ops, }; diff --git a/drivers/mmc/sh_mmcif.c b/drivers/mmc/sh_mmcif.c index ad386909e9..af342f2c29 100644 --- a/drivers/mmc/sh_mmcif.c +++ b/drivers/mmc/sh_mmcif.c @@ -666,14 +666,14 @@ static const struct dm_mmc_ops sh_mmcif_dm_ops = { static int sh_mmcif_dm_bind(struct udevice *dev) { - struct sh_mmcif_plat *plat = dev_get_platdata(dev); + struct sh_mmcif_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } static int sh_mmcif_dm_probe(struct udevice *dev) { - struct sh_mmcif_plat *plat = dev_get_platdata(dev); + struct sh_mmcif_plat *plat = dev_get_plat(dev); struct sh_mmcif_host *host = dev_get_priv(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct clk sh_mmcif_clk; @@ -743,8 +743,8 @@ U_BOOT_DRIVER(sh_mmcif_mmc) = { .of_match = sh_mmcif_sd_match, .bind = sh_mmcif_dm_bind, .probe = sh_mmcif_dm_probe, - .priv_auto_alloc_size = sizeof(struct sh_mmcif_host), - .platdata_auto_alloc_size = sizeof(struct sh_mmcif_plat), + .priv_auto = sizeof(struct sh_mmcif_host), + .plat_auto = sizeof(struct sh_mmcif_plat), .ops = &sh_mmcif_dm_ops, }; #endif diff --git a/drivers/mmc/sh_sdhi.c b/drivers/mmc/sh_sdhi.c index 29f83b6554..b8865b1ca6 100644 --- a/drivers/mmc/sh_sdhi.c +++ b/drivers/mmc/sh_sdhi.c @@ -818,14 +818,14 @@ static const struct dm_mmc_ops sh_sdhi_dm_ops = { static int sh_sdhi_dm_bind(struct udevice *dev) { - struct sh_sdhi_plat *plat = dev_get_platdata(dev); + struct sh_sdhi_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } static int sh_sdhi_dm_probe(struct udevice *dev) { - struct sh_sdhi_plat *plat = dev_get_platdata(dev); + struct sh_sdhi_plat *plat = dev_get_plat(dev); struct sh_sdhi_host *host = dev_get_priv(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct clk sh_sdhi_clk; @@ -902,8 +902,8 @@ U_BOOT_DRIVER(sh_sdhi_mmc) = { .of_match = sh_sdhi_sd_match, .bind = sh_sdhi_dm_bind, .probe = sh_sdhi_dm_probe, - .priv_auto_alloc_size = sizeof(struct sh_sdhi_host), - .platdata_auto_alloc_size = sizeof(struct sh_sdhi_plat), + .priv_auto = sizeof(struct sh_sdhi_host), + .plat_auto = sizeof(struct sh_sdhi_plat), .ops = &sh_sdhi_dm_ops, }; #endif diff --git a/drivers/mmc/snps_dw_mmc.c b/drivers/mmc/snps_dw_mmc.c index 4b468a1f3d..50a8805e73 100644 --- a/drivers/mmc/snps_dw_mmc.c +++ b/drivers/mmc/snps_dw_mmc.c @@ -76,7 +76,7 @@ clk_err: return ret; } -static int snps_dwmmc_ofdata_to_platdata(struct udevice *dev) +static int snps_dwmmc_of_to_plat(struct udevice *dev) { struct snps_dwmci_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -132,7 +132,7 @@ struct dm_mmc_ops snps_dwmci_dm_ops; static int snps_dwmmc_probe(struct udevice *dev) { #ifdef CONFIG_BLK - struct snps_dwmci_plat *plat = dev_get_platdata(dev); + struct snps_dwmci_plat *plat = dev_get_plat(dev); #endif struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct snps_dwmci_priv_data *priv = dev_get_priv(dev); @@ -171,7 +171,7 @@ static int snps_dwmmc_probe(struct udevice *dev) static int snps_dwmmc_bind(struct udevice *dev) { #ifdef CONFIG_BLK - struct snps_dwmci_plat *plat = dev_get_platdata(dev); + struct snps_dwmci_plat *plat = dev_get_plat(dev); int ret; ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); @@ -191,10 +191,10 @@ U_BOOT_DRIVER(snps_dwmmc_drv) = { .name = "snps_dw_mmc", .id = UCLASS_MMC, .of_match = snps_dwmmc_ids, - .ofdata_to_platdata = snps_dwmmc_ofdata_to_platdata, + .of_to_plat = snps_dwmmc_of_to_plat, .ops = &snps_dwmci_dm_ops, .bind = snps_dwmmc_bind, .probe = snps_dwmmc_probe, - .priv_auto_alloc_size = sizeof(struct snps_dwmci_priv_data), - .platdata_auto_alloc_size = sizeof(struct snps_dwmci_plat), + .priv_auto = sizeof(struct snps_dwmci_priv_data), + .plat_auto = sizeof(struct snps_dwmci_plat), }; diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c index 0022f943bd..dc008c5e2f 100644 --- a/drivers/mmc/socfpga_dw_mmc.c +++ b/drivers/mmc/socfpga_dw_mmc.c @@ -95,7 +95,7 @@ static int socfpga_dwmmc_get_clk_rate(struct udevice *dev) return 0; } -static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev) +static int socfpga_dwmmc_of_to_plat(struct udevice *dev) { struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -133,7 +133,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev) static int socfpga_dwmmc_probe(struct udevice *dev) { #ifdef CONFIG_BLK - struct socfpga_dwmci_plat *plat = dev_get_platdata(dev); + struct socfpga_dwmci_plat *plat = dev_get_plat(dev); #endif struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev); @@ -165,7 +165,7 @@ static int socfpga_dwmmc_probe(struct udevice *dev) static int socfpga_dwmmc_bind(struct udevice *dev) { #ifdef CONFIG_BLK - struct socfpga_dwmci_plat *plat = dev_get_platdata(dev); + struct socfpga_dwmci_plat *plat = dev_get_plat(dev); int ret; ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); @@ -185,10 +185,10 @@ U_BOOT_DRIVER(socfpga_dwmmc_drv) = { .name = "socfpga_dwmmc", .id = UCLASS_MMC, .of_match = socfpga_dwmmc_ids, - .ofdata_to_platdata = socfpga_dwmmc_ofdata_to_platdata, + .of_to_plat = socfpga_dwmmc_of_to_plat, .ops = &dm_dwmci_ops, .bind = socfpga_dwmmc_bind, .probe = socfpga_dwmmc_probe, - .priv_auto_alloc_size = sizeof(struct dwmci_socfpga_priv_data), - .platdata_auto_alloc_size = sizeof(struct socfpga_dwmci_plat), + .priv_auto = sizeof(struct dwmci_socfpga_priv_data), + .plat_auto = sizeof(struct socfpga_dwmci_plat), }; diff --git a/drivers/mmc/sti_sdhci.c b/drivers/mmc/sti_sdhci.c index c3a1b34442..8ecd575152 100644 --- a/drivers/mmc/sti_sdhci.c +++ b/drivers/mmc/sti_sdhci.c @@ -35,7 +35,7 @@ struct sti_sdhci_plat { */ static int sti_mmc_core_config(struct udevice *dev) { - struct sti_sdhci_plat *plat = dev_get_platdata(dev); + struct sti_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); int ret; @@ -71,7 +71,7 @@ static int sti_mmc_core_config(struct udevice *dev) static int sti_sdhci_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct sti_sdhci_plat *plat = dev_get_platdata(dev); + struct sti_sdhci_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); int ret; @@ -111,7 +111,7 @@ static int sti_sdhci_probe(struct udevice *dev) return sdhci_probe(dev); } -static int sti_sdhci_ofdata_to_platdata(struct udevice *dev) +static int sti_sdhci_of_to_plat(struct udevice *dev) { struct sdhci_host *host = dev_get_priv(dev); @@ -126,7 +126,7 @@ static int sti_sdhci_ofdata_to_platdata(struct udevice *dev) static int sti_sdhci_bind(struct udevice *dev) { - struct sti_sdhci_plat *plat = dev_get_platdata(dev); + struct sti_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -142,8 +142,8 @@ U_BOOT_DRIVER(sti_mmc) = { .of_match = sti_sdhci_ids, .bind = sti_sdhci_bind, .ops = &sdhci_ops, - .ofdata_to_platdata = sti_sdhci_ofdata_to_platdata, + .of_to_plat = sti_sdhci_of_to_plat, .probe = sti_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct sti_sdhci_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct sti_sdhci_plat), }; diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c index 1f1b6cf4fb..3246f6b5e0 100644 --- a/drivers/mmc/stm32_sdmmc2.c +++ b/drivers/mmc/stm32_sdmmc2.c @@ -644,7 +644,7 @@ static const struct dm_mmc_ops stm32_sdmmc2_ops = { static int stm32_sdmmc2_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct stm32_sdmmc2_plat *plat = dev_get_platdata(dev); + struct stm32_sdmmc2_plat *plat = dev_get_plat(dev); struct stm32_sdmmc2_priv *priv = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; int ret; @@ -700,7 +700,7 @@ clk_free: static int stm32_sdmmc_bind(struct udevice *dev) { - struct stm32_sdmmc2_plat *plat = dev_get_platdata(dev); + struct stm32_sdmmc2_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -717,6 +717,6 @@ U_BOOT_DRIVER(stm32_sdmmc2) = { .ops = &stm32_sdmmc2_ops, .probe = stm32_sdmmc2_probe, .bind = stm32_sdmmc_bind, - .priv_auto_alloc_size = sizeof(struct stm32_sdmmc2_priv), - .platdata_auto_alloc_size = sizeof(struct stm32_sdmmc2_plat), + .priv_auto = sizeof(struct stm32_sdmmc2_priv), + .plat_auto = sizeof(struct stm32_sdmmc2_plat), }; diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c index 0e03b07ce5..b33f80b9da 100644 --- a/drivers/mmc/sunxi_mmc.c +++ b/drivers/mmc/sunxi_mmc.c @@ -572,7 +572,7 @@ struct mmc *sunxi_mmc_init(int sdc_no) static int sunxi_mmc_set_ios(struct udevice *dev) { - struct sunxi_mmc_plat *plat = dev_get_platdata(dev); + struct sunxi_mmc_plat *plat = dev_get_plat(dev); struct sunxi_mmc_priv *priv = dev_get_priv(dev); return sunxi_mmc_set_ios_common(priv, &plat->mmc); @@ -581,7 +581,7 @@ static int sunxi_mmc_set_ios(struct udevice *dev) static int sunxi_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) { - struct sunxi_mmc_plat *plat = dev_get_platdata(dev); + struct sunxi_mmc_plat *plat = dev_get_plat(dev); struct sunxi_mmc_priv *priv = dev_get_priv(dev); return sunxi_mmc_send_cmd_common(priv, &plat->mmc, cmd, data); @@ -608,7 +608,7 @@ static const struct dm_mmc_ops sunxi_mmc_ops = { static int sunxi_mmc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct sunxi_mmc_plat *plat = dev_get_platdata(dev); + struct sunxi_mmc_plat *plat = dev_get_plat(dev); struct sunxi_mmc_priv *priv = dev_get_priv(dev); struct reset_ctl_bulk reset_bulk; struct clk gate_clk; @@ -682,7 +682,7 @@ static int sunxi_mmc_probe(struct udevice *dev) static int sunxi_mmc_bind(struct udevice *dev) { - struct sunxi_mmc_plat *plat = dev_get_platdata(dev); + struct sunxi_mmc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -746,7 +746,7 @@ U_BOOT_DRIVER(sunxi_mmc_drv) = { .bind = sunxi_mmc_bind, .probe = sunxi_mmc_probe, .ops = &sunxi_mmc_ops, - .platdata_auto_alloc_size = sizeof(struct sunxi_mmc_plat), - .priv_auto_alloc_size = sizeof(struct sunxi_mmc_priv), + .plat_auto = sizeof(struct sunxi_mmc_plat), + .priv_auto = sizeof(struct sunxi_mmc_priv), }; #endif diff --git a/drivers/mmc/tangier_sdhci.c b/drivers/mmc/tangier_sdhci.c index 879e2c98a2..1156427332 100644 --- a/drivers/mmc/tangier_sdhci.c +++ b/drivers/mmc/tangier_sdhci.c @@ -22,7 +22,7 @@ struct sdhci_tangier_plat { static int sdhci_tangier_bind(struct udevice *dev) { - struct sdhci_tangier_plat *plat = dev_get_platdata(dev); + struct sdhci_tangier_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -30,7 +30,7 @@ static int sdhci_tangier_bind(struct udevice *dev) static int sdhci_tangier_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct sdhci_tangier_plat *plat = dev_get_platdata(dev); + struct sdhci_tangier_plat *plat = dev_get_plat(dev); struct sdhci_host *host = dev_get_priv(dev); fdt_addr_t base; int ret; @@ -76,6 +76,6 @@ U_BOOT_DRIVER(sdhci_tangier) = { .bind = sdhci_tangier_bind, .probe = sdhci_tangier_probe, .ops = &sdhci_ops, - .priv_auto_alloc_size = sizeof(struct sdhci_host), - .platdata_auto_alloc_size = sizeof(struct sdhci_tangier_plat), + .priv_auto = sizeof(struct sdhci_host), + .plat_auto = sizeof(struct sdhci_tangier_plat), }; diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c index cc78a2f2f0..760eca4059 100644 --- a/drivers/mmc/tegra_mmc.c +++ b/drivers/mmc/tegra_mmc.c @@ -680,7 +680,7 @@ static const struct dm_mmc_ops tegra_mmc_ops = { static int tegra_mmc_probe(struct udevice *dev) { struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); - struct tegra_mmc_plat *plat = dev_get_platdata(dev); + struct tegra_mmc_plat *plat = dev_get_plat(dev); struct tegra_mmc_priv *priv = dev_get_priv(dev); struct mmc_config *cfg = &plat->cfg; int bus_width, ret; @@ -749,7 +749,7 @@ static int tegra_mmc_probe(struct udevice *dev) static int tegra_mmc_bind(struct udevice *dev) { - struct tegra_mmc_plat *plat = dev_get_platdata(dev); + struct tegra_mmc_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } @@ -771,6 +771,6 @@ U_BOOT_DRIVER(tegra_mmc_drv) = { .bind = tegra_mmc_bind, .probe = tegra_mmc_probe, .ops = &tegra_mmc_ops, - .platdata_auto_alloc_size = sizeof(struct tegra_mmc_plat), - .priv_auto_alloc_size = sizeof(struct tegra_mmc_priv), + .plat_auto = sizeof(struct tegra_mmc_plat), + .priv_auto = sizeof(struct tegra_mmc_priv), }; diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c index c653973676..2c528689bd 100644 --- a/drivers/mmc/tmio-common.c +++ b/drivers/mmc/tmio-common.c @@ -708,14 +708,14 @@ static void tmio_sd_host_init(struct tmio_sd_priv *priv) int tmio_sd_bind(struct udevice *dev) { - struct tmio_sd_plat *plat = dev_get_platdata(dev); + struct tmio_sd_plat *plat = dev_get_plat(dev); return mmc_bind(dev, &plat->mmc, &plat->cfg); } int tmio_sd_probe(struct udevice *dev, u32 quirks) { - struct tmio_sd_plat *plat = dev_get_platdata(dev); + struct tmio_sd_plat *plat = dev_get_plat(dev); struct tmio_sd_priv *priv = dev_get_priv(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); fdt_addr_t base; diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c index 4dbe71fa2e..75003a0113 100644 --- a/drivers/mmc/uniphier-sd.c +++ b/drivers/mmc/uniphier-sd.c @@ -84,7 +84,7 @@ U_BOOT_DRIVER(uniphier_mmc) = { .of_match = uniphier_sd_match, .bind = tmio_sd_bind, .probe = uniphier_sd_probe, - .priv_auto_alloc_size = sizeof(struct tmio_sd_priv), - .platdata_auto_alloc_size = sizeof(struct tmio_sd_plat), + .priv_auto = sizeof(struct tmio_sd_priv), + .plat_auto = sizeof(struct tmio_sd_plat), .ops = &uniphier_sd_ops, }; diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c index 6ce9d00d0a..b8e833e6a3 100644 --- a/drivers/mmc/xenon_sdhci.c +++ b/drivers/mmc/xenon_sdhci.c @@ -442,7 +442,7 @@ static const struct sdhci_ops xenon_sdhci_ops = { static int xenon_sdhci_probe(struct udevice *dev) { - struct xenon_sdhci_plat *plat = dev_get_platdata(dev); + struct xenon_sdhci_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct xenon_sdhci_priv *priv = dev_get_priv(dev); struct sdhci_host *host = dev_get_priv(dev); @@ -515,7 +515,7 @@ static int xenon_sdhci_probe(struct udevice *dev) return ret; } -static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev) +static int xenon_sdhci_of_to_plat(struct udevice *dev) { struct sdhci_host *host = dev_get_priv(dev); struct xenon_sdhci_priv *priv = dev_get_priv(dev); @@ -545,7 +545,7 @@ static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev) static int xenon_sdhci_bind(struct udevice *dev) { - struct xenon_sdhci_plat *plat = dev_get_platdata(dev); + struct xenon_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -560,10 +560,10 @@ U_BOOT_DRIVER(xenon_sdhci_drv) = { .name = "xenon_sdhci", .id = UCLASS_MMC, .of_match = xenon_sdhci_ids, - .ofdata_to_platdata = xenon_sdhci_ofdata_to_platdata, + .of_to_plat = xenon_sdhci_of_to_plat, .ops = &sdhci_ops, .bind = xenon_sdhci_bind, .probe = xenon_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct xenon_sdhci_priv), - .platdata_auto_alloc_size = sizeof(struct xenon_sdhci_plat), + .priv_auto = sizeof(struct xenon_sdhci_priv), + .plat_auto = sizeof(struct xenon_sdhci_plat), }; diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 147ecc0d70..d9ad0ff199 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -552,7 +552,7 @@ const struct sdhci_ops arasan_ops = { static int arasan_sdhci_probe(struct udevice *dev) { - struct arasan_sdhci_plat *plat = dev_get_platdata(dev); + struct arasan_sdhci_plat *plat = dev_get_plat(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct arasan_sdhci_priv *priv = dev_get_priv(dev); struct sdhci_host *host; @@ -613,7 +613,7 @@ static int arasan_sdhci_probe(struct udevice *dev) return sdhci_probe(dev); } -static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) +static int arasan_sdhci_of_to_plat(struct udevice *dev) { struct arasan_sdhci_priv *priv = dev_get_priv(dev); @@ -641,7 +641,7 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) static int arasan_sdhci_bind(struct udevice *dev) { - struct arasan_sdhci_plat *plat = dev_get_platdata(dev); + struct arasan_sdhci_plat *plat = dev_get_plat(dev); return sdhci_bind(dev, &plat->mmc, &plat->cfg); } @@ -655,10 +655,10 @@ U_BOOT_DRIVER(arasan_sdhci_drv) = { .name = "arasan_sdhci", .id = UCLASS_MMC, .of_match = arasan_sdhci_ids, - .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata, + .of_to_plat = arasan_sdhci_of_to_plat, .ops = &sdhci_ops, .bind = arasan_sdhci_bind, .probe = arasan_sdhci_probe, - .priv_auto_alloc_size = sizeof(struct arasan_sdhci_priv), - .platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat), + .priv_auto = sizeof(struct arasan_sdhci_priv), + .plat_auto = sizeof(struct arasan_sdhci_plat), }; diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c index cd4d32959a..0011811250 100644 --- a/drivers/mtd/altera_qspi.c +++ b/drivers/mtd/altera_qspi.c @@ -48,7 +48,7 @@ struct altera_qspi_regs { u32 chip_select; }; -struct altera_qspi_platdata { +struct altera_qspi_plat { struct altera_qspi_regs *regs; void *base; unsigned long size; @@ -106,7 +106,7 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt) { struct mtd_info *mtd = info->mtd; struct udevice *dev = mtd->dev; - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); ulong base = (ulong)pdata->base; loff_t to = addr - base; size_t retlen; @@ -135,7 +135,7 @@ unsigned long flash_init(void) static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr) { struct udevice *dev = mtd->dev; - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); struct altera_qspi_regs *regs = pdata->regs; size_t addr = instr->addr; size_t len = instr->len; @@ -197,7 +197,7 @@ static int altera_qspi_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { struct udevice *dev = mtd->dev; - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); memcpy_fromio(buf, pdata->base + from, len); *retlen = len; @@ -209,7 +209,7 @@ static int altera_qspi_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { struct udevice *dev = mtd->dev; - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); struct altera_qspi_regs *regs = pdata->regs; u32 stat; @@ -235,7 +235,7 @@ static void altera_qspi_get_locked_range(struct mtd_info *mtd, loff_t *ofs, uint64_t *len) { struct udevice *dev = mtd->dev; - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); struct altera_qspi_regs *regs = pdata->regs; int shift0 = ffs(QUADSPI_SR_BP2_0) - 1; int shift3 = ffs(QUADSPI_SR_BP3) - 1 - 3; @@ -257,7 +257,7 @@ static void altera_qspi_get_locked_range(struct mtd_info *mtd, loff_t *ofs, static int altera_qspi_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { struct udevice *dev = mtd->dev; - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); struct altera_qspi_regs *regs = pdata->regs; u32 sector_start, sector_end; u32 num_sectors; @@ -291,7 +291,7 @@ static int altera_qspi_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) static int altera_qspi_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { struct udevice *dev = mtd->dev; - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); struct altera_qspi_regs *regs = pdata->regs; u32 mem_op; @@ -304,7 +304,7 @@ static int altera_qspi_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) static int altera_qspi_probe(struct udevice *dev) { - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); struct altera_qspi_regs *regs = pdata->regs; unsigned long base = (unsigned long)pdata->base; struct mtd_info *mtd; @@ -346,9 +346,9 @@ static int altera_qspi_probe(struct udevice *dev) return 0; } -static int altera_qspi_ofdata_to_platdata(struct udevice *dev) +static int altera_qspi_of_to_plat(struct udevice *dev) { - struct altera_qspi_platdata *pdata = dev_get_platdata(dev); + struct altera_qspi_plat *pdata = dev_get_plat(dev); void *blob = (void *)gd->fdt_blob; int node = dev_of_offset(dev); const char *list, *end; @@ -400,7 +400,7 @@ U_BOOT_DRIVER(altera_qspi) = { .name = "altera_qspi", .id = UCLASS_MTD, .of_match = altera_qspi_ids, - .ofdata_to_platdata = altera_qspi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_qspi_platdata), + .of_to_plat = altera_qspi_of_to_plat, + .plat_auto = sizeof(struct altera_qspi_plat), .probe = altera_qspi_probe, }; diff --git a/drivers/mtd/hbmc-am654.c b/drivers/mtd/hbmc-am654.c index 846b0e832b..c86e504da3 100644 --- a/drivers/mtd/hbmc-am654.c +++ b/drivers/mtd/hbmc-am654.c @@ -102,5 +102,5 @@ U_BOOT_DRIVER(hbmc_am654) = { .of_match = am654_hbmc_dt_ids, .probe = am654_hbmc_probe, .bind = am654_hbmc_bind, - .priv_auto_alloc_size = sizeof(struct am654_hbmc_priv), + .priv_auto = sizeof(struct am654_hbmc_priv), }; diff --git a/drivers/mtd/mtd-uclass.c b/drivers/mtd/mtd-uclass.c index 5418217431..9f5f672ba3 100644 --- a/drivers/mtd/mtd-uclass.c +++ b/drivers/mtd/mtd-uclass.c @@ -32,5 +32,5 @@ int mtd_probe(struct udevice *dev) UCLASS_DRIVER(mtd) = { .id = UCLASS_MTD, .name = "mtd", - .per_device_auto_alloc_size = sizeof(struct mtd_info), + .per_device_auto = sizeof(struct mtd_info), }; diff --git a/drivers/mtd/nand/raw/arasan_nfc.c b/drivers/mtd/nand/raw/arasan_nfc.c index 0615e50378..4621bfb03e 100644 --- a/drivers/mtd/nand/raw/arasan_nfc.c +++ b/drivers/mtd/nand/raw/arasan_nfc.c @@ -1310,7 +1310,7 @@ U_BOOT_DRIVER(arasan_nand) = { .id = UCLASS_MTD, .of_match = arasan_nand_dt_ids, .probe = arasan_probe, - .priv_auto_alloc_size = sizeof(struct arasan_nand_info), + .priv_auto = sizeof(struct arasan_nand_info), }; void board_nand_init(void) @@ -1319,7 +1319,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(arasan_nand), &dev); + DM_DRIVER_GET(arasan_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); } diff --git a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c index 6313403cd6..aa095c439b 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c @@ -109,7 +109,7 @@ U_BOOT_DRIVER(bcm63158_nand) = { .id = UCLASS_MTD, .of_match = bcm63158_nand_dt_ids, .probe = bcm63158_nand_probe, - .priv_auto_alloc_size = sizeof(struct bcm63158_nand_soc), + .priv_auto = sizeof(struct bcm63158_nand_soc), }; void board_nand_init(void) @@ -118,7 +118,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(bcm63158_nand), &dev); + DM_DRIVER_GET(bcm63158_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c index cd4b24a51a..e4bf193681 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c @@ -102,7 +102,7 @@ U_BOOT_DRIVER(bcm6368_nand) = { .id = UCLASS_MTD, .of_match = bcm6368_nand_dt_ids, .probe = bcm6368_nand_probe, - .priv_auto_alloc_size = sizeof(struct bcm6368_nand_soc), + .priv_auto = sizeof(struct bcm6368_nand_soc), }; void board_nand_init(void) @@ -111,7 +111,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(bcm6368_nand), &dev); + DM_DRIVER_GET(bcm6368_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); diff --git a/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c index aa042bef15..586ea3d8fb 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c @@ -108,7 +108,7 @@ U_BOOT_DRIVER(bcm68360_nand) = { .id = UCLASS_MTD, .of_match = bcm68360_nand_dt_ids, .probe = bcm68360_nand_probe, - .priv_auto_alloc_size = sizeof(struct bcm68360_nand_soc), + .priv_auto = sizeof(struct bcm68360_nand_soc), }; void board_nand_init(void) @@ -117,7 +117,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(bcm68360_nand), &dev); + DM_DRIVER_GET(bcm68360_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c index 0788455090..85f318bd77 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c @@ -108,7 +108,7 @@ U_BOOT_DRIVER(bcm6838_nand) = { .id = UCLASS_MTD, .of_match = bcm6838_nand_dt_ids, .probe = bcm6838_nand_probe, - .priv_auto_alloc_size = sizeof(struct bcm6838_nand_soc), + .priv_auto = sizeof(struct bcm6838_nand_soc), }; void board_nand_init(void) @@ -117,7 +117,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(bcm6838_nand), &dev); + DM_DRIVER_GET(bcm6838_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c index 818eae8a7c..a5e159ad52 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c @@ -109,7 +109,7 @@ U_BOOT_DRIVER(bcm6858_nand) = { .id = UCLASS_MTD, .of_match = bcm6858_nand_dt_ids, .probe = bcm6858_nand_probe, - .priv_auto_alloc_size = sizeof(struct bcm6858_nand_soc), + .priv_auto = sizeof(struct bcm6858_nand_soc), }; void board_nand_init(void) @@ -118,7 +118,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(bcm6858_nand), &dev); + DM_DRIVER_GET(bcm6858_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c index 4416b8fa1e..9ad3a57690 100644 --- a/drivers/mtd/nand/raw/davinci_nand.c +++ b/drivers/mtd/nand/raw/davinci_nand.c @@ -816,7 +816,7 @@ U_BOOT_DRIVER(davinci_nand) = { .id = UCLASS_MTD, .of_match = davinci_nand_ids, .probe = davinci_nand_probe, - .priv_auto_alloc_size = sizeof(struct nand_chip), + .priv_auto = sizeof(struct nand_chip), }; void board_nand_init(void) @@ -825,7 +825,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(davinci_nand), &dev); + DM_DRIVER_GET(davinci_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s: %d\n", dev->name, ret); } diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c index 8318ff507f..cf4df0168a 100644 --- a/drivers/mtd/nand/raw/denali_dt.c +++ b/drivers/mtd/nand/raw/denali_dt.c @@ -172,7 +172,7 @@ U_BOOT_DRIVER(denali_nand_dt) = { .id = UCLASS_MTD, .of_match = denali_nand_dt_ids, .probe = denali_dt_probe, - .priv_auto_alloc_size = sizeof(struct denali_nand_info), + .priv_auto = sizeof(struct denali_nand_info), }; void board_nand_init(void) @@ -181,7 +181,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(denali_nand_dt), + DM_DRIVER_GET(denali_nand_dt), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize Denali NAND controller. (error %d)\n", diff --git a/drivers/mtd/nand/raw/mxs_nand_dt.c b/drivers/mtd/nand/raw/mxs_nand_dt.c index 43dbe9e66e..878796d555 100644 --- a/drivers/mtd/nand/raw/mxs_nand_dt.c +++ b/drivers/mtd/nand/raw/mxs_nand_dt.c @@ -168,7 +168,7 @@ U_BOOT_DRIVER(mxs_nand_dt) = { .id = UCLASS_MTD, .of_match = mxs_nand_dt_ids, .probe = mxs_nand_dt_probe, - .priv_auto_alloc_size = sizeof(struct mxs_nand_info), + .priv_auto = sizeof(struct mxs_nand_info), }; void board_nand_init(void) @@ -177,7 +177,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(mxs_nand_dt), + DM_DRIVER_GET(mxs_nand_dt), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize MXS NAND controller. (error %d)\n", diff --git a/drivers/mtd/nand/raw/octeontx_bch.c b/drivers/mtd/nand/raw/octeontx_bch.c index 693706257c..a41772880f 100644 --- a/drivers/mtd/nand/raw/octeontx_bch.c +++ b/drivers/mtd/nand/raw/octeontx_bch.c @@ -410,7 +410,7 @@ U_BOOT_DRIVER(octeontx_pci_bchpf) = { .id = UCLASS_MISC, .probe = octeontx_pci_bchpf_probe, .remove = octeontx_pci_bchpf_remove, - .priv_auto_alloc_size = sizeof(struct bch_device), + .priv_auto = sizeof(struct bch_device), .flags = DM_FLAG_OS_PREPARE, }; @@ -418,7 +418,7 @@ U_BOOT_DRIVER(octeontx_pci_bchvf) = { .name = BCHVF_DRIVER_NAME, .id = UCLASS_MISC, .probe = octeontx_pci_bchvf_probe, - .priv_auto_alloc_size = sizeof(struct bch_vf), + .priv_auto = sizeof(struct bch_vf), }; U_BOOT_PCI_DEVICE(octeontx_pci_bchpf, octeontx_bchpf_pci_id_table); diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c index ad219171e9..9997135ef9 100644 --- a/drivers/mtd/nand/raw/octeontx_nand.c +++ b/drivers/mtd/nand/raw/octeontx_nand.c @@ -1999,7 +1999,7 @@ static int octeontx_nfc_chip_init(struct octeontx_nfc *tn, struct udevice *dev, static int octeontx_nfc_chips_init(struct octeontx_nfc *tn) { struct udevice *dev = tn->dev; - ofnode node = dev->node; + ofnode node = dev_ofnode(dev); ofnode nand_node; int nr_chips = of_get_child_count(node); int ret; @@ -2187,7 +2187,7 @@ int octeontx_pci_nand_deferred_probe(void) debug("%s: Performing deferred probing\n", __func__); list_for_each_entry(pdev, &octeontx_pci_nand_deferred_devices, list) { debug("%s: Probing %s\n", __func__, pdev->dev->name); - pdev->dev->flags &= ~DM_FLAG_ACTIVATED; + dev_get_flags(pdev->dev) &= ~DM_FLAG_ACTIVATED; rc = device_probe(pdev->dev); if (rc && rc != -ENODEV) { printf("%s: Error %d with deferred probe of %s\n", @@ -2203,7 +2203,7 @@ static const struct pci_device_id octeontx_nfc_pci_id_table[] = { {} }; -static int octeontx_nand_ofdata_to_platdata(struct udevice *dev) +static int octeontx_nand_of_to_plat(struct udevice *dev) { return 0; } @@ -2217,9 +2217,9 @@ U_BOOT_DRIVER(octeontx_pci_nand) = { .name = OCTEONTX_NAND_DRIVER_NAME, .id = UCLASS_MTD, .of_match = of_match_ptr(octeontx_nand_ids), - .ofdata_to_platdata = octeontx_nand_ofdata_to_platdata, + .of_to_plat = octeontx_nand_of_to_plat, .probe = octeontx_pci_nand_probe, - .priv_auto_alloc_size = sizeof(struct octeontx_nfc), + .priv_auto = sizeof(struct octeontx_nfc), .remove = octeontx_pci_nand_disable, .flags = DM_FLAG_OS_PREPARE, }; @@ -2233,14 +2233,14 @@ void board_nand_init(void) if (IS_ENABLED(CONFIG_NAND_OCTEONTX_HW_ECC)) { ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(octeontx_pci_bchpf), + DM_DRIVER_GET(octeontx_pci_bchpf), &dev); if (ret && ret != -ENODEV) { pr_err("Failed to initialize OcteonTX BCH PF controller. (error %d)\n", ret); } ret = uclass_get_device_by_driver(UCLASS_MISC, - DM_GET_DRIVER(octeontx_pci_bchvf), + DM_DRIVER_GET(octeontx_pci_bchvf), &dev); if (ret && ret != -ENODEV) { pr_err("Failed to initialize OcteonTX BCH VF controller. (error %d)\n", @@ -2249,7 +2249,7 @@ void board_nand_init(void) } ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(octeontx_pci_nand), + DM_DRIVER_GET(octeontx_pci_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize OcteonTX NAND controller. (error %d)\n", diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c b/drivers/mtd/nand/raw/pxa3xx_nand.c index 361a9e3293..f6233756d8 100644 --- a/drivers/mtd/nand/raw/pxa3xx_nand.c +++ b/drivers/mtd/nand/raw/pxa3xx_nand.c @@ -1937,7 +1937,7 @@ U_BOOT_DRIVER(pxa3xx_nand) = { .id = UCLASS_MTD, .of_match = pxa3xx_nand_dt_ids, .probe = pxa3xx_nand_probe, - .priv_auto_alloc_size = sizeof(struct pxa3xx_nand_info) + + .priv_auto = sizeof(struct pxa3xx_nand_info) + sizeof(struct pxa3xx_nand_host) * CONFIG_SYS_MAX_NAND_DEVICE, }; @@ -1947,7 +1947,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(pxa3xx_nand), &dev); + DM_DRIVER_GET(pxa3xx_nand), &dev); if (ret && ret != -ENODEV) { pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index 47fe61090d..b8561b2516 100644 --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c @@ -1033,7 +1033,7 @@ U_BOOT_DRIVER(stm32_fmc2_nfc) = { .id = UCLASS_MTD, .of_match = stm32_fmc2_nfc_match, .probe = stm32_fmc2_nfc_probe, - .priv_auto_alloc_size = sizeof(struct stm32_fmc2_nfc), + .priv_auto = sizeof(struct stm32_fmc2_nfc), }; void board_nand_init(void) @@ -1042,7 +1042,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(stm32_fmc2_nfc), + DM_DRIVER_GET(stm32_fmc2_nfc), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize STM32 FMC2 NFC controller. (error %d)\n", diff --git a/drivers/mtd/nand/raw/tegra_nand.c b/drivers/mtd/nand/raw/tegra_nand.c index b9f5bdd953..a530127cb7 100644 --- a/drivers/mtd/nand/raw/tegra_nand.c +++ b/drivers/mtd/nand/raw/tegra_nand.c @@ -990,7 +990,7 @@ U_BOOT_DRIVER(tegra_nand) = { .id = UCLASS_MTD, .of_match = tegra_nand_dt_ids, .probe = tegra_probe, - .priv_auto_alloc_size = sizeof(struct tegra_nand_info), + .priv_auto = sizeof(struct tegra_nand_info), }; void board_nand_init(void) @@ -999,7 +999,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(tegra_nand), &dev); + DM_DRIVER_GET(tegra_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c index 4e6fdc607f..e33953ec7c 100644 --- a/drivers/mtd/nand/raw/vf610_nfc.c +++ b/drivers/mtd/nand/raw/vf610_nfc.c @@ -784,7 +784,7 @@ U_BOOT_DRIVER(vf610_nfc_dt) = { .name = "vf610-nfc-dt", .id = UCLASS_MTD, .of_match = vf610_nfc_dt_ids, - .priv_auto_alloc_size = sizeof(struct vf610_nfc), + .priv_auto = sizeof(struct vf610_nfc), .probe = vf610_nfc_dt_probe, }; @@ -794,7 +794,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(vf610_nfc_dt), + DM_DRIVER_GET(vf610_nfc_dt), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize NAND controller. (error %d)\n", diff --git a/drivers/mtd/nand/raw/zynq_nand.c b/drivers/mtd/nand/raw/zynq_nand.c index 92db2aa19c..d792528370 100644 --- a/drivers/mtd/nand/raw/zynq_nand.c +++ b/drivers/mtd/nand/raw/zynq_nand.c @@ -1206,12 +1206,10 @@ static int zynq_nand_probe(struct udevice *dev) nand_chip->options |= NAND_SUBPAGE_READ; /* On-Die ECC spare bytes offset 8 is used for ECC codes */ - if (ondie_ecc_enabled) { - nand_chip->ecc.layout = &ondie_nand_oob_64; - /* Use the BBT pattern descriptors */ - nand_chip->bbt_td = &bbt_main_descr; - nand_chip->bbt_md = &bbt_mirror_descr; - } + nand_chip->ecc.layout = &ondie_nand_oob_64; + /* Use the BBT pattern descriptors */ + nand_chip->bbt_td = &bbt_main_descr; + nand_chip->bbt_md = &bbt_mirror_descr; } else { /* Hardware ECC generates 3 bytes ECC code for each 512 bytes */ nand_chip->ecc.mode = NAND_ECC_HW; @@ -1286,7 +1284,7 @@ U_BOOT_DRIVER(zynq_nand) = { .id = UCLASS_MTD, .of_match = zynq_nand_dt_ids, .probe = zynq_nand_probe, - .priv_auto_alloc_size = sizeof(struct zynq_nand_info), + .priv_auto = sizeof(struct zynq_nand_info), }; void board_nand_init(void) @@ -1295,7 +1293,7 @@ void board_nand_init(void) int ret; ret = uclass_get_device_by_driver(UCLASS_MTD, - DM_GET_DRIVER(zynq_nand), &dev); + DM_DRIVER_GET(zynq_nand), &dev); if (ret && ret != -ENODEV) pr_err("Failed to initialize %s. (error %d)\n", dev->name, ret); } diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 36d040038e..68ef5d1af8 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1165,7 +1165,7 @@ static int spinand_probe(struct udevice *dev) return -ENOMEM; sprintf(mtd->name, "spi-nand%d", spi_nand_idx++); spinand->slave = slave; - spinand_set_of_node(spinand, dev->node.np); + spinand_set_ofnode(spinand, dev_ofnode(dev)); #endif ret = spinand_init(spinand); @@ -1247,6 +1247,6 @@ U_BOOT_DRIVER(spinand) = { .name = "spi_nand", .id = UCLASS_MTD, .of_match = spinand_ids, - .priv_auto_alloc_size = sizeof(struct spinand_device), + .priv_auto = sizeof(struct spinand_device), .probe = spinand_probe, }; diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig index 018e8c597e..ea444436ad 100644 --- a/drivers/mtd/spi/Kconfig +++ b/drivers/mtd/spi/Kconfig @@ -63,7 +63,7 @@ config SF_DEFAULT_MODE to handle the common case when only a single serial flash is present on the system. Not used for boot with device tree; the SPI driver reads - speed and mode from platdata values computed from + speed and mode from plat values computed from available node. config SF_DEFAULT_SPEED @@ -75,7 +75,7 @@ config SF_DEFAULT_SPEED to handle the common case when only a single serial flash is present on the system. Not used for boot with device tree; the SPI driver reads - speed and mode from platdata values computed from + speed and mode from plat values computed from available node. if SPI_FLASH diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c index 0b602dc914..3c01e3b41c 100644 --- a/drivers/mtd/spi/sandbox.c +++ b/drivers/mtd/spi/sandbox.c @@ -122,23 +122,23 @@ static int sandbox_sf_probe(struct udevice *dev) struct sandbox_spi_flash *sbsf = dev_get_priv(dev); size_t len, idname_len; const struct flash_info *data; - struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); + struct sandbox_spi_flash_plat_data *pdata = dev_get_plat(dev); struct sandbox_state *state = state_get_current(); - struct dm_spi_slave_platdata *slave_plat; + struct dm_spi_slave_plat *slave_plat; struct udevice *bus = dev->parent; const char *spec = NULL; struct udevice *emul; int ret = 0; int cs = -1; - debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev); + debug("%s: bus %d, looking for emul=%p: ", __func__, dev_seq(bus), dev); ret = sandbox_spi_get_emul(state, bus, dev, &emul); if (ret) { printf("Error: Unknown chip select for device '%s'\n", dev->name); return ret; } - slave_plat = dev_get_parent_platdata(dev); + slave_plat = dev_get_parent_plat(dev); cs = slave_plat->cs; debug("found at cs %d\n", cs); @@ -498,9 +498,9 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen, return pos == bytes ? 0 : -EIO; } -int sandbox_sf_ofdata_to_platdata(struct udevice *dev) +int sandbox_sf_of_to_plat(struct udevice *dev) { - struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); + struct sandbox_spi_flash_plat_data *pdata = dev_get_plat(dev); pdata->filename = dev_read_string(dev, "sandbox,filename"); pdata->device_name = dev_read_string(dev, "compatible"); @@ -538,7 +538,7 @@ int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs, str = strdup(name); if (!str) return -ENOMEM; - ret = device_bind_ofnode(bus, drv, str, NULL, node, &emul); + ret = device_bind(bus, drv, str, NULL, node, &emul); if (ret) { free(str); printf("Cannot create emul device for spec '%s' (err=%d)\n", @@ -565,7 +565,7 @@ int sandbox_spi_get_emul(struct sandbox_state *state, struct udevice **emulp) { struct sandbox_spi_info *info; - int busnum = bus->seq; + int busnum = dev_seq(bus); int cs = spi_chip_select(slave); int ret; @@ -597,10 +597,10 @@ U_BOOT_DRIVER(sandbox_sf_emul) = { .name = "sandbox_sf_emul", .id = UCLASS_SPI_EMUL, .of_match = sandbox_sf_ids, - .ofdata_to_platdata = sandbox_sf_ofdata_to_platdata, + .of_to_plat = sandbox_sf_of_to_plat, .probe = sandbox_sf_probe, .remove = sandbox_sf_remove, - .priv_auto_alloc_size = sizeof(struct sandbox_spi_flash), - .platdata_auto_alloc_size = sizeof(struct sandbox_spi_flash_plat_data), + .priv_auto = sizeof(struct sandbox_spi_flash), + .plat_auto = sizeof(struct sandbox_spi_flash_plat_data), .ops = &sandbox_sf_emul_ops, }; diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c index 09c11439b0..3017022abb 100644 --- a/drivers/mtd/spi/sf-uclass.c +++ b/drivers/mtd/spi/sf-uclass.c @@ -100,5 +100,5 @@ UCLASS_DRIVER(spi_flash) = { .id = UCLASS_SPI_FLASH, .name = "spi_flash", .post_bind = spi_flash_post_bind, - .per_device_auto_alloc_size = sizeof(struct spi_flash), + .per_device_auto = sizeof(struct spi_nor), }; diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c index 27d847d421..b59edd152c 100644 --- a/drivers/mtd/spi/sf_dataflash.c +++ b/drivers/mtd/spi/sf_dataflash.c @@ -693,6 +693,6 @@ U_BOOT_DRIVER(spi_dataflash) = { .id = UCLASS_SPI_FLASH, .of_match = spi_dataflash_ids, .probe = spi_dataflash_probe, - .priv_auto_alloc_size = sizeof(struct dataflash), + .priv_auto = sizeof(struct dataflash), .ops = &spi_dataflash_ops, }; diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index b959e3453a..6c87434867 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -166,10 +166,10 @@ U_BOOT_DRIVER(jedec_spi_nor) = { .of_match = spi_flash_std_ids, .probe = spi_flash_std_probe, .remove = spi_flash_std_remove, - .priv_auto_alloc_size = sizeof(struct spi_flash), + .priv_auto = sizeof(struct spi_nor), .ops = &spi_flash_std_ops, }; -U_BOOT_DRIVER_ALIAS(jedec_spi_nor, spansion_m25p16) +DM_DRIVER_ALIAS(jedec_spi_nor, spansion_m25p16) #endif /* CONFIG_DM_SPI_FLASH */ diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c index b9868505a3..00e0282dcc 100644 --- a/drivers/mux/mmio.c +++ b/drivers/mux/mmio.c @@ -12,6 +12,7 @@ #include <regmap.h> #include <syscon.h> #include <dm/device.h> +#include <dm/device-internal.h> #include <dm/device_compat.h> #include <dm/read.h> #include <dm/devres.h> @@ -68,7 +69,7 @@ static int mmio_mux_probe(struct udevice *dev) fields = devm_kmalloc(dev, num_fields * sizeof(*fields), __GFP_ZERO); if (!fields) return -ENOMEM; - dev->priv = fields; + dev_set_priv(dev, fields); mux_reg_masks = devm_kmalloc(dev, num_fields * 2 * sizeof(u32), __GFP_ZERO); diff --git a/drivers/mux/mux-uclass.c b/drivers/mux/mux-uclass.c index a35c3d9c94..6d28dbe4d1 100644 --- a/drivers/mux/mux-uclass.c +++ b/drivers/mux/mux-uclass.c @@ -331,5 +331,5 @@ UCLASS_DRIVER(mux) = { .id = UCLASS_MUX, .name = "mux", .post_probe = mux_uclass_post_probe, - .per_device_auto_alloc_size = sizeof(struct mux_chip), + .per_device_auto = sizeof(struct mux_chip), }; diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c index ccba3947ac..c16dff959b 100644 --- a/drivers/net/ag7xxx.c +++ b/drivers/net/ag7xxx.c @@ -588,7 +588,7 @@ static void ag7xxx_eth_stop(struct udevice *dev) */ static int ag7xxx_eth_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ar7xxx_eth_priv *priv = dev_get_priv(dev); unsigned char *mac = pdata->enetaddr; u32 macid_lo, macid_hi; @@ -1197,7 +1197,7 @@ static int ag7xxx_get_phy_iface_offset(struct udevice *dev) static int ag7xxx_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ar7xxx_eth_priv *priv = dev_get_priv(dev); void __iomem *iobase, *phyiobase; int ret, phyreg; @@ -1250,9 +1250,9 @@ static const struct eth_ops ag7xxx_eth_ops = { .write_hwaddr = ag7xxx_eth_write_hwaddr, }; -static int ag7xxx_eth_ofdata_to_platdata(struct udevice *dev) +static int ag7xxx_eth_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const char *phy_mode; int ret; @@ -1287,11 +1287,11 @@ U_BOOT_DRIVER(eth_ag7xxx) = { .name = "eth_ag7xxx", .id = UCLASS_ETH, .of_match = ag7xxx_eth_ids, - .ofdata_to_platdata = ag7xxx_eth_ofdata_to_platdata, + .of_to_plat = ag7xxx_eth_of_to_plat, .probe = ag7xxx_eth_probe, .remove = ag7xxx_eth_remove, .ops = &ag7xxx_eth_ops, - .priv_auto_alloc_size = sizeof(struct ar7xxx_eth_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ar7xxx_eth_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index 93b26da392..456b7b98e9 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -453,7 +453,7 @@ static int altera_tse_write_hwaddr(struct udevice *dev) { struct altera_tse_priv *priv = dev_get_priv(dev); struct alt_tse_mac *mac_dev = priv->mac_dev; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); u8 *hwaddr = pdata->enetaddr; u32 mac_lo, mac_hi; @@ -575,7 +575,7 @@ static const struct tse_ops tse_msgdma_ops = { static int altera_tse_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct altera_tse_priv *priv = dev_get_priv(dev); void *blob = (void *)gd->fdt_blob; int node = dev_of_offset(dev); @@ -672,9 +672,9 @@ static int altera_tse_probe(struct udevice *dev) return ret; } -static int altera_tse_ofdata_to_platdata(struct udevice *dev) +static int altera_tse_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const char *phy_mode; pdata->phy_interface = -1; @@ -710,8 +710,8 @@ U_BOOT_DRIVER(altera_tse) = { .id = UCLASS_ETH, .of_match = altera_tse_ids, .ops = &altera_tse_ops, - .ofdata_to_platdata = altera_tse_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct eth_pdata), - .priv_auto_alloc_size = sizeof(struct altera_tse_priv), + .of_to_plat = altera_tse_of_to_plat, + .plat_auto = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct altera_tse_priv), .probe = altera_tse_probe, }; diff --git a/drivers/net/bcm6348-eth.c b/drivers/net/bcm6348-eth.c index 9ddc0f938f..aad7b61213 100644 --- a/drivers/net/bcm6348-eth.c +++ b/drivers/net/bcm6348-eth.c @@ -264,7 +264,7 @@ static void bcm6348_eth_stop(struct udevice *dev) static int bcm6348_eth_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct bcm6348_eth_priv *priv = dev_get_priv(dev); bool running = false; @@ -380,7 +380,7 @@ static int bcm6348_mdio_init(const char *name, void __iomem *base) static int bcm6348_phy_init(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct bcm6348_eth_priv *priv = dev_get_priv(dev); struct mii_dev *bus; @@ -412,7 +412,7 @@ static int bcm6348_phy_init(struct udevice *dev) static int bcm6348_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct bcm6348_eth_priv *priv = dev_get_priv(dev); struct ofnode_phandle_args phy; const char *phy_mode; @@ -533,7 +533,7 @@ U_BOOT_DRIVER(bcm6348_eth) = { .id = UCLASS_ETH, .of_match = bcm6348_eth_ids, .ops = &bcm6348_eth_ops, - .platdata_auto_alloc_size = sizeof(struct eth_pdata), - .priv_auto_alloc_size = sizeof(struct bcm6348_eth_priv), + .plat_auto = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct bcm6348_eth_priv), .probe = bcm6348_eth_probe, }; diff --git a/drivers/net/bcm6368-eth.c b/drivers/net/bcm6368-eth.c index 38a2a30fe6..29abe7fc96 100644 --- a/drivers/net/bcm6368-eth.c +++ b/drivers/net/bcm6368-eth.c @@ -506,7 +506,7 @@ static int bcm6368_mdio_init(const char *name, struct bcm6368_eth_priv *priv) static int bcm6368_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct bcm6368_eth_priv *priv = dev_get_priv(dev); int num_ports, ret, i; ofnode node; @@ -637,7 +637,7 @@ U_BOOT_DRIVER(bcm6368_eth) = { .id = UCLASS_ETH, .of_match = bcm6368_eth_ids, .ops = &bcm6368_eth_ops, - .platdata_auto_alloc_size = sizeof(struct eth_pdata), - .priv_auto_alloc_size = sizeof(struct bcm6368_eth_priv), + .plat_auto = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct bcm6368_eth_priv), .probe = bcm6368_eth_probe, }; diff --git a/drivers/net/bcmgenet.c b/drivers/net/bcmgenet.c index ace1331362..67839563db 100644 --- a/drivers/net/bcmgenet.c +++ b/drivers/net/bcmgenet.c @@ -236,7 +236,7 @@ static void bcmgenet_umac_reset(struct bcmgenet_eth_priv *priv) static int bcmgenet_gmac_write_hwaddr(struct udevice *dev) { struct bcmgenet_eth_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); uchar *addr = pdata->enetaddr; u32 reg; @@ -619,7 +619,7 @@ static int bcmgenet_interface_set(struct bcmgenet_eth_priv *priv) static int bcmgenet_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct bcmgenet_eth_priv *priv = dev_get_priv(dev); ofnode mdio_node; const char *name; @@ -685,9 +685,9 @@ static const struct eth_ops bcmgenet_gmac_eth_ops = { .stop = bcmgenet_gmac_eth_stop, }; -static int bcmgenet_eth_ofdata_to_platdata(struct udevice *dev) +static int bcmgenet_eth_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct bcmgenet_eth_priv *priv = dev_get_priv(dev); struct ofnode_phandle_args phy_node; const char *phy_mode; @@ -729,10 +729,10 @@ U_BOOT_DRIVER(eth_bcmgenet) = { .name = "eth_bcmgenet", .id = UCLASS_ETH, .of_match = bcmgenet_eth_ids, - .ofdata_to_platdata = bcmgenet_eth_ofdata_to_platdata, + .of_to_plat = bcmgenet_eth_of_to_plat, .probe = bcmgenet_eth_probe, .ops = &bcmgenet_gmac_eth_ops, - .priv_auto_alloc_size = sizeof(struct bcmgenet_eth_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct bcmgenet_eth_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/dc2114x.c b/drivers/net/dc2114x.c index 9f8c6c58d9..deedfe76e4 100644 --- a/drivers/net/dc2114x.c +++ b/drivers/net/dc2114x.c @@ -625,7 +625,7 @@ int dc21x4x_initialize(struct bd_info *bis) #else /* DM_ETH */ static int dc2114x_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct dc2114x_priv *priv = dev_get_priv(dev); memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); @@ -709,7 +709,7 @@ static int dc2114x_bind(struct udevice *dev) static int dc2114x_probe(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct dc2114x_priv *priv = dev_get_priv(dev); u16 command, status; u32 iobase; @@ -751,8 +751,8 @@ U_BOOT_DRIVER(eth_dc2114x) = { .bind = dc2114x_bind, .probe = dc2114x_probe, .ops = &dc2114x_ops, - .priv_auto_alloc_size = sizeof(struct dc2114x_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct dc2114x_priv), + .plat_auto = sizeof(struct eth_pdata), }; U_BOOT_PCI_DEVICE(eth_dc2114x, supported); diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 4c19abbaf0..9dba55adaa 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -93,7 +93,7 @@ static int dw_mdio_reset(struct mii_dev *bus) { struct udevice *dev = bus->priv; struct dw_eth_dev *priv = dev_get_priv(dev); - struct dw_eth_pdata *pdata = dev_get_platdata(dev); + struct dw_eth_pdata *pdata = dev_get_plat(dev); int ret; if (!dm_gpio_is_valid(&priv->reset_gpio)) @@ -610,7 +610,7 @@ int designware_initialize(ulong base_addr, u32 interface) #ifdef CONFIG_DM_ETH static int designware_eth_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct dw_eth_dev *priv = dev_get_priv(dev); int ret; @@ -654,7 +654,7 @@ void designware_eth_stop(struct udevice *dev) int designware_eth_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct dw_eth_dev *priv = dev_get_priv(dev); return _dw_write_hwaddr(priv, pdata->enetaddr); @@ -678,7 +678,7 @@ static int designware_eth_bind(struct udevice *dev) int designware_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct dw_eth_dev *priv = dev_get_priv(dev); u32 iobase = pdata->iobase; ulong ioaddr; @@ -740,7 +740,7 @@ int designware_eth_probe(struct udevice *dev) #ifdef CONFIG_DM_PCI /* * If we are on PCI bus, either directly attached to a PCI root port, - * or via a PCI bridge, fill in platdata before we probe the hardware. + * or via a PCI bridge, fill in plat before we probe the hardware. */ if (device_is_on_pci_bus(dev)) { dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase); @@ -811,9 +811,9 @@ const struct eth_ops designware_eth_ops = { .write_hwaddr = designware_eth_write_hwaddr, }; -int designware_eth_ofdata_to_platdata(struct udevice *dev) +int designware_eth_of_to_plat(struct udevice *dev) { - struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev); + struct dw_eth_pdata *dw_pdata = dev_get_plat(dev); #if CONFIG_IS_ENABLED(DM_GPIO) struct dw_eth_dev *priv = dev_get_priv(dev); #endif @@ -868,13 +868,13 @@ U_BOOT_DRIVER(eth_designware) = { .name = "eth_designware", .id = UCLASS_ETH, .of_match = designware_eth_ids, - .ofdata_to_platdata = designware_eth_ofdata_to_platdata, + .of_to_plat = designware_eth_of_to_plat, .bind = designware_eth_bind, .probe = designware_eth_probe, .remove = designware_eth_remove, .ops = &designware_eth_ops, - .priv_auto_alloc_size = sizeof(struct dw_eth_dev), - .platdata_auto_alloc_size = sizeof(struct dw_eth_pdata), + .priv_auto = sizeof(struct dw_eth_dev), + .plat_auto = sizeof(struct dw_eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/designware.h b/drivers/net/designware.h index ffaf5a14d0..a82afb99ca 100644 --- a/drivers/net/designware.h +++ b/drivers/net/designware.h @@ -251,7 +251,7 @@ struct dw_eth_dev { }; #ifdef CONFIG_DM_ETH -int designware_eth_ofdata_to_platdata(struct udevice *dev); +int designware_eth_of_to_plat(struct udevice *dev); int designware_eth_probe(struct udevice *dev); extern const struct eth_ops designware_eth_ops; diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index db1102562f..45a1648ad5 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1108,7 +1108,7 @@ static int eqos_adjust_link(struct udevice *dev) static int eqos_write_hwaddr(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct eqos_priv *eqos = dev_get_priv(dev); uint32_t val; @@ -1152,10 +1152,10 @@ static int eqos_write_hwaddr(struct udevice *dev) static int eqos_read_rom_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); #ifdef CONFIG_ARCH_IMX8M - imx_get_mac_from_fuse(dev->req_seq, pdata->enetaddr); + imx_get_mac_from_fuse(dev_seq(dev), pdata->enetaddr); #endif return !is_valid_ethaddr(pdata->enetaddr); } @@ -2193,6 +2193,6 @@ U_BOOT_DRIVER(eth_eqos) = { .probe = eqos_probe, .remove = eqos_remove, .ops = &eqos_ops, - .priv_auto_alloc_size = sizeof(struct eqos_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct eqos_priv), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/dwmac_s700.c b/drivers/net/dwmac_s700.c index 9d3f3ac5d9..efe3d1dade 100644 --- a/drivers/net/dwmac_s700.c +++ b/drivers/net/dwmac_s700.c @@ -44,9 +44,9 @@ static int dwmac_s700_probe(struct udevice *dev) return designware_eth_probe(dev); } -static int dwmac_s700_ofdata_to_platdata(struct udevice *dev) +static int dwmac_s700_of_to_plat(struct udevice *dev) { - return designware_eth_ofdata_to_platdata(dev); + return designware_eth_of_to_plat(dev); } static const struct udevice_id dwmac_s700_ids[] = { @@ -58,10 +58,10 @@ U_BOOT_DRIVER(dwmac_s700) = { .name = "dwmac_s700", .id = UCLASS_ETH, .of_match = dwmac_s700_ids, - .ofdata_to_platdata = dwmac_s700_ofdata_to_platdata, + .of_to_plat = dwmac_s700_of_to_plat, .probe = dwmac_s700_probe, .ops = &designware_eth_ops, - .priv_auto_alloc_size = sizeof(struct dw_eth_dev), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct dw_eth_dev), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/dwmac_socfpga.c b/drivers/net/dwmac_socfpga.c index e93561dffa..939f199b1f 100644 --- a/drivers/net/dwmac_socfpga.c +++ b/drivers/net/dwmac_socfpga.c @@ -19,15 +19,15 @@ #include <asm/arch/system_manager.h> -struct dwmac_socfpga_platdata { +struct dwmac_socfpga_plat { struct dw_eth_pdata dw_eth_pdata; void *phy_intf; u32 reg_shift; }; -static int dwmac_socfpga_ofdata_to_platdata(struct udevice *dev) +static int dwmac_socfpga_of_to_plat(struct udevice *dev) { - struct dwmac_socfpga_platdata *pdata = dev_get_platdata(dev); + struct dwmac_socfpga_plat *pdata = dev_get_plat(dev); struct regmap *regmap; struct ofnode_phandle_args args; void *range; @@ -61,12 +61,12 @@ static int dwmac_socfpga_ofdata_to_platdata(struct udevice *dev) pdata->phy_intf = range + args.args[0]; pdata->reg_shift = args.args[1]; - return designware_eth_ofdata_to_platdata(dev); + return designware_eth_of_to_plat(dev); } static int dwmac_socfpga_probe(struct udevice *dev) { - struct dwmac_socfpga_platdata *pdata = dev_get_platdata(dev); + struct dwmac_socfpga_plat *pdata = dev_get_plat(dev); struct eth_pdata *edata = &pdata->dw_eth_pdata.eth_pdata; struct reset_ctl_bulk reset_bulk; int ret; @@ -115,10 +115,10 @@ U_BOOT_DRIVER(dwmac_socfpga) = { .name = "dwmac_socfpga", .id = UCLASS_ETH, .of_match = dwmac_socfpga_ids, - .ofdata_to_platdata = dwmac_socfpga_ofdata_to_platdata, + .of_to_plat = dwmac_socfpga_of_to_plat, .probe = dwmac_socfpga_probe, .ops = &designware_eth_ops, - .priv_auto_alloc_size = sizeof(struct dw_eth_dev), - .platdata_auto_alloc_size = sizeof(struct dwmac_socfpga_platdata), + .priv_auto = sizeof(struct dw_eth_dev), + .plat_auto = sizeof(struct dwmac_socfpga_plat), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 8e6c755f64..3b3dd104cd 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -5795,7 +5795,7 @@ static int do_e1000(struct cmd_tbl *cmdtp, int flag, int argc, e1000_name(name, cardnum); ret = uclass_get_device_by_name(UCLASS_ETH, name, &dev); if (!ret) { - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); mac = plat->enetaddr; } #else @@ -5844,7 +5844,7 @@ U_BOOT_CMD( #ifdef CONFIG_DM_ETH static int e1000_eth_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct e1000_hw *hw = dev_get_priv(dev); return _e1000_init(hw, plat->enetaddr); @@ -5890,7 +5890,7 @@ static int e1000_free_pkt(struct udevice *dev, uchar *packet, int length) static int e1000_eth_probe(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct e1000_hw *hw = dev_get_priv(dev); int ret; @@ -5940,8 +5940,8 @@ U_BOOT_DRIVER(eth_e1000) = { .bind = e1000_eth_bind, .probe = e1000_eth_probe, .ops = &e1000_eth_ops, - .priv_auto_alloc_size = sizeof(struct e1000_hw), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct e1000_hw), + .plat_auto = sizeof(struct eth_pdata), }; U_BOOT_PCI_DEVICE(eth_e1000, e1000_supported); diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index feba5327da..934b881219 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -900,7 +900,7 @@ int eepro100_initialize(struct bd_info *bis) #else /* DM_ETH */ static int eepro100_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct eepro100_priv *priv = dev_get_priv(dev); memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); @@ -962,7 +962,7 @@ static int eepro100_bind(struct udevice *dev) static int eepro100_probe(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct eepro100_priv *priv = dev_get_priv(dev); u16 command, status; u32 iobase; @@ -1009,8 +1009,8 @@ U_BOOT_DRIVER(eth_eepro100) = { .bind = eepro100_bind, .probe = eepro100_probe, .ops = &eepro100_ops, - .priv_auto_alloc_size = sizeof(struct eepro100_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct eepro100_priv), + .plat_auto = sizeof(struct eth_pdata), }; U_BOOT_PCI_DEVICE(eth_eepro100, supported); diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c index b383f45527..07aebd935e 100644 --- a/drivers/net/eth-phy-uclass.c +++ b/drivers/net/eth-phy-uclass.c @@ -54,7 +54,7 @@ int eth_phy_set_mdio_bus(struct udevice *eth_dev, struct mii_dev *mdio_bus) for (uclass_first_device(UCLASS_ETH_PHY, &dev); dev; uclass_next_device(&dev)) { if (dev->parent == eth_dev) { - uc_priv = (struct eth_phy_device_priv *)(dev->uclass_priv); + uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(dev)); if (!uc_priv->mdio_bus) uc_priv->mdio_bus = mdio_bus; @@ -79,7 +79,7 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev) * phy_dev is shared and controlled by * other eth controller */ - uc_priv = (struct eth_phy_device_priv *)(phy_dev->uclass_priv); + uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(phy_dev)); if (uc_priv->mdio_bus) printf("Get shared mii bus on %s\n", eth_dev->name); else @@ -113,7 +113,7 @@ int eth_phy_get_addr(struct udevice *dev) UCLASS_DRIVER(eth_phy_generic) = { .id = UCLASS_ETH_PHY, .name = "eth_phy_generic", - .per_device_auto_alloc_size = sizeof(struct eth_phy_device_priv), + .per_device_auto = sizeof(struct eth_phy_device_priv), }; U_BOOT_DRIVER(eth_phy_generic_drv) = { diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index b9d80a5b08..7f146d4c8b 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -647,7 +647,7 @@ static inline int ethoc_phy_init(struct ethoc *priv, void *dev) static int ethoc_write_hwaddr(struct udevice *dev) { - struct ethoc_eth_pdata *pdata = dev_get_platdata(dev); + struct ethoc_eth_pdata *pdata = dev_get_plat(dev); struct ethoc *priv = dev_get_priv(dev); u8 *mac = pdata->eth_pdata.enetaddr; @@ -685,9 +685,9 @@ static void ethoc_stop(struct udevice *dev) ethoc_stop_common(dev_get_priv(dev)); } -static int ethoc_ofdata_to_platdata(struct udevice *dev) +static int ethoc_of_to_plat(struct udevice *dev) { - struct ethoc_eth_pdata *pdata = dev_get_platdata(dev); + struct ethoc_eth_pdata *pdata = dev_get_plat(dev); fdt_addr_t addr; pdata->eth_pdata.iobase = dev_read_addr(dev); @@ -699,7 +699,7 @@ static int ethoc_ofdata_to_platdata(struct udevice *dev) static int ethoc_probe(struct udevice *dev) { - struct ethoc_eth_pdata *pdata = dev_get_platdata(dev); + struct ethoc_eth_pdata *pdata = dev_get_plat(dev); struct ethoc *priv = dev_get_priv(dev); priv->iobase = ioremap(pdata->eth_pdata.iobase, ETHOC_IOSIZE); @@ -746,12 +746,12 @@ U_BOOT_DRIVER(ethoc) = { .name = "ethoc", .id = UCLASS_ETH, .of_match = ethoc_ids, - .ofdata_to_platdata = ethoc_ofdata_to_platdata, + .of_to_plat = ethoc_of_to_plat, .probe = ethoc_probe, .remove = ethoc_remove, .ops = ðoc_ops, - .priv_auto_alloc_size = sizeof(struct ethoc), - .platdata_auto_alloc_size = sizeof(struct ethoc_eth_pdata), + .priv_auto = sizeof(struct ethoc), + .plat_auto = sizeof(struct ethoc_eth_pdata), }; #else diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index bb55be9a26..e3b29a9c3e 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -415,7 +415,7 @@ static int fec_set_hwaddr(struct eth_device *dev) { #ifdef CONFIG_DM_ETH struct fec_priv *fec = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); uchar *mac = pdata->enetaddr; #else uchar *mac = dev->enetaddr; @@ -1272,7 +1272,7 @@ int fecmxc_register_mii_postcall(struct eth_device *dev, int (*cb)(int)) static int fecmxc_read_rom_hwaddr(struct udevice *dev) { struct fec_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); return fec_get_hwaddr(priv->dev_id, pdata->enetaddr); } @@ -1351,7 +1351,7 @@ static void fec_gpio_reset(struct fec_priv *priv) static int fecmxc_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct fec_priv *priv = dev_get_priv(dev); struct mii_dev *bus = NULL; uint32_t start; @@ -1451,7 +1451,7 @@ static int fecmxc_probe(struct udevice *dev) fec_reg_setup(priv); - priv->dev_id = dev->seq; + priv->dev_id = dev_seq(dev); #ifdef CONFIG_DM_ETH_PHY bus = eth_phy_get_mdio_bus(dev); @@ -1459,9 +1459,10 @@ static int fecmxc_probe(struct udevice *dev) if (!bus) { #ifdef CONFIG_FEC_MXC_MDIO_BASE - bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq); + bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, + dev_seq(dev)); #else - bus = fec_get_miibus((ulong)priv->eth, dev->seq); + bus = fec_get_miibus((ulong)priv->eth, dev_seq(dev)); #endif } if (!bus) { @@ -1527,10 +1528,10 @@ static int fecmxc_remove(struct udevice *dev) return 0; } -static int fecmxc_ofdata_to_platdata(struct udevice *dev) +static int fecmxc_of_to_plat(struct udevice *dev) { int ret = 0; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct fec_priv *priv = dev_get_priv(dev); const char *phy_mode; @@ -1593,11 +1594,11 @@ U_BOOT_DRIVER(fecmxc_gem) = { .name = "fecmxc", .id = UCLASS_ETH, .of_match = fecmxc_ids, - .ofdata_to_platdata = fecmxc_ofdata_to_platdata, + .of_to_plat = fecmxc_of_to_plat, .probe = fecmxc_probe, .remove = fecmxc_remove, .ops = &fecmxc_ops, - .priv_auto_alloc_size = sizeof(struct fec_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct fec_priv), + .plat_auto = sizeof(struct eth_pdata), }; #endif diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index 2f433cedd0..0e89e663f7 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -472,7 +472,7 @@ static int fm_eth_open(struct udevice *dev) #ifndef CONFIG_DM_ETH struct fm_eth *fm_eth = dev->priv; #else - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct fm_eth *fm_eth = dev_get_priv(dev); #endif unsigned char *enetaddr; @@ -547,7 +547,11 @@ static void fm_eth_halt(struct udevice *dev) struct fm_eth *fm_eth; struct fsl_enet_mac *mac; +#ifndef CONFIG_DM_ETH fm_eth = (struct fm_eth *)dev->priv; +#else + fm_eth = dev_get_priv(dev); +#endif mac = fm_eth->mac; /* graceful stop the transmission of frames */ @@ -577,7 +581,11 @@ static int fm_eth_send(struct udevice *dev, void *buf, int len) u16 offset_in; int i; +#ifndef CONFIG_DM_ETH fm_eth = (struct fm_eth *)dev->priv; +#else + fm_eth = dev_get_priv(dev); +#endif pram = fm_eth->tx_pram; txbd = fm_eth->cur_txbd; @@ -664,13 +672,19 @@ static int fm_eth_recv(struct eth_device *dev) static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) #endif { - struct fm_eth *fm_eth = (struct fm_eth *)dev->priv; - struct fm_port_bd *rxbd = fm_eth->cur_rxbd; + struct fm_eth *fm_eth; + struct fm_port_bd *rxbd; u32 buf_lo, buf_hi; u16 status, len; int ret = -1; u8 *data; +#ifndef CONFIG_DM_ETH + fm_eth = (struct fm_eth *)dev->priv; +#else + fm_eth = dev_get_priv(dev); +#endif + rxbd = fm_eth->cur_rxbd; status = muram_readw(&rxbd->status); while (!(status & RxBD_EMPTY)) { @@ -704,7 +718,7 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) #ifdef CONFIG_DM_ETH static int fm_eth_free_pkt(struct udevice *dev, uchar *packet, int length) { - struct fm_eth *fm_eth = (struct fm_eth *)dev->priv; + struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev); fm_eth->cur_rxbd = fm_eth_free_one(fm_eth, fm_eth->cur_rxbd); @@ -943,7 +957,7 @@ phy_interface_t fman_read_sys_if(struct udevice *dev) { const char *if_str; - if_str = ofnode_read_string(dev->node, "phy-connection-type"); + if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type"); debug("MAC system interface mode %s\n", if_str); return phy_get_interface_by_name(if_str); @@ -955,7 +969,7 @@ static int fm_eth_bind(struct udevice *dev) char mac_name[11]; u32 fm, num; - if (ofnode_read_u32(ofnode_get_parent(dev->node), "cell-index", &fm)) { + if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", &fm)) { printf("FMan node property cell-index missing\n"); return -EINVAL; } @@ -1004,7 +1018,7 @@ static struct udevice *fm_get_internal_mdio(struct udevice *dev) static int fm_eth_probe(struct udevice *dev) { - struct fm_eth *fm_eth = (struct fm_eth *)dev->priv; + struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev); struct ofnode_phandle_args args; void *reg; int ret, index; @@ -1130,8 +1144,8 @@ U_BOOT_DRIVER(eth_fman) = { .probe = fm_eth_probe, .remove = fm_eth_remove, .ops = &fm_eth_ops, - .priv_auto_alloc_size = sizeof(struct fm_eth), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct fm_eth), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index bbb1738c4b..7d51be1f72 100644 --- a/drivers/net/fm/fm.c +++ b/drivers/net/fm/fm.c @@ -605,7 +605,7 @@ U_BOOT_DRIVER(fman) = { .of_match = fman_ids, .probe = fman_probe, .remove = fman_remove, - .priv_auto_alloc_size = sizeof(struct fman_priv), + .priv_auto = sizeof(struct fman_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/memac_phy.c b/drivers/net/fm/memac_phy.c index e15c28d500..8bd32b0ab7 100644 --- a/drivers/net/fm/memac_phy.c +++ b/drivers/net/fm/memac_phy.c @@ -297,8 +297,8 @@ U_BOOT_DRIVER(fman_mdio) = { .probe = fm_mdio_probe, .remove = fm_mdio_remove, .ops = &fm_mdio_ops, - .priv_auto_alloc_size = sizeof(struct fm_mdio_priv), - .platdata_auto_alloc_size = sizeof(struct mdio_perdev_priv), + .priv_auto = sizeof(struct fm_mdio_priv), + .plat_auto = sizeof(struct mdio_perdev_priv), }; #endif /* CONFIG_PHYLIB && CONFIG_DM_MDIO */ #endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 84db6be624..5bfe3781a1 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -185,9 +185,9 @@ static int mc_fixup_mac_addr(void *blob, int nodeoffset, enum mc_fixup_type type) { #ifdef CONFIG_DM_ETH - struct eth_pdata *plat = dev_get_platdata(eth_dev); + struct eth_pdata *plat = dev_get_plat(eth_dev); unsigned char *enetaddr = plat->enetaddr; - int eth_index = eth_dev->seq; + int eth_index = dev_seq(eth_dev); #else unsigned char *enetaddr = eth_dev->enetaddr; int eth_index = eth_dev->index; diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c index 2929ae7209..f6fc7801b9 100644 --- a/drivers/net/fsl_enetc.c +++ b/drivers/net/fsl_enetc.c @@ -54,7 +54,7 @@ static int ierb_fn_to_pf[] = {0, 1, 2, -1, -1, -1, 3}; /* sets up primary MAC addresses in DT/IERB */ void fdt_fixup_enetc_mac(void *blob) { - struct pci_child_platdata *ppdata; + struct pci_child_plat *ppdata; struct eth_pdata *pdata; struct udevice *dev; struct uclass *uc; @@ -68,8 +68,8 @@ void fdt_fixup_enetc_mac(void *blob) strcmp(dev->driver->name, ENETC_DRIVER_NAME)) continue; - pdata = dev_get_platdata(dev); - ppdata = dev_get_parent_platdata(dev); + pdata = dev_get_plat(dev); + ppdata = dev_get_parent_plat(dev); devfn = PCI_FUNC(ppdata->devfn); enetc_set_ierb_primary_mac(dev, devfn, pdata->enetaddr); @@ -99,7 +99,7 @@ static int enetc_bind(struct udevice *dev) * and some are not, use different naming scheme - enetc-N based on * PCI function # and enetc#N based on interface count */ - if (ofnode_valid(dev->node)) + if (ofnode_valid(dev_ofnode(dev))) sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev))); else sprintf(name, "enetc#%u", eth_num_devices++); @@ -253,12 +253,12 @@ static void enetc_start_pcs(struct udevice *dev) mdio_register(&priv->imdio); } - if (!ofnode_valid(dev->node)) { + if (!ofnode_valid(dev_ofnode(dev))) { enetc_dbg(dev, "no enetc ofnode found, skipping PCS set-up\n"); return; } - if_str = ofnode_read_string(dev->node, "phy-mode"); + if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode"); if (if_str) priv->if_type = phy_get_interface_by_name(if_str); else @@ -306,7 +306,7 @@ static int enetc_probe(struct udevice *dev) { struct enetc_priv *priv = dev_get_priv(dev); - if (ofnode_valid(dev->node) && !ofnode_is_available(dev->node)) { + if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) { enetc_dbg(dev, "interface disabled\n"); return -ENODEV; } @@ -365,9 +365,9 @@ static int enetc_remove(struct udevice *dev) static int enetc_ls1028a_write_hwaddr(struct udevice *dev) { - struct pci_child_platdata *ppdata = dev_get_parent_platdata(dev); + struct pci_child_plat *ppdata = dev_get_parent_plat(dev); const int devfn_to_pf[] = {0, 1, 2, -1, -1, -1, 3}; - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); int devfn = PCI_FUNC(ppdata->devfn); u8 *addr = plat->enetaddr; u32 lower, upper; @@ -391,7 +391,7 @@ static int enetc_ls1028a_write_hwaddr(struct udevice *dev) static int enetc_write_hwaddr(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct enetc_priv *priv = dev_get_priv(dev); u8 *addr = plat->enetaddr; @@ -677,8 +677,8 @@ U_BOOT_DRIVER(eth_enetc) = { .probe = enetc_probe, .remove = enetc_remove, .ops = &enetc_ops, - .priv_auto_alloc_size = sizeof(struct enetc_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct enetc_priv), + .plat_auto = sizeof(struct eth_pdata), }; static struct pci_device_id enetc_ids[] = { diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c index 47257a6cf6..3eb6ac9fc8 100644 --- a/drivers/net/fsl_enetc_mdio.c +++ b/drivers/net/fsl_enetc_mdio.c @@ -112,7 +112,7 @@ static int enetc_mdio_bind(struct udevice *dev) * and some are not, use different naming scheme - enetc-N based on * PCI function # and enetc#N based on interface count */ - if (ofnode_valid(dev->node)) + if (ofnode_valid(dev_ofnode(dev))) sprintf(name, "emdio-%u", PCI_FUNC(pci_get_devfn(dev))); else sprintf(name, "emdio#%u", eth_num_devices++); @@ -144,7 +144,7 @@ U_BOOT_DRIVER(enetc_mdio) = { .bind = enetc_mdio_bind, .probe = enetc_mdio_probe, .ops = &enetc_mdio_ops, - .priv_auto_alloc_size = sizeof(struct enetc_mdio_priv), + .priv_auto = sizeof(struct enetc_mdio_priv), }; static struct pci_device_id enetc_mdio_ids[] = { diff --git a/drivers/net/fsl_ls_mdio.c b/drivers/net/fsl_ls_mdio.c index 6d8332d19a..6d4e682fdf 100644 --- a/drivers/net/fsl_ls_mdio.c +++ b/drivers/net/fsl_ls_mdio.c @@ -142,5 +142,5 @@ U_BOOT_DRIVER(fsl_ls_mdio) = { .of_match = fsl_ls_mdio_of_ids, .probe = fsl_ls_mdio_probe, .ops = &fsl_ls_mdio_ops, - .priv_auto_alloc_size = sizeof(struct fsl_ls_mdio_priv), + .priv_auto = sizeof(struct fsl_ls_mdio_priv), }; diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c index e27f7e5321..c36d40c911 100644 --- a/drivers/net/fsl_mcdmafec.c +++ b/drivers/net/fsl_mcdmafec.c @@ -79,7 +79,7 @@ static void init_eth_info(struct fec_info_dma *info) static void fec_halt(struct udevice *dev) { - struct fec_info_dma *info = dev->priv; + struct fec_info_dma *info = dev_get_priv(dev); volatile fecdma_t *fecp = (fecdma_t *)info->iobase; int counter = 0xffff; @@ -230,7 +230,7 @@ static void fec_set_hwaddr(volatile fecdma_t *fecp, u8 *mac) static int fec_init(struct udevice *dev) { - struct fec_info_dma *info = dev->priv; + struct fec_info_dma *info = dev_get_priv(dev); volatile fecdma_t *fecp = (fecdma_t *)info->iobase; int rval, i; uchar enetaddr[6]; @@ -352,7 +352,7 @@ static int mcdmafec_init(struct udevice *dev) static int mcdmafec_send(struct udevice *dev, void *packet, int length) { - struct fec_info_dma *info = dev->priv; + struct fec_info_dma *info = dev_get_priv(dev); cbd_t *p_tbd, *p_used_tbd; u16 phy_status; @@ -412,7 +412,7 @@ static int mcdmafec_send(struct udevice *dev, void *packet, int length) static int mcdmafec_recv(struct udevice *dev, int flags, uchar **packetp) { - struct fec_info_dma *info = dev->priv; + struct fec_info_dma *info = dev_get_priv(dev); volatile fecdma_t *fecp = (fecdma_t *)info->iobase; cbd_t *prbd = &info->rxbd[info->rx_idx]; @@ -491,18 +491,18 @@ static const struct eth_ops mcdmafec_ops = { }; /* - * Boot sequence, called just after mcffec_ofdata_to_platdata, + * Boot sequence, called just after mcffec_of_to_plat, * as DM way, it replaces old mcffec_initialize. */ static int mcdmafec_probe(struct udevice *dev) { - struct fec_info_dma *info = dev->priv; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct fec_info_dma *info = dev_get_priv(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int node = dev_of_offset(dev); int retval; const u32 *val; - info->index = dev->seq; + info->index = dev_seq(dev); info->iobase = pdata->iobase; info->miibase = pdata->iobase; info->phy_addr = -1; @@ -565,9 +565,9 @@ static int mcdmafec_remove(struct udevice *dev) /* * Boot sequence, called 1st */ -static int mcdmafec_ofdata_to_platdata(struct udevice *dev) +static int mcdmafec_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const u32 *val; pdata->iobase = dev_read_addr(dev); @@ -590,10 +590,10 @@ U_BOOT_DRIVER(mcffec) = { .name = "mcdmafec", .id = UCLASS_ETH, .of_match = mcdmafec_ids, - .ofdata_to_platdata = mcdmafec_ofdata_to_platdata, + .of_to_plat = mcdmafec_of_to_plat, .probe = mcdmafec_probe, .remove = mcdmafec_remove, .ops = &mcdmafec_ops, - .priv_auto_alloc_size = sizeof(struct fec_info_dma), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct fec_info_dma), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/fsl_mdio.c b/drivers/net/fsl_mdio.c index 77f1a96a2e..5fd11db05f 100644 --- a/drivers/net/fsl_mdio.c +++ b/drivers/net/fsl_mdio.c @@ -248,8 +248,8 @@ U_BOOT_DRIVER(tsec_mdio) = { .probe = tsec_mdio_probe, .remove = tsec_mdio_remove, .ops = &tsec_mdio_ops, - .priv_auto_alloc_size = sizeof(struct tsec_mdio_priv), - .platdata_auto_alloc_size = sizeof(struct mdio_perdev_priv), + .priv_auto = sizeof(struct tsec_mdio_priv), + .plat_auto = sizeof(struct mdio_perdev_priv), }; #endif /* CONFIG_PHYLIB */ #endif /* CONFIG_DM_MDIO */ diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index 00bda24f1f..69e299d6a3 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -171,7 +171,7 @@ static int ftgmac100_mdio_init(struct udevice *dev) bus->write = ftgmac100_mdio_write; bus->priv = priv; - ret = mdio_register_seq(bus, dev->seq); + ret = mdio_register_seq(bus, dev_seq(dev)); if (ret) { free(bus); return ret; @@ -287,7 +287,7 @@ static void ftgmac100_stop(struct udevice *dev) static int ftgmac100_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct ftgmac100_data *priv = dev_get_priv(dev); struct ftgmac100 *ftgmac100 = priv->iobase; struct phy_device *phydev = priv->phydev; @@ -505,15 +505,15 @@ static int ftgmac100_send(struct udevice *dev, void *packet, int length) static int ftgmac100_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ftgmac100_data *priv = dev_get_priv(dev); return ftgmac100_set_mac(priv, pdata->enetaddr); } -static int ftgmac100_ofdata_to_platdata(struct udevice *dev) +static int ftgmac100_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ftgmac100_data *priv = dev_get_priv(dev); const char *phy_mode; @@ -542,7 +542,7 @@ static int ftgmac100_ofdata_to_platdata(struct udevice *dev) static int ftgmac100_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ftgmac100_data *priv = dev_get_priv(dev); int ret; @@ -609,11 +609,11 @@ U_BOOT_DRIVER(ftgmac100) = { .name = "ftgmac100", .id = UCLASS_ETH, .of_match = ftgmac100_ids, - .ofdata_to_platdata = ftgmac100_ofdata_to_platdata, + .of_to_plat = ftgmac100_of_to_plat, .probe = ftgmac100_probe, .remove = ftgmac100_remove, .ops = &ftgmac100_ops, - .priv_auto_alloc_size = sizeof(struct ftgmac100_data), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ftgmac100_data), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 292690de96..0d672374fd 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -318,7 +318,7 @@ out: #ifdef CONFIG_DM_ETH static int ftmac100_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct ftmac100_data *priv = dev_get_priv(dev); return _ftmac100_init(priv, plat->enetaddr); @@ -360,7 +360,7 @@ static int ftmac100_free_pkt(struct udevice *dev, uchar *packet, int length) int ftmac100_read_rom_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); eth_env_get_enetaddr("ethaddr", pdata->enetaddr); return 0; } @@ -393,10 +393,10 @@ static const char *dtbmacaddr(u32 ifno) return NULL; } -static int ftmac100_ofdata_to_platdata(struct udevice *dev) +static int ftmac100_of_to_plat(struct udevice *dev) { struct ftmac100_data *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const char *mac; pdata->iobase = dev_read_addr(dev); priv->iobase = pdata->iobase; @@ -437,11 +437,11 @@ U_BOOT_DRIVER(ftmac100) = { .id = UCLASS_ETH, .of_match = ftmac100_ids, .bind = ftmac100_bind, - .ofdata_to_platdata = ftmac100_ofdata_to_platdata, + .of_to_plat = ftmac100_of_to_plat, .probe = ftmac100_probe, .ops = &ftmac100_ops, - .priv_auto_alloc_size = sizeof(struct ftmac100_data), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ftmac100_data), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c index 8d95ee15ff..a50a5b3f33 100644 --- a/drivers/net/gmac_rockchip.c +++ b/drivers/net/gmac_rockchip.c @@ -39,7 +39,7 @@ DECLARE_GLOBAL_DATA_PTR; * * dw_eth_pdata: Required platform data for designware driver (must be first) */ -struct gmac_rockchip_platdata { +struct gmac_rockchip_plat { struct dw_eth_pdata dw_eth_pdata; bool clock_input; int tx_delay; @@ -48,14 +48,14 @@ struct gmac_rockchip_platdata { struct rk_gmac_ops { int (*fix_mac_speed)(struct dw_eth_dev *priv); - void (*set_to_rmii)(struct gmac_rockchip_platdata *pdata); - void (*set_to_rgmii)(struct gmac_rockchip_platdata *pdata); + void (*set_to_rmii)(struct gmac_rockchip_plat *pdata); + void (*set_to_rgmii)(struct gmac_rockchip_plat *pdata); }; -static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) +static int gmac_rockchip_of_to_plat(struct udevice *dev) { - struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev); + struct gmac_rockchip_plat *pdata = dev_get_plat(dev); const char *string; string = dev_read_string(dev, "clock_in_out"); @@ -74,7 +74,7 @@ static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) if (pdata->rx_delay == -ENOENT) pdata->rx_delay = dev_read_u32_default(dev, "rx-delay", 0x10); - return designware_eth_ofdata_to_platdata(dev); + return designware_eth_of_to_plat(dev); } static int px30_gmac_fix_mac_speed(struct dw_eth_dev *priv) @@ -344,7 +344,7 @@ static int rv1108_set_rmii_speed(struct dw_eth_dev *priv) return 0; } -static void px30_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata) +static void px30_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata) { struct px30_grf *grf; enum { @@ -360,7 +360,7 @@ static void px30_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata) PX30_GMAC_PHY_INTF_SEL_RMII); } -static void rk3228_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) +static void rk3228_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata) { struct rk322x_grf *grf; enum { @@ -403,7 +403,7 @@ static void rk3228_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) pdata->tx_delay << RK3228_CLK_TX_DL_CFG_GMAC_SHIFT); } -static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) +static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata) { struct rk3288_grf *grf; @@ -422,7 +422,7 @@ static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) pdata->tx_delay << RK3288_CLK_TX_DL_CFG_GMAC_SHIFT); } -static void rk3308_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata) +static void rk3308_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata) { struct rk3308_grf *grf; enum { @@ -438,7 +438,7 @@ static void rk3308_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata) RK3308_GMAC_PHY_INTF_SEL_RMII); } -static void rk3328_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) +static void rk3328_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata) { struct rk3328_grf_regs *grf; enum { @@ -481,7 +481,7 @@ static void rk3328_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) pdata->tx_delay << RK3328_CLK_TX_DL_CFG_GMAC_SHIFT); } -static void rk3368_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) +static void rk3368_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata) { struct rk3368_grf *grf; enum { @@ -518,7 +518,7 @@ static void rk3368_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) pdata->tx_delay << RK3368_CLK_TX_DL_CFG_GMAC_SHIFT); } -static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) +static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata) { struct rk3399_grf_regs *grf; @@ -538,7 +538,7 @@ static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata) pdata->tx_delay << RK3399_CLK_TX_DL_CFG_GMAC_SHIFT); } -static void rv1108_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata) +static void rv1108_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata) { struct rv1108_grf *grf; @@ -555,10 +555,10 @@ static void rv1108_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata) static int gmac_rockchip_probe(struct udevice *dev) { - struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev); + struct gmac_rockchip_plat *pdata = dev_get_plat(dev); struct rk_gmac_ops *ops = (struct rk_gmac_ops *)dev_get_driver_data(dev); - struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev); + struct dw_eth_pdata *dw_pdata = dev_get_plat(dev); struct eth_pdata *eth_pdata = &dw_pdata->eth_pdata; struct clk clk; ulong rate; @@ -664,7 +664,7 @@ static int gmac_rockchip_probe(struct udevice *dev) static int gmac_rockchip_eth_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct dw_eth_dev *priv = dev_get_priv(dev); struct rk_gmac_ops *ops = (struct rk_gmac_ops *)dev_get_driver_data(dev); @@ -756,10 +756,10 @@ U_BOOT_DRIVER(eth_gmac_rockchip) = { .name = "gmac_rockchip", .id = UCLASS_ETH, .of_match = rockchip_gmac_ids, - .ofdata_to_platdata = gmac_rockchip_ofdata_to_platdata, + .of_to_plat = gmac_rockchip_of_to_plat, .probe = gmac_rockchip_probe, .ops = &gmac_rockchip_eth_ops, - .priv_auto_alloc_size = sizeof(struct dw_eth_dev), - .platdata_auto_alloc_size = sizeof(struct gmac_rockchip_platdata), + .priv_auto = sizeof(struct dw_eth_dev), + .plat_auto = sizeof(struct gmac_rockchip_plat), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/higmacv300.c b/drivers/net/higmacv300.c index 2aae7f4863..aa79d6eda8 100644 --- a/drivers/net/higmacv300.c +++ b/drivers/net/higmacv300.c @@ -128,7 +128,7 @@ struct higmac_priv { static int higmac_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct higmac_priv *priv = dev_get_priv(dev); unsigned char *mac = pdata->enetaddr; u32 val; @@ -528,7 +528,7 @@ static int higmac_probe(struct udevice *dev) bus->priv = priv; priv->bus = bus; - ret = mdio_register_seq(bus, dev->seq); + ret = mdio_register_seq(bus, dev_seq(dev)); if (ret) return ret; @@ -558,7 +558,7 @@ static int higmac_remove(struct udevice *dev) return 0; } -static int higmac_ofdata_to_platdata(struct udevice *dev) +static int higmac_of_to_plat(struct udevice *dev) { struct higmac_priv *priv = dev_get_priv(dev); int phyintf = PHY_INTERFACE_MODE_NONE; @@ -594,10 +594,10 @@ U_BOOT_DRIVER(eth_higmac) = { .name = "eth_higmac", .id = UCLASS_ETH, .of_match = higmac_ids, - .ofdata_to_platdata = higmac_ofdata_to_platdata, + .of_to_plat = higmac_of_to_plat, .probe = higmac_probe, .remove = higmac_remove, .ops = &higmac_ops, - .priv_auto_alloc_size = sizeof(struct higmac_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct higmac_priv), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c index 58e065cdcc..91c2d10ffc 100644 --- a/drivers/net/ks8851_mll.c +++ b/drivers/net/ks8851_mll.c @@ -615,7 +615,7 @@ static int ks8851_recv(struct udevice *dev, int flags, uchar **packetp) static int ks8851_write_hwaddr(struct udevice *dev) { struct ks_net *ks = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); ks8851_mll_write_hwaddr_common(ks, pdata->enetaddr); @@ -625,7 +625,7 @@ static int ks8851_write_hwaddr(struct udevice *dev) static int ks8851_read_rom_hwaddr(struct udevice *dev) { struct ks_net *ks = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); u16 addrl, addrm, addrh; /* No EEPROM means no valid MAC address. */ @@ -665,10 +665,10 @@ static int ks8851_probe(struct udevice *dev) return 0; } -static int ks8851_ofdata_to_platdata(struct udevice *dev) +static int ks8851_of_to_plat(struct udevice *dev) { struct ks_net *ks = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); pdata->iobase = dev_read_addr(dev); ks->iobase = pdata->iobase; @@ -695,11 +695,11 @@ U_BOOT_DRIVER(ks8851) = { .id = UCLASS_ETH, .of_match = ks8851_ids, .bind = ks8851_bind, - .ofdata_to_platdata = ks8851_ofdata_to_platdata, + .of_to_plat = ks8851_of_to_plat, .probe = ks8851_probe, .ops = &ks8851_ops, - .priv_auto_alloc_size = sizeof(struct ks_net), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ks_net), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index 42eaf49d71..ef013c9c97 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -511,7 +511,7 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, #ifdef CONFIG_DM_ETH static int ldpaa_eth_open(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct ldpaa_eth_priv *priv = dev_get_priv(dev); #else static int ldpaa_eth_open(struct eth_device *net_dev, struct bd_info *bd) @@ -1160,7 +1160,7 @@ static int ldpaa_eth_bind(struct udevice *dev) return 0; } -static int ldpaa_eth_ofdata_to_platdata(struct udevice *dev) +static int ldpaa_eth_of_to_plat(struct udevice *dev) { struct ldpaa_eth_priv *priv = dev_get_priv(dev); const char *phy_mode_str; @@ -1187,12 +1187,12 @@ U_BOOT_DRIVER(ldpaa_eth) = { .name = "ldpaa_eth", .id = UCLASS_ETH, .of_match = ldpaa_eth_of_ids, - .ofdata_to_platdata = ldpaa_eth_ofdata_to_platdata, + .of_to_plat = ldpaa_eth_of_to_plat, .bind = ldpaa_eth_bind, .probe = ldpaa_eth_probe, .ops = &ldpaa_eth_ops, - .priv_auto_alloc_size = sizeof(struct ldpaa_eth_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ldpaa_eth_priv), + .plat_auto = sizeof(struct eth_pdata), }; #else diff --git a/drivers/net/macb.c b/drivers/net/macb.c index b80a259ff7..e287c29e69 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -1169,7 +1169,7 @@ static void macb_stop(struct udevice *dev) static int macb_write_hwaddr(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct macb_device *macb = dev_get_priv(dev); return _macb_write_hwaddr(macb, plat->enetaddr); @@ -1222,7 +1222,7 @@ static const struct macb_config default_gem_config = { static int macb_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct macb_device *macb = dev_get_priv(dev); const char *phy_mode; int ret; @@ -1283,25 +1283,25 @@ static int macb_eth_remove(struct udevice *dev) } /** - * macb_late_eth_ofdata_to_platdata + * macb_late_eth_of_to_plat * @dev: udevice struct * Returns 0 when operation success and negative errno number * when operation failed. */ -int __weak macb_late_eth_ofdata_to_platdata(struct udevice *dev) +int __weak macb_late_eth_of_to_plat(struct udevice *dev) { return 0; } -static int macb_eth_ofdata_to_platdata(struct udevice *dev) +static int macb_eth_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); pdata->iobase = (phys_addr_t)dev_remap_addr(dev); if (!pdata->iobase) return -EINVAL; - return macb_late_eth_ofdata_to_platdata(dev); + return macb_late_eth_of_to_plat(dev); } static const struct macb_config sama5d4_config = { @@ -1331,12 +1331,12 @@ U_BOOT_DRIVER(eth_macb) = { .name = "eth_macb", .id = UCLASS_ETH, .of_match = macb_eth_ids, - .ofdata_to_platdata = macb_eth_ofdata_to_platdata, + .of_to_plat = macb_eth_of_to_plat, .probe = macb_eth_probe, .remove = macb_eth_remove, .ops = &macb_eth_ops, - .priv_auto_alloc_size = sizeof(struct macb_device), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct macb_device), + .plat_auto = sizeof(struct eth_pdata), }; #endif diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c index f94a2d8123..cb343b446f 100644 --- a/drivers/net/mcffec.c +++ b/drivers/net/mcffec.c @@ -125,7 +125,7 @@ static void set_fec_duplex_speed(volatile fec_t *fecp, int dup_spd) #ifdef ET_DEBUG static void dbg_fec_regs(struct udevice *dev) { - struct fec_info_s *info = dev->priv; + struct fec_info_s *info = dev_get_priv(dev); volatile fec_t *fecp = (fec_t *)(info->iobase); printf("=====\n"); @@ -275,7 +275,7 @@ static void dbg_fec_regs(struct udevice *dev) int mcffec_init(struct udevice *dev) { - struct fec_info_s *info = dev->priv; + struct fec_info_s *info = dev_get_priv(dev); volatile fec_t *fecp = (fec_t *) (info->iobase); int rval, i; uchar ea[6]; @@ -374,7 +374,7 @@ int mcffec_init(struct udevice *dev) static int mcffec_send(struct udevice *dev, void *packet, int length) { - struct fec_info_s *info = dev->priv; + struct fec_info_s *info = dev_get_priv(dev); volatile fec_t *fecp = (fec_t *)info->iobase; int j, rc; u16 phy_status; @@ -440,7 +440,7 @@ static int mcffec_send(struct udevice *dev, void *packet, int length) static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp) { - struct fec_info_s *info = dev->priv; + struct fec_info_s *info = dev_get_priv(dev); volatile fec_t *fecp = (fec_t *)info->iobase; int length = -1; @@ -492,7 +492,7 @@ static int mcffec_recv(struct udevice *dev, int flags, uchar **packetp) static void mcffec_halt(struct udevice *dev) { - struct fec_info_s *info = dev->priv; + struct fec_info_s *info = dev_get_priv(dev); fec_reset(info); fecpin_setclear(info, 0); @@ -513,18 +513,18 @@ static const struct eth_ops mcffec_ops = { }; /* - * Boot sequence, called just after mcffec_ofdata_to_platdata, + * Boot sequence, called just after mcffec_of_to_plat, * as DM way, it replaces old mcffec_initialize. */ static int mcffec_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); - struct fec_info_s *info = dev->priv; + struct eth_pdata *pdata = dev_get_plat(dev); + struct fec_info_s *info = dev_get_priv(dev); int node = dev_of_offset(dev); int retval, fec_idx; const u32 *val; - info->index = dev->seq; + info->index = dev_seq(dev); info->iobase = pdata->iobase; info->phy_addr = -1; @@ -584,9 +584,9 @@ static int mcffec_remove(struct udevice *dev) /* * Boot sequence, called 1st */ -static int mcffec_ofdata_to_platdata(struct udevice *dev) +static int mcffec_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const u32 *val; pdata->iobase = dev_read_addr(dev); @@ -610,10 +610,10 @@ U_BOOT_DRIVER(mcffec) = { .name = "mcffec", .id = UCLASS_ETH, .of_match = mcffec_ids, - .ofdata_to_platdata = mcffec_ofdata_to_platdata, + .of_to_plat = mcffec_of_to_plat, .probe = mcffec_probe, .remove = mcffec_remove, .ops = &mcffec_ops, - .priv_auto_alloc_size = sizeof(struct fec_info_s), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct fec_info_s), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c index 393605512d..ec81320a86 100644 --- a/drivers/net/mcfmii.c +++ b/drivers/net/mcfmii.c @@ -100,7 +100,11 @@ uint mii_send(uint mii_cmd) /* retrieve from register structure */ dev = eth_get_dev(); +#ifdef CONFIG_DM_ETH + info = dev_get_priv(dev); +#else info = dev->priv; +#endif ep = (FEC_T *) info->miibase; @@ -216,7 +220,11 @@ void __mii_init(void) /* retrieve from register structure */ dev = eth_get_dev(); +#ifdef CONFIG_DM_ETH + info = dev_get_priv(dev); +#else info = dev->priv; +#endif fecp = (FEC_T *) info->miibase; diff --git a/drivers/net/mdio-ipq4019.c b/drivers/net/mdio-ipq4019.c index bc68e1d506..50134b4d9b 100644 --- a/drivers/net/mdio-ipq4019.c +++ b/drivers/net/mdio-ipq4019.c @@ -107,8 +107,8 @@ static const struct mdio_ops ipq4019_mdio_ops = { static int ipq4019_mdio_bind(struct udevice *dev) { - if (ofnode_valid(dev->node)) - device_set_name(dev, ofnode_get_name(dev->node)); + if (ofnode_valid(dev_ofnode(dev))) + device_set_name(dev, ofnode_get_name(dev_ofnode(dev))); return 0; } @@ -142,5 +142,5 @@ U_BOOT_DRIVER(ipq4019_mdio) = { .bind = ipq4019_mdio_bind, .probe = ipq4019_mdio_probe, .ops = &ipq4019_mdio_ops, - .priv_auto_alloc_size = sizeof(struct ipq4019_mdio_priv), + .priv_auto = sizeof(struct ipq4019_mdio_priv), }; diff --git a/drivers/net/mdio_mux_i2creg.c b/drivers/net/mdio_mux_i2creg.c index cc02b5ffd4..3654230118 100644 --- a/drivers/net/mdio_mux_i2creg.c +++ b/drivers/net/mdio_mux_i2creg.c @@ -61,7 +61,7 @@ static int mdio_mux_i2creg_probe(struct udevice *dev) } /* parent should be an I2C chip, grandparent should be an I2C bus */ - chip_node = ofnode_get_parent(dev->node); + chip_node = ofnode_get_parent(dev_ofnode(dev)); bus_node = ofnode_get_parent(chip_node); err = uclass_get_device_by_ofnode(UCLASS_I2C, bus_node, &i2c_bus); @@ -105,5 +105,5 @@ U_BOOT_DRIVER(mdio_mux_i2creg) = { .of_match = mdio_mux_i2creg_ids, .probe = mdio_mux_i2creg_probe, .ops = &mdio_mux_i2creg_ops, - .priv_auto_alloc_size = sizeof(struct mdio_mux_i2creg_priv), + .priv_auto = sizeof(struct mdio_mux_i2creg_priv), }; diff --git a/drivers/net/mdio_mux_sandbox.c b/drivers/net/mdio_mux_sandbox.c index 3dba4d18a1..fff6ddb2f1 100644 --- a/drivers/net/mdio_mux_sandbox.c +++ b/drivers/net/mdio_mux_sandbox.c @@ -93,5 +93,5 @@ U_BOOT_DRIVER(mdio_mux_sandbox) = { .of_match = mdio_mux_sandbox_ids, .probe = mdio_mux_sandbox_probe, .ops = &mdio_mux_sandbox_ops, - .priv_auto_alloc_size = sizeof(struct mdio_mux_sandbox_priv), + .priv_auto = sizeof(struct mdio_mux_sandbox_priv), }; diff --git a/drivers/net/mdio_sandbox.c b/drivers/net/mdio_sandbox.c index b731f60a98..2b50ffc3ac 100644 --- a/drivers/net/mdio_sandbox.c +++ b/drivers/net/mdio_sandbox.c @@ -90,5 +90,5 @@ U_BOOT_DRIVER(mdio_sandbox) = { .of_match = mdio_sandbox_ids, .probe = mdio_sandbox_probe, .ops = &mdio_sandbox_ops, - .priv_auto_alloc_size = sizeof(struct mdio_sandbox_priv), + .priv_auto = sizeof(struct mdio_sandbox_priv), }; diff --git a/drivers/net/mscc_eswitch/jr2_switch.c b/drivers/net/mscc_eswitch/jr2_switch.c index 1c9a401de8..128d7f21ce 100644 --- a/drivers/net/mscc_eswitch/jr2_switch.c +++ b/drivers/net/mscc_eswitch/jr2_switch.c @@ -726,7 +726,7 @@ static int jr2_mac_table_add(struct jr2_private *priv, static int jr2_write_hwaddr(struct udevice *dev) { struct jr2_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); return jr2_mac_table_add(priv, pdata->enetaddr, PGID_UNICAST); } @@ -755,7 +755,7 @@ static void serdes_setup(struct jr2_private *priv) static int jr2_start(struct udevice *dev) { struct jr2_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const unsigned char mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int ret; @@ -964,6 +964,6 @@ U_BOOT_DRIVER(jr2) = { .probe = jr2_probe, .remove = jr2_remove, .ops = &jr2_ops, - .priv_auto_alloc_size = sizeof(struct jr2_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct jr2_private), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mscc_eswitch/luton_switch.c b/drivers/net/mscc_eswitch/luton_switch.c index 1d46d0e5e1..54afa14c9d 100644 --- a/drivers/net/mscc_eswitch/luton_switch.c +++ b/drivers/net/mscc_eswitch/luton_switch.c @@ -497,7 +497,7 @@ static int luton_initialize(struct luton_private *priv) static int luton_write_hwaddr(struct udevice *dev) { struct luton_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); mscc_mac_table_add(priv->regs[ANA], luton_regs_ana_table, pdata->enetaddr, PGID_UNICAST); @@ -510,7 +510,7 @@ static int luton_write_hwaddr(struct udevice *dev) static int luton_start(struct udevice *dev) { struct luton_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const unsigned char mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int ret; @@ -737,6 +737,6 @@ U_BOOT_DRIVER(luton) = { .probe = luton_probe, .remove = luton_remove, .ops = &luton_ops, - .priv_auto_alloc_size = sizeof(struct luton_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct luton_private), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mscc_eswitch/ocelot_switch.c b/drivers/net/mscc_eswitch/ocelot_switch.c index 2a48dc6a19..19e725c6f9 100644 --- a/drivers/net/mscc_eswitch/ocelot_switch.c +++ b/drivers/net/mscc_eswitch/ocelot_switch.c @@ -420,7 +420,7 @@ static int ocelot_initialize(struct ocelot_private *priv) static int ocelot_write_hwaddr(struct udevice *dev) { struct ocelot_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); mscc_mac_table_add(priv->regs[ANA], ocelot_regs_ana_table, pdata->enetaddr, PGID_UNICAST); @@ -433,7 +433,7 @@ static int ocelot_write_hwaddr(struct udevice *dev) static int ocelot_start(struct udevice *dev) { struct ocelot_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const unsigned char mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int ret; @@ -651,6 +651,6 @@ U_BOOT_DRIVER(ocelot) = { .probe = ocelot_probe, .remove = ocelot_remove, .ops = &ocelot_ops, - .priv_auto_alloc_size = sizeof(struct ocelot_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ocelot_private), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mscc_eswitch/serval_switch.c b/drivers/net/mscc_eswitch/serval_switch.c index d8ee1a7698..09ce33452d 100644 --- a/drivers/net/mscc_eswitch/serval_switch.c +++ b/drivers/net/mscc_eswitch/serval_switch.c @@ -373,7 +373,7 @@ static int serval_initialize(struct serval_private *priv) static int serval_write_hwaddr(struct udevice *dev) { struct serval_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); mscc_mac_table_add(priv->regs[ANA], serval_regs_ana_table, pdata->enetaddr, PGID_UNICAST); @@ -386,7 +386,7 @@ static int serval_write_hwaddr(struct udevice *dev) static int serval_start(struct udevice *dev) { struct serval_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const unsigned char mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int ret; @@ -604,6 +604,6 @@ U_BOOT_DRIVER(serval) = { .probe = serval_probe, .remove = serval_remove, .ops = &serval_ops, - .priv_auto_alloc_size = sizeof(struct serval_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct serval_private), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mscc_eswitch/servalt_switch.c b/drivers/net/mscc_eswitch/servalt_switch.c index 1cf2273142..4a4e9e4054 100644 --- a/drivers/net/mscc_eswitch/servalt_switch.c +++ b/drivers/net/mscc_eswitch/servalt_switch.c @@ -323,7 +323,7 @@ static int servalt_mac_table_add(struct servalt_private *priv, static int servalt_write_hwaddr(struct udevice *dev) { struct servalt_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); return servalt_mac_table_add(priv, pdata->enetaddr, PGID_UNICAST); } @@ -331,7 +331,7 @@ static int servalt_write_hwaddr(struct udevice *dev) static int servalt_start(struct udevice *dev) { struct servalt_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const unsigned char mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; int ret; @@ -523,6 +523,6 @@ U_BOOT_DRIVER(servalt) = { .probe = servalt_probe, .remove = servalt_remove, .ops = &servalt_ops, - .priv_auto_alloc_size = sizeof(struct servalt_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct servalt_private), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mt7628-eth.c b/drivers/net/mt7628-eth.c index 64f1c8c828..50d066a8ba 100644 --- a/drivers/net/mt7628-eth.c +++ b/drivers/net/mt7628-eth.c @@ -361,7 +361,7 @@ static int mt7628_eth_write_hwaddr(struct udevice *dev) { struct mt7628_eth_dev *priv = dev_get_priv(dev); void __iomem *base = priv->base; - u8 *addr = ((struct eth_pdata *)dev_get_platdata(dev))->enetaddr; + u8 *addr = ((struct eth_pdata *)dev_get_plat(dev))->enetaddr; u32 val; /* Set MAC address. */ @@ -651,6 +651,6 @@ U_BOOT_DRIVER(mt7628_eth) = { .of_match = mt7628_eth_ids, .probe = mt7628_eth_probe, .ops = &mt7628_eth_ops, - .priv_auto_alloc_size = sizeof(struct mt7628_eth_dev), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct mt7628_eth_dev), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c index 5183c08e14..26f02847a2 100644 --- a/drivers/net/mtk_eth.c +++ b/drivers/net/mtk_eth.c @@ -1278,7 +1278,7 @@ static void mtk_eth_stop(struct udevice *dev) static int mtk_eth_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mtk_eth_priv *priv = dev_get_priv(dev); unsigned char *mac = pdata->enetaddr; u32 macaddr_lsb, macaddr_msb; @@ -1358,7 +1358,7 @@ static int mtk_eth_free_pkt(struct udevice *dev, uchar *packet, int length) static int mtk_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mtk_eth_priv *priv = dev_get_priv(dev); ulong iobase = pdata->iobase; int ret; @@ -1407,9 +1407,9 @@ static int mtk_eth_remove(struct udevice *dev) return 0; } -static int mtk_eth_ofdata_to_platdata(struct udevice *dev) +static int mtk_eth_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mtk_eth_priv *priv = dev_get_priv(dev); struct ofnode_phandle_args args; struct regmap *regmap; @@ -1558,11 +1558,11 @@ U_BOOT_DRIVER(mtk_eth) = { .name = "mtk-eth", .id = UCLASS_ETH, .of_match = mtk_eth_ids, - .ofdata_to_platdata = mtk_eth_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .of_to_plat = mtk_eth_of_to_plat, + .plat_auto = sizeof(struct eth_pdata), .probe = mtk_eth_probe, .remove = mtk_eth_remove, .ops = &mtk_eth_ops, - .priv_auto_alloc_size = sizeof(struct mtk_eth_priv), + .priv_auto = sizeof(struct mtk_eth_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c index 2f9464b961..2452859f81 100644 --- a/drivers/net/mvgbe.c +++ b/drivers/net/mvgbe.c @@ -554,7 +554,7 @@ static int mvgbe_halt(struct eth_device *dev) #ifdef CONFIG_DM_ETH static int mvgbe_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); port_uc_addr_set(dev_get_priv(dev), pdata->enetaddr); @@ -906,7 +906,7 @@ static int mvgbe_port_is_fixed_link(struct mvgbe_device *dmvgbe) static int mvgbe_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mvgbe_device *dmvgbe = dev_get_priv(dev); int ret; @@ -948,7 +948,7 @@ static void mvgbe_stop(struct udevice *dev) static int mvgbe_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mvgbe_device *dmvgbe = dev_get_priv(dev); struct mii_dev *bus; int ret; @@ -986,9 +986,9 @@ static const struct eth_ops mvgbe_ops = { .write_hwaddr = mvgbe_write_hwaddr, }; -static int mvgbe_ofdata_to_platdata(struct udevice *dev) +static int mvgbe_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mvgbe_device *dmvgbe = dev_get_priv(dev); void *blob = (void *)gd->fdt_blob; int node = dev_of_offset(dev); @@ -1038,10 +1038,10 @@ U_BOOT_DRIVER(mvgbe) = { .name = "mvgbe", .id = UCLASS_ETH, .of_match = mvgbe_ids, - .ofdata_to_platdata = mvgbe_ofdata_to_platdata, + .of_to_plat = mvgbe_of_to_plat, .probe = mvgbe_probe, .ops = &mvgbe_ops, - .priv_auto_alloc_size = sizeof(struct mvgbe_device), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct mvgbe_device), + .plat_auto = sizeof(struct eth_pdata), }; #endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/mvmdio.c b/drivers/net/mvmdio.c index a8e93e80fc..96f8dc62b5 100644 --- a/drivers/net/mvmdio.c +++ b/drivers/net/mvmdio.c @@ -197,8 +197,8 @@ static int mvmdio_write(struct udevice *dev, int addr, int devad, int reg, */ static int mvmdio_bind(struct udevice *dev) { - if (ofnode_valid(dev->node)) - device_set_name(dev, ofnode_get_name(dev->node)); + if (ofnode_valid(dev_ofnode(dev))) + device_set_name(dev, ofnode_get_name(dev_ofnode(dev))); return 0; } @@ -232,6 +232,6 @@ U_BOOT_DRIVER(mvmdio) = { .bind = mvmdio_bind, .probe = mvmdio_probe, .ops = &mvmdio_ops, - .priv_auto_alloc_size = sizeof(struct mvmdio_priv), + .priv_auto = sizeof(struct mvmdio_priv), }; diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index 83f99e5d8a..3192cf5509 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -896,7 +896,7 @@ static void mvneta_mac_addr_set(struct mvneta_port *pp, unsigned char *addr, static int mvneta_write_hwaddr(struct udevice *dev) { mvneta_mac_addr_set(dev_get_priv(dev), - ((struct eth_pdata *)dev_get_platdata(dev))->enetaddr, + ((struct eth_pdata *)dev_get_plat(dev))->enetaddr, rxq_def); return 0; @@ -1397,7 +1397,7 @@ static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode) /* Device initialization routine */ static int mvneta_init(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mvneta_port *pp = dev_get_priv(dev); int err; @@ -1690,7 +1690,7 @@ static int mvneta_recv(struct udevice *dev, int flags, uchar **packetp) static int mvneta_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mvneta_port *pp = dev_get_priv(dev); void *blob = (void *)gd->fdt_blob; int node = dev_of_offset(dev); @@ -1732,7 +1732,7 @@ static int mvneta_probe(struct udevice *dev) else mvneta_conf_mbus_windows(pp); - /* PHY interface is already decoded in mvneta_ofdata_to_platdata() */ + /* PHY interface is already decoded in mvneta_of_to_plat() */ pp->phy_interface = pdata->phy_interface; /* fetch 'fixed-link' property from 'neta' node */ @@ -1795,9 +1795,9 @@ static const struct eth_ops mvneta_ops = { .write_hwaddr = mvneta_write_hwaddr, }; -static int mvneta_ofdata_to_platdata(struct udevice *dev) +static int mvneta_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const char *phy_mode; pdata->iobase = dev_read_addr(dev); @@ -1827,9 +1827,9 @@ U_BOOT_DRIVER(mvneta) = { .name = "mvneta", .id = UCLASS_ETH, .of_match = mvneta_ids, - .ofdata_to_platdata = mvneta_ofdata_to_platdata, + .of_to_plat = mvneta_of_to_plat, .probe = mvneta_probe, .ops = &mvneta_ops, - .priv_auto_alloc_size = sizeof(struct mvneta_port), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct mvneta_port), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c index 8f790a8b44..d266e6d0f3 100644 --- a/drivers/net/mvpp2.c +++ b/drivers/net/mvpp2.c @@ -5186,7 +5186,7 @@ static int mvpp2_send(struct udevice *dev, void *packet, int length) static int mvpp2_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct mvpp2_port *port = dev_get_priv(dev); /* Load current MAC address */ @@ -5424,8 +5424,8 @@ static struct driver mvpp2_driver = { .probe = mvpp2_probe, .remove = mvpp2_remove, .ops = &mvpp2_ops, - .priv_auto_alloc_size = sizeof(struct mvpp2_port), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct mvpp2_port), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ACTIVE_DMA, }; @@ -5477,8 +5477,8 @@ static int mvpp2_base_bind(struct udevice *parent) sprintf(name, "mvpp2-%d", id); /* Create child device UCLASS_ETH and bind it */ - device_bind(parent, &mvpp2_driver, name, plat, subnode, &dev); - dev_set_of_offset(dev, subnode); + device_bind(parent, &mvpp2_driver, name, plat, + offset_to_ofnode(subnode), &dev); } return 0; @@ -5501,5 +5501,5 @@ U_BOOT_DRIVER(mvpp2_base) = { .id = UCLASS_MISC, .of_match = mvpp2_ids, .bind = mvpp2_base_bind, - .priv_auto_alloc_size = sizeof(struct mvpp2), + .priv_auto = sizeof(struct mvpp2), }; diff --git a/drivers/net/octeontx/bgx.c b/drivers/net/octeontx/bgx.c index fbe2e2c073..2ea54be84d 100644 --- a/drivers/net/octeontx/bgx.c +++ b/drivers/net/octeontx/bgx.c @@ -1552,7 +1552,7 @@ U_BOOT_DRIVER(octeontx_bgx) = { .id = UCLASS_MISC, .probe = octeontx_bgx_probe, .remove = octeontx_bgx_remove, - .priv_auto_alloc_size = sizeof(struct bgx), + .priv_auto = sizeof(struct bgx), .flags = DM_FLAG_OS_PREPARE, }; diff --git a/drivers/net/octeontx/nic_main.c b/drivers/net/octeontx/nic_main.c index 1a805f7a46..8f05d4e720 100644 --- a/drivers/net/octeontx/nic_main.c +++ b/drivers/net/octeontx/nic_main.c @@ -766,7 +766,7 @@ U_BOOT_DRIVER(octeontx_nic) = { .name = "octeontx_nic", .id = UCLASS_MISC, .probe = octeontx_nic_probe, - .priv_auto_alloc_size = sizeof(struct nicpf), + .priv_auto = sizeof(struct nicpf), }; static struct pci_device_id octeontx_nic_supported[] = { diff --git a/drivers/net/octeontx/nicvf_main.c b/drivers/net/octeontx/nicvf_main.c index e13c8b9556..c30ba49c27 100644 --- a/drivers/net/octeontx/nicvf_main.c +++ b/drivers/net/octeontx/nicvf_main.c @@ -105,7 +105,7 @@ static int nicvf_check_pf_ready(struct nicvf *nic) static void nicvf_handle_mbx_intr(struct nicvf *nic) { union nic_mbx mbx = {}; - struct eth_pdata *pdata = dev_get_platdata(nic->dev); + struct eth_pdata *pdata = dev_get_plat(nic->dev); u64 *mbx_data; u64 mbx_addr; int i; @@ -165,7 +165,7 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic) static int nicvf_hw_set_mac_addr(struct nicvf *nic, struct udevice *dev) { union nic_mbx mbx = {}; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); mbx.mac.msg = NIC_MBOX_MSG_SET_MAC; mbx.mac.vf_id = nic->vf_id; @@ -445,18 +445,19 @@ int nicvf_open(struct udevice *dev) int nicvf_write_hwaddr(struct udevice *dev) { unsigned char ethaddr[ARP_HLEN]; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct nicvf *nic = dev_get_priv(dev); /* If lower level firmware fails to set proper MAC * u-boot framework updates MAC to random address. * Use this hook to update mac address in environment. */ - if (!eth_env_get_enetaddr_by_index("eth", dev->seq, ethaddr)) { - eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr); + if (!eth_env_get_enetaddr_by_index("eth", dev_seq(dev), ethaddr)) { + eth_env_set_enetaddr_by_index("eth", dev_seq(dev), + pdata->enetaddr); debug("%s: pMAC %pM\n", __func__, pdata->enetaddr); } - eth_env_get_enetaddr_by_index("eth", dev->seq, ethaddr); + eth_env_get_enetaddr_by_index("eth", dev_seq(dev), ethaddr); if (memcmp(ethaddr, pdata->enetaddr, ARP_HLEN)) { debug("%s: pMAC %pM\n", __func__, pdata->enetaddr); nicvf_hw_set_mac_addr(nic, dev); @@ -484,7 +485,7 @@ static void nicvf_probe_mdio_devices(void) int nicvf_initialize(struct udevice *dev) { struct nicvf *nicvf = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int ret = 0, bgx, lmac; char name[16]; unsigned char ethaddr[ARP_HLEN]; @@ -540,7 +541,7 @@ int nicvf_initialize(struct udevice *dev) if (is_valid_ethaddr(ethaddr)) { memcpy(pdata->enetaddr, ethaddr, ARP_HLEN); - eth_env_set_enetaddr_by_index("eth", dev->seq, ethaddr); + eth_env_set_enetaddr_by_index("eth", dev_seq(dev), ethaddr); } debug("%s enetaddr %pM ethaddr %pM\n", __func__, pdata->enetaddr, ethaddr); @@ -568,8 +569,8 @@ U_BOOT_DRIVER(octeontx_vnic) = { .id = UCLASS_ETH, .probe = octeontx_vnic_probe, .ops = &octeontx_vnic_ops, - .priv_auto_alloc_size = sizeof(struct nicvf), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct nicvf), + .plat_auto = sizeof(struct eth_pdata), }; static struct pci_device_id octeontx_vnic_supported[] = { diff --git a/drivers/net/octeontx/smi.c b/drivers/net/octeontx/smi.c index 8e2c3ca5a3..58436419f1 100644 --- a/drivers/net/octeontx/smi.c +++ b/drivers/net/octeontx/smi.c @@ -313,13 +313,12 @@ read_error: int octeontx_smi_probe(struct udevice *dev) { - int ret, subnode, cnt = 0, node = dev->node.of_offset; + int ret, subnode, cnt = 0, node = dev_ofnode(dev).of_offset; struct mii_dev *bus; struct octeontx_smi_priv *priv; pci_dev_t bdf = dm_pci_get_bdf(dev); debug("SMI PCI device: %x\n", bdf); - dev->req_seq = PCI_FUNC(bdf); if (!dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM)) { printf("Failed to map PCI region for bdf %x\n", bdf); return -1; @@ -335,7 +334,7 @@ int octeontx_smi_probe(struct udevice *dev) priv = malloc(sizeof(*priv)); if (!bus || !priv) { printf("Failed to allocate OcteonTX MDIO bus # %u\n", - dev->seq); + dev_seq(dev)); return -1; } diff --git a/drivers/net/octeontx2/cgx.c b/drivers/net/octeontx2/cgx.c index ff2ebc25ce..189fe7c631 100644 --- a/drivers/net/octeontx2/cgx.c +++ b/drivers/net/octeontx2/cgx.c @@ -285,7 +285,7 @@ U_BOOT_DRIVER(cgx) = { .id = UCLASS_MISC, .probe = cgx_probe, .remove = cgx_remove, - .priv_auto_alloc_size = sizeof(struct cgx), + .priv_auto = sizeof(struct cgx), }; static struct pci_device_id cgx_supported[] = { diff --git a/drivers/net/octeontx2/nix.c b/drivers/net/octeontx2/nix.c index 0a3e8e4af0..039c44b654 100644 --- a/drivers/net/octeontx2/nix.c +++ b/drivers/net/octeontx2/nix.c @@ -727,7 +727,7 @@ int nix_lf_setup_mac(struct udevice *dev) { struct rvu_pf *rvu = dev_get_priv(dev); struct nix *nix = rvu->nix; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); /* If lower level firmware fails to set proper MAC * u-boot framework updates MAC to random address. @@ -736,7 +736,7 @@ int nix_lf_setup_mac(struct udevice *dev) */ if (memcmp(nix->lmac->mac_addr, pdata->enetaddr, ARP_HLEN)) { memcpy(nix->lmac->mac_addr, pdata->enetaddr, 6); - eth_env_set_enetaddr_by_index("eth", rvu->dev->seq, + eth_env_set_enetaddr_by_index("eth", dev_seq(rvu->dev), pdata->enetaddr); cgx_lmac_mac_filter_setup(nix->lmac); /* Update user given MAC address to ATF for update diff --git a/drivers/net/octeontx2/rvu_af.c b/drivers/net/octeontx2/rvu_af.c index 7750089a20..d2f9654861 100644 --- a/drivers/net/octeontx2/rvu_af.c +++ b/drivers/net/octeontx2/rvu_af.c @@ -160,7 +160,7 @@ U_BOOT_DRIVER(rvu_af) = { .id = UCLASS_MISC, .probe = rvu_af_probe, .remove = rvu_af_remove, - .priv_auto_alloc_size = sizeof(struct rvu_af), + .priv_auto = sizeof(struct rvu_af), }; static struct pci_device_id rvu_af_supported[] = { diff --git a/drivers/net/octeontx2/rvu_pf.c b/drivers/net/octeontx2/rvu_pf.c index 201ecf2c16..4b00178989 100644 --- a/drivers/net/octeontx2/rvu_pf.c +++ b/drivers/net/octeontx2/rvu_pf.c @@ -20,7 +20,7 @@ extern struct udevice *rvu_af_dev; int rvu_pf_init(struct rvu_pf *rvu) { struct nix *nix; - struct eth_pdata *pdata = dev_get_platdata(rvu->dev); + struct eth_pdata *pdata = dev_get_plat(rvu->dev); debug("%s: Allocating nix lf\n", __func__); nix = nix_lf_alloc(rvu->dev); @@ -34,7 +34,7 @@ int rvu_pf_init(struct rvu_pf *rvu) /* to make post_probe happy */ if (is_valid_ethaddr(nix->lmac->mac_addr)) { memcpy(pdata->enetaddr, nix->lmac->mac_addr, 6); - eth_env_set_enetaddr_by_index("eth", rvu->dev->seq, + eth_env_set_enetaddr_by_index("eth", dev_seq(rvu->dev), pdata->enetaddr); } @@ -59,7 +59,7 @@ int rvu_pf_probe(struct udevice *dev) debug("%s: name: %s\n", __func__, dev->name); rvu->pf_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_2, PCI_REGION_MEM); - rvu->pfid = dev->seq + 1; // RVU PF's start from 1; + rvu->pfid = dev_seq(dev) + 1; // RVU PF's start from 1; rvu->dev = dev; if (!rvu_af_dev) { printf("%s: Error: Could not find RVU AF device\n", @@ -80,7 +80,7 @@ int rvu_pf_probe(struct udevice *dev) * modify device name to include index/sequence number, * for better readability, this is 1:1 mapping with eth0/1/2.. names. */ - sprintf(name, "rvu_pf#%d", dev->seq); + sprintf(name, "rvu_pf#%d", dev_seq(dev)); device_set_name(dev, name); debug("%s: name: %s\n", __func__, dev->name); return err; @@ -104,8 +104,8 @@ U_BOOT_DRIVER(rvu_pf) = { .probe = rvu_pf_probe, .remove = rvu_pf_remove, .ops = &nix_eth_ops, - .priv_auto_alloc_size = sizeof(struct rvu_pf), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct rvu_pf), + .plat_auto = sizeof(struct eth_pdata), }; static struct pci_device_id rvu_pf_supported[] = { diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 1daafbe2b9..fabcf85c0d 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -68,7 +68,7 @@ static int pch_gbe_mac_write(struct pch_gbe_regs *mac_regs, u8 *addr) static int pch_gbe_reset(struct udevice *dev) { struct pch_gbe_priv *priv = dev_get_priv(dev); - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct pch_gbe_regs *mac_regs = priv->mac_regs; ulong start; @@ -412,7 +412,7 @@ static int pch_gbe_mdio_init(const char *name, struct pch_gbe_regs *mac_regs) static int pch_gbe_phy_init(struct udevice *dev) { struct pch_gbe_priv *priv = dev_get_priv(dev); - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct phy_device *phydev; int mask = 0xffffffff; @@ -436,7 +436,7 @@ static int pch_gbe_phy_init(struct udevice *dev) static int pch_gbe_probe(struct udevice *dev) { struct pch_gbe_priv *priv; - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); void *iobase; int err; @@ -499,8 +499,8 @@ U_BOOT_DRIVER(eth_pch_gbe) = { .probe = pch_gbe_probe, .remove = pch_gbe_remove, .ops = &pch_gbe_ops, - .priv_auto_alloc_size = sizeof(struct pch_gbe_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct pch_gbe_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c index ad5ac6618f..59ef104334 100644 --- a/drivers/net/pcnet.c +++ b/drivers/net/pcnet.c @@ -585,7 +585,7 @@ int pcnet_initialize(struct bd_info *bis) #else /* DM_ETH */ static int pcnet_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct pcnet_priv *priv = dev_get_priv(dev); memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); @@ -638,7 +638,7 @@ static int pcnet_bind(struct udevice *dev) static int pcnet_probe(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct pcnet_priv *lp = dev_get_priv(dev); u16 command, status; u32 iobase; @@ -689,8 +689,8 @@ U_BOOT_DRIVER(eth_pcnet) = { .bind = pcnet_bind, .probe = pcnet_probe, .ops = &pcnet_ops, - .priv_auto_alloc_size = sizeof(struct pcnet_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct pcnet_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_UC_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/pfe_eth/pfe_eth.c b/drivers/net/pfe_eth/pfe_eth.c index 3b4ca0393c..0c27a668b5 100644 --- a/drivers/net/pfe_eth/pfe_eth.c +++ b/drivers/net/pfe_eth/pfe_eth.c @@ -87,7 +87,7 @@ static int pfe_eth_write_hwaddr(struct udevice *dev) { struct pfe_eth_dev *priv = dev_get_priv(dev); struct gemac_s *gem = priv->gem; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); uchar *mac = pdata->enetaddr; writel((mac[0] << 24) + (mac[1] << 16) + (mac[2] << 8) + mac[3], @@ -157,7 +157,7 @@ static int pfe_eth_start(struct udevice *dev) static int pfe_eth_send(struct udevice *dev, void *packet, int length) { - struct pfe_eth_dev *priv = (struct pfe_eth_dev *)dev->priv; + struct pfe_eth_dev *priv = (struct pfe_eth_dev *)dev_get_priv(dev); int rc; int i = 0; @@ -215,7 +215,7 @@ static int pfe_eth_probe(struct udevice *dev) { struct pfe_eth_dev *priv = dev_get_priv(dev); struct pfe_ddr_address pfe_addr; - struct pfe_eth_pdata *pdata = dev_get_platdata(dev); + struct pfe_eth_pdata *pdata = dev_get_plat(dev); int ret = 0; static int init_done; @@ -266,7 +266,7 @@ static int pfe_eth_probe(struct udevice *dev) static int pfe_eth_bind(struct udevice *dev) { - struct pfe_eth_pdata *pdata = dev_get_platdata(dev); + struct pfe_eth_pdata *pdata = dev_get_plat(dev); char name[20]; sprintf(name, "pfe_eth%u", pdata->pfe_eth_pdata_mac.phy_interface); @@ -290,6 +290,6 @@ U_BOOT_DRIVER(pfe_eth) = { .probe = pfe_eth_probe, .remove = pfe_eth_remove, .ops = &pfe_eth_ops, - .priv_auto_alloc_size = sizeof(struct pfe_eth_dev), - .platdata_auto_alloc_size = sizeof(struct pfe_eth_pdata) + .priv_auto = sizeof(struct pfe_eth_dev), + .plat_auto = sizeof(struct pfe_eth_pdata) }; diff --git a/drivers/net/pic32_eth.c b/drivers/net/pic32_eth.c index 6a2084947b..9eba55affb 100644 --- a/drivers/net/pic32_eth.c +++ b/drivers/net/pic32_eth.c @@ -326,7 +326,7 @@ static void pic32_rx_desc_init(struct pic32eth_dev *priv) static int pic32_eth_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct pic32eth_dev *priv = dev_get_priv(dev); /* controller */ @@ -531,7 +531,7 @@ static const struct eth_ops pic32_eth_ops = { static int pic32_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct pic32eth_dev *priv = dev_get_priv(dev); const char *phy_mode; void __iomem *iobase; @@ -606,6 +606,6 @@ U_BOOT_DRIVER(pic32_ethernet) = { .probe = pic32_eth_probe, .remove = pic32_eth_remove, .ops = &pic32_eth_ops, - .priv_auto_alloc_size = sizeof(struct pic32eth_dev), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct pic32eth_dev), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/qe/dm_qe_uec.c b/drivers/net/qe/dm_qe_uec.c index 3482b3ff17..a33068cc70 100644 --- a/drivers/net/qe/dm_qe_uec.c +++ b/drivers/net/qe/dm_qe_uec.c @@ -416,7 +416,7 @@ static void qe_uec_stop(struct udevice *dev) static int qe_uec_set_hwaddr(struct udevice *dev) { struct qe_uec_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct uec_priv *uec = priv->uec; uec_t *uec_regs = uec->uec_regs; uchar *mac = pdata->enetaddr; @@ -982,7 +982,7 @@ static void qe_uec_set_eth_type(struct udevice *dev) static int qe_uec_set_uec_info(struct udevice *dev) { struct qe_uec_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct uec_priv *uec = priv->uec; struct uec_inf *uec_info; struct ucc_fast_inf *uf_info; @@ -1086,7 +1086,7 @@ out: static int qe_uec_probe(struct udevice *dev) { struct qe_uec_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct uec_priv *uec; int ret; @@ -1129,9 +1129,9 @@ static int qe_uec_remove(struct udevice *dev) return 0; } -static int qe_uec_ofdata_to_platdata(struct udevice *dev) +static int qe_uec_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const char *phy_mode; pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); @@ -1158,10 +1158,10 @@ U_BOOT_DRIVER(eth_qe_uec) = { .name = QE_UEC_DRIVER_NAME, .id = UCLASS_ETH, .of_match = qe_uec_ids, - .ofdata_to_platdata = qe_uec_ofdata_to_platdata, + .of_to_plat = qe_uec_of_to_plat, .probe = qe_uec_probe, .remove = qe_uec_remove, .ops = &qe_uec_eth_ops, - .priv_auto_alloc_size = sizeof(struct qe_uec_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct qe_uec_priv), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/qe/dm_qe_uec_phy.c b/drivers/net/qe/dm_qe_uec_phy.c index 02ce08edad..038b810460 100644 --- a/drivers/net/qe/dm_qe_uec_phy.c +++ b/drivers/net/qe/dm_qe_uec_phy.c @@ -159,5 +159,5 @@ U_BOOT_DRIVER(mvmdio) = { .of_match = qe_uec_mdio_ids, .probe = qe_uec_mdio_probe, .ops = &qe_uec_mdio_ops, - .priv_auto_alloc_size = sizeof(struct qe_uec_mdio_priv), + .priv_auto = sizeof(struct qe_uec_mdio_priv), }; diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 98883cd15b..34e2b8f9e9 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -306,7 +306,7 @@ static void ravb_rx_desc_init(struct ravb_priv *eth) static int ravb_phy_config(struct udevice *dev) { struct ravb_priv *eth = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct phy_device *phydev; int mask = 0xffffffff, reg; @@ -346,7 +346,7 @@ static int ravb_phy_config(struct udevice *dev) static int ravb_write_hwaddr(struct udevice *dev) { struct ravb_priv *eth = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); unsigned char *mac = pdata->enetaddr; writel((mac[0] << 24) | (mac[1] << 16) | (mac[2] << 8) | mac[3], @@ -373,7 +373,7 @@ static int ravb_mac_init(struct ravb_priv *eth) static int ravb_dmac_init(struct udevice *dev) { struct ravb_priv *eth = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int ret = 0; /* Set CONFIG mode */ @@ -474,7 +474,7 @@ static void ravb_stop(struct udevice *dev) static int ravb_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ravb_priv *eth = dev_get_priv(dev); struct ofnode_phandle_args phandle_args; struct mii_dev *mdiodev; @@ -642,9 +642,9 @@ static const struct eth_ops ravb_ops = { .write_hwaddr = ravb_write_hwaddr, }; -int ravb_ofdata_to_platdata(struct udevice *dev) +int ravb_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const char *phy_mode; const fdt32_t *cell; int ret = 0; @@ -685,11 +685,11 @@ U_BOOT_DRIVER(eth_ravb) = { .name = "ravb", .id = UCLASS_ETH, .of_match = ravb_ids, - .ofdata_to_platdata = ravb_ofdata_to_platdata, + .of_to_plat = ravb_of_to_plat, .probe = ravb_probe, .remove = ravb_remove, .ops = &ravb_ops, - .priv_auto_alloc_size = sizeof(struct ravb_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ravb_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index 71f2aba4c7..feeea930fb 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -660,7 +660,7 @@ int rtl8139_initialize(struct bd_info *bis) #else /* DM_ETH */ static int rtl8139_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct rtl8139_priv *priv = dev_get_priv(dev); memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); @@ -704,7 +704,7 @@ static int rtl8139_free_pkt(struct udevice *dev, uchar *packet, int length) static int rtl8139_write_hwaddr(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct rtl8139_priv *priv = dev_get_priv(dev); memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); @@ -735,7 +735,7 @@ static int rtl8139_bind(struct udevice *dev) static int rtl8139_probe(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct rtl8139_priv *priv = dev_get_priv(dev); u32 iobase; @@ -771,8 +771,8 @@ U_BOOT_DRIVER(eth_rtl8139) = { .bind = rtl8139_bind, .probe = rtl8139_probe, .ops = &rtl8139_ops, - .priv_auto_alloc_size = sizeof(struct rtl8139_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct rtl8139_priv), + .plat_auto = sizeof(struct eth_pdata), }; U_BOOT_PCI_DEVICE(eth_rtl8139, supported); diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index 2e1304e44d..da2cfb7f55 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -890,7 +890,7 @@ static void rtl8169_common_start(pci_dev_t dev, unsigned char *enetaddr, #ifdef CONFIG_DM_ETH static int rtl8169_eth_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct rtl8169_private *priv = dev_get_priv(dev); rtl8169_common_start(dev, plat->enetaddr, priv->iobase); @@ -953,7 +953,7 @@ static void rtl_halt(struct eth_device *dev) #ifdef CONFIG_DM_ETH static int rtl8169_write_hwaddr(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); unsigned int i; RTL_W8(Cfg9346, Cfg9346_Unlock); @@ -1187,9 +1187,9 @@ int rtl8169_initialize(struct bd_info *bis) #ifdef CONFIG_DM_ETH static int rtl8169_eth_probe(struct udevice *dev) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); struct rtl8169_private *priv = dev_get_priv(dev); - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); u32 iobase; int region; int ret; @@ -1248,8 +1248,8 @@ U_BOOT_DRIVER(eth_rtl8169) = { .of_match = rtl8169_eth_ids, .probe = rtl8169_eth_probe, .ops = &rtl8169_eth_ops, - .priv_auto_alloc_size = sizeof(struct rtl8169_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct rtl8169_private), + .plat_auto = sizeof(struct eth_pdata), }; U_BOOT_PCI_DEVICE(eth_rtl8169, supported); diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c index 4bd94c3103..8273f73c91 100644 --- a/drivers/net/sandbox-raw.c +++ b/drivers/net/sandbox-raw.c @@ -22,7 +22,7 @@ static struct in_addr arp_ip; static int sb_eth_raw_start(struct udevice *dev) { struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int ret; debug("eth_sandbox_raw: Start\n"); @@ -65,7 +65,7 @@ static int sb_eth_raw_send(struct udevice *dev, void *packet, int length) static int sb_eth_raw_recv(struct udevice *dev, int flags, uchar **packetp) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); int retval = 0; int length; @@ -134,7 +134,7 @@ static void sb_eth_raw_stop(struct udevice *dev) static int sb_eth_raw_read_rom_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); net_random_ethaddr(pdata->enetaddr); @@ -149,9 +149,9 @@ static const struct eth_ops sb_eth_raw_ops = { .read_rom_hwaddr = sb_eth_raw_read_rom_hwaddr, }; -static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) +static int sb_eth_raw_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); const char *ifname; int ret; @@ -191,8 +191,8 @@ U_BOOT_DRIVER(eth_sandbox_raw) = { .name = "eth_sandbox_raw", .id = UCLASS_ETH, .of_match = sb_eth_raw_ids, - .ofdata_to_platdata = sb_eth_raw_ofdata_to_platdata, + .of_to_plat = sb_eth_raw_of_to_plat, .ops = &sb_eth_raw_ops, - .priv_auto_alloc_size = sizeof(struct eth_sandbox_raw_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct eth_sandbox_raw_priv), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 4f7e3d4243..a389e2bd0d 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -393,7 +393,7 @@ static void sb_eth_stop(struct udevice *dev) static int sb_eth_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); debug("eth_sandbox %s: Write HW ADDR - %pM\n", dev->name, pdata->enetaddr); @@ -414,9 +414,9 @@ static int sb_eth_remove(struct udevice *dev) return 0; } -static int sb_eth_ofdata_to_platdata(struct udevice *dev) +static int sb_eth_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct eth_sandbox_priv *priv = dev_get_priv(dev); const u8 *mac; @@ -443,9 +443,9 @@ U_BOOT_DRIVER(eth_sandbox) = { .name = "eth_sandbox", .id = UCLASS_ETH, .of_match = sb_eth_ids, - .ofdata_to_platdata = sb_eth_ofdata_to_platdata, + .of_to_plat = sb_eth_of_to_plat, .remove = sb_eth_remove, .ops = &sb_eth_ops, - .priv_auto_alloc_size = sizeof(struct eth_sandbox_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct eth_sandbox_priv), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 4cbffb14c5..1666a8cdb2 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -744,7 +744,7 @@ static int sh_ether_write_hwaddr(struct udevice *dev) struct sh_ether_priv *priv = dev_get_priv(dev); struct sh_eth_dev *eth = &priv->shdev; struct sh_eth_info *port_info = ð->port_info[eth->port]; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); sh_eth_write_hwaddr(port_info, pdata->enetaddr); @@ -754,7 +754,7 @@ static int sh_ether_write_hwaddr(struct udevice *dev) static int sh_eth_phy_config(struct udevice *dev) { struct sh_ether_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct sh_eth_dev *eth = &priv->shdev; int ret = 0; struct sh_eth_info *port_info = ð->port_info[eth->port]; @@ -776,7 +776,7 @@ static int sh_eth_phy_config(struct udevice *dev) static int sh_ether_start(struct udevice *dev) { struct sh_ether_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct sh_eth_dev *eth = &priv->shdev; int ret; @@ -808,7 +808,7 @@ static void sh_ether_stop(struct udevice *dev) static int sh_ether_probe(struct udevice *udev) { - struct eth_pdata *pdata = dev_get_platdata(udev); + struct eth_pdata *pdata = dev_get_plat(udev); struct sh_ether_priv *priv = dev_get_priv(udev); struct sh_eth_dev *eth = &priv->shdev; struct ofnode_phandle_args phandle_args; @@ -911,9 +911,9 @@ static const struct eth_ops sh_ether_ops = { .write_hwaddr = sh_ether_write_hwaddr, }; -int sh_ether_ofdata_to_platdata(struct udevice *dev) +int sh_ether_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const char *phy_mode; const fdt32_t *cell; int ret = 0; @@ -953,12 +953,12 @@ U_BOOT_DRIVER(eth_sh_ether) = { .name = "sh_ether", .id = UCLASS_ETH, .of_match = sh_ether_ids, - .ofdata_to_platdata = sh_ether_ofdata_to_platdata, + .of_to_plat = sh_ether_of_to_plat, .probe = sh_ether_probe, .remove = sh_ether_remove, .ops = &sh_ether_ops, - .priv_auto_alloc_size = sizeof(struct sh_ether_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct sh_ether_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 09372d7f6b..7b79831c28 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -536,7 +536,7 @@ err_detect: static int smc911x_start(struct udevice *dev) { - struct eth_pdata *plat = dev_get_platdata(dev); + struct eth_pdata *plat = dev_get_plat(dev); struct smc911x_priv *priv = dev_get_priv(dev); memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); @@ -577,7 +577,7 @@ static int smc911x_recv(struct udevice *dev, int flags, uchar **packetp) static int smc911x_read_rom_hwaddr(struct udevice *dev) { struct smc911x_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); if (!smc911x_read_mac_address(priv)) return -ENODEV; @@ -607,10 +607,10 @@ static int smc911x_probe(struct udevice *dev) return 0; } -static int smc911x_ofdata_to_platdata(struct udevice *dev) +static int smc911x_of_to_plat(struct udevice *dev) { struct smc911x_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); pdata->iobase = dev_read_addr(dev); priv->iobase = pdata->iobase; @@ -636,11 +636,11 @@ U_BOOT_DRIVER(smc911x) = { .id = UCLASS_ETH, .of_match = smc911x_ids, .bind = smc911x_bind, - .ofdata_to_platdata = smc911x_ofdata_to_platdata, + .of_to_plat = smc911x_of_to_plat, .probe = smc911x_probe, .ops = &smc911x_ops, - .priv_auto_alloc_size = sizeof(struct smc911x_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct smc911x_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c index 0f7ada8c3e..0ebe86a333 100644 --- a/drivers/net/sni_ave.c +++ b/drivers/net/sni_ave.c @@ -299,7 +299,7 @@ static int ave_mdiobus_write(struct mii_dev *bus, static int ave_adjust_link(struct ave_private *priv) { struct phy_device *phydev = priv->phydev; - struct eth_pdata *pdata = dev_get_platdata(phydev->dev); + struct eth_pdata *pdata = dev_get_plat(phydev->dev); u32 val, txcr, rxcr, rxcr_org; u16 rmt_adv = 0, lcl_adv = 0; u8 cap; @@ -516,7 +516,7 @@ static int ave_start(struct udevice *dev) static int ave_write_hwaddr(struct udevice *dev) { struct ave_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); u8 *mac = pdata->enetaddr; writel(mac[0] | mac[1] << 8 | mac[2] << 16 | mac[3] << 24, @@ -732,9 +732,9 @@ static int ave_pxs3_get_pinmode(struct ave_private *priv) return 0; } -static int ave_ofdata_to_platdata(struct udevice *dev) +static int ave_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ave_private *priv = dev_get_priv(dev); struct ofnode_phandle_args args; const char *phy_mode; @@ -826,7 +826,7 @@ out_clk_free: static int ave_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ave_private *priv = dev_get_priv(dev); int ret, nc, nr; @@ -996,8 +996,8 @@ U_BOOT_DRIVER(ave) = { .of_match = ave_ids, .probe = ave_probe, .remove = ave_remove, - .ofdata_to_platdata = ave_ofdata_to_platdata, + .of_to_plat = ave_of_to_plat, .ops = &ave_ops, - .priv_auto_alloc_size = sizeof(struct ave_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ave_private), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index 4524604126..cf15e9f475 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -255,7 +255,7 @@ static int sun8i_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, static int sun8i_eth_write_hwaddr(struct udevice *dev) { struct emac_eth_dev *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); uchar *mac_id = pdata->enetaddr; u32 macid_lo, macid_hi; @@ -712,7 +712,7 @@ static int sun8i_mdio_reset(struct mii_dev *bus) { struct udevice *dev = bus->priv; struct emac_eth_dev *priv = dev_get_priv(dev); - struct sun8i_eth_pdata *pdata = dev_get_platdata(dev); + struct sun8i_eth_pdata *pdata = dev_get_plat(dev); int ret; if (!dm_gpio_is_valid(&priv->reset_gpio)) @@ -799,7 +799,7 @@ static void sun8i_emac_eth_stop(struct udevice *dev) static int sun8i_emac_eth_probe(struct udevice *dev) { - struct sun8i_eth_pdata *sun8i_pdata = dev_get_platdata(dev); + struct sun8i_eth_pdata *sun8i_pdata = dev_get_plat(dev); struct eth_pdata *pdata = &sun8i_pdata->eth_pdata; struct emac_eth_dev *priv = dev_get_priv(dev); int ret; @@ -861,9 +861,9 @@ static int sun8i_handle_internal_phy(struct udevice *dev, struct emac_eth_dev *p return 0; } -static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) +static int sun8i_emac_eth_of_to_plat(struct udevice *dev) { - struct sun8i_eth_pdata *sun8i_pdata = dev_get_platdata(dev); + struct sun8i_eth_pdata *sun8i_pdata = dev_get_plat(dev); struct eth_pdata *pdata = &sun8i_pdata->eth_pdata; struct emac_eth_dev *priv = dev_get_priv(dev); const char *phy_mode; @@ -1001,10 +1001,10 @@ U_BOOT_DRIVER(eth_sun8i_emac) = { .name = "eth_sun8i_emac", .id = UCLASS_ETH, .of_match = sun8i_emac_eth_ids, - .ofdata_to_platdata = sun8i_emac_eth_ofdata_to_platdata, + .of_to_plat = sun8i_emac_eth_of_to_plat, .probe = sun8i_emac_eth_probe, .ops = &sun8i_emac_eth_ops, - .priv_auto_alloc_size = sizeof(struct emac_eth_dev), - .platdata_auto_alloc_size = sizeof(struct sun8i_eth_pdata), + .priv_auto = sizeof(struct emac_eth_dev), + .plat_auto = sizeof(struct sun8i_eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c index 8e66ce2461..17ad88e732 100644 --- a/drivers/net/sunxi_emac.c +++ b/drivers/net/sunxi_emac.c @@ -535,9 +535,9 @@ static int sunxi_emac_board_setup(struct udevice *dev, static int sunxi_emac_eth_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); - return _sunxi_emac_eth_init(dev->priv, pdata->enetaddr); + return _sunxi_emac_eth_init(dev_get_priv(dev), pdata->enetaddr); } static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length) @@ -565,7 +565,7 @@ static void sunxi_emac_eth_stop(struct udevice *dev) static int sunxi_emac_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct emac_eth_dev *priv = dev_get_priv(dev); int ret; @@ -591,9 +591,9 @@ static const struct eth_ops sunxi_emac_eth_ops = { .stop = sunxi_emac_eth_stop, }; -static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev) +static int sunxi_emac_eth_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); pdata->iobase = dev_read_addr(dev); @@ -609,9 +609,9 @@ U_BOOT_DRIVER(eth_sunxi_emac) = { .name = "eth_sunxi_emac", .id = UCLASS_ETH, .of_match = sunxi_emac_eth_ids, - .ofdata_to_platdata = sunxi_emac_eth_ofdata_to_platdata, + .of_to_plat = sunxi_emac_eth_of_to_plat, .probe = sunxi_emac_eth_probe, .ops = &sunxi_emac_eth_ops, - .priv_auto_alloc_size = sizeof(struct emac_eth_dev), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct emac_eth_dev), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c index 971bdcdfda..e6954b64b7 100644 --- a/drivers/net/ti/am65-cpsw-nuss.c +++ b/drivers/net/ti/am65-cpsw-nuss.c @@ -281,7 +281,7 @@ static void am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv *priv, static int am65_cpsw_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct am65_cpsw_priv *priv = dev_get_priv(dev); struct am65_cpsw_common *common = priv->cpsw_common; struct am65_cpsw_port *port = &common->ports[priv->port_id]; @@ -514,7 +514,7 @@ static int am65_cpsw_read_rom_hwaddr(struct udevice *dev) { struct am65_cpsw_priv *priv = dev_get_priv(dev); struct am65_cpsw_common *common = priv->cpsw_common; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); u32 mac_hi, mac_lo; if (common->mac_efuse == FDT_ADDR_T_NONE) @@ -563,7 +563,7 @@ static int am65_cpsw_phy_init(struct udevice *dev) { struct am65_cpsw_priv *priv = dev_get_priv(dev); struct am65_cpsw_common *cpsw_common = priv->cpsw_common; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct phy_device *phydev; u32 supported = PHY_GBIT_FEATURES; int ret; @@ -599,7 +599,7 @@ static int am65_cpsw_phy_init(struct udevice *dev) static int am65_cpsw_ofdata_parse_phy(struct udevice *dev, ofnode port_np) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct am65_cpsw_priv *priv = dev_get_priv(dev); struct ofnode_phandle_args out_args; const char *phy_mode; @@ -649,7 +649,7 @@ out: static int am65_cpsw_probe_cpsw(struct udevice *dev) { struct am65_cpsw_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct am65_cpsw_common *cpsw_common; ofnode ports_np, node; int ret, i; @@ -791,7 +791,7 @@ U_BOOT_DRIVER(am65_cpsw_nuss_slave) = { .of_match = am65_cpsw_nuss_ids, .probe = am65_cpsw_probe_cpsw, .ops = &am65_cpsw_ops, - .priv_auto_alloc_size = sizeof(struct am65_cpsw_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct am65_cpsw_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c index 1c11257839..68f4191fe9 100644 --- a/drivers/net/ti/cpsw.c +++ b/drivers/net/ti/cpsw.c @@ -456,7 +456,7 @@ static void cpsw_set_slave_mac(struct cpsw_slave *slave, struct cpsw_priv *priv) { #ifdef CONFIG_DM_ETH - struct eth_pdata *pdata = dev_get_platdata(priv->dev); + struct eth_pdata *pdata = dev_get_plat(priv->dev); writel(mac_hi(pdata->enetaddr), &slave->regs->sa_hi); writel(mac_lo(pdata->enetaddr), &slave->regs->sa_lo); @@ -1014,7 +1014,7 @@ int cpsw_register(struct cpsw_platform_data *data) #else static int cpsw_eth_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct cpsw_priv *priv = dev_get_priv(dev); return _cpsw_init(priv, pdata->enetaddr); @@ -1176,7 +1176,7 @@ static void cpsw_phy_sel(struct cpsw_priv *priv, const char *compat, static int cpsw_eth_probe(struct udevice *dev) { struct cpsw_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); priv->dev = dev; priv->data = pdata->priv_pdata; @@ -1223,9 +1223,9 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data, "max-speed", 0); } -static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) +static int cpsw_eth_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct cpsw_platform_data *data; struct gpio_desc *mode_gpios; int slave_index = 0; @@ -1377,12 +1377,12 @@ U_BOOT_DRIVER(eth_cpsw) = { .id = UCLASS_ETH, #if CONFIG_IS_ENABLED(OF_CONTROL) .of_match = cpsw_eth_ids, - .ofdata_to_platdata = cpsw_eth_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .of_to_plat = cpsw_eth_of_to_plat, + .plat_auto = sizeof(struct eth_pdata), #endif .probe = cpsw_eth_probe, .ops = &cpsw_eth_ops, - .priv_auto_alloc_size = sizeof(struct cpsw_priv), + .priv_auto = sizeof(struct cpsw_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_PRE_RELOC, }; #endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/ti/davinci_emac.c b/drivers/net/ti/davinci_emac.c index 56ea1fec0a..bfe1b84cd5 100644 --- a/drivers/net/ti/davinci_emac.c +++ b/drivers/net/ti/davinci_emac.c @@ -112,7 +112,7 @@ phy_t phy[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT]; static int davinci_emac_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); unsigned long mac_hi; unsigned long mac_lo; @@ -865,5 +865,5 @@ U_BOOT_DRIVER(davinci_emac) = { .of_match = davinci_emac_ids, .probe = davinci_emac_probe, .ops = &davinci_emac_ops, - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c index 50f0d33a83..35b796c913 100644 --- a/drivers/net/ti/keystone_net.c +++ b/drivers/net/ti/keystone_net.c @@ -496,7 +496,7 @@ static void ks2_eth_stop(struct udevice *dev) int ks2_eth_read_rom_hwaddr(struct udevice *dev) { struct ks2_eth_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); u32 maca = 0; u32 macb = 0; @@ -519,7 +519,7 @@ int ks2_eth_read_rom_hwaddr(struct udevice *dev) int ks2_eth_write_hwaddr(struct udevice *dev) { struct ks2_eth_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); writel(mac_hi(pdata->enetaddr), DEVICE_EMACSW_BASE(pdata->iobase, priv->slave_port - 1) + @@ -747,10 +747,10 @@ static int ks2_eth_parse_slave_interface(int netcp, int slave, return 0; } -static int ks2_sl_eth_ofdata_to_platdata(struct udevice *dev) +static int ks2_sl_eth_of_to_plat(struct udevice *dev) { struct ks2_eth_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const void *fdt = gd->fdt_blob; int slave = dev_of_offset(dev); int interfaces; @@ -770,10 +770,10 @@ static int ks2_sl_eth_ofdata_to_platdata(struct udevice *dev) return 0; } -static int ks2_eth_ofdata_to_platdata(struct udevice *dev) +static int ks2_eth_of_to_plat(struct udevice *dev) { struct ks2_eth_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); const void *fdt = gd->fdt_blob; int gbe_0 = -ENODEV; int netcp_devices; @@ -800,12 +800,12 @@ static const struct udevice_id ks2_eth_ids[] = { U_BOOT_DRIVER(eth_ks2_slave) = { .name = "eth_ks2_sl", .id = UCLASS_ETH, - .ofdata_to_platdata = ks2_sl_eth_ofdata_to_platdata, + .of_to_plat = ks2_sl_eth_of_to_plat, .probe = ks2_eth_probe, .remove = ks2_eth_remove, .ops = &ks2_eth_ops, - .priv_auto_alloc_size = sizeof(struct ks2_eth_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ks2_eth_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; @@ -813,11 +813,11 @@ U_BOOT_DRIVER(eth_ks2) = { .name = "eth_ks2", .id = UCLASS_ETH, .of_match = ks2_eth_ids, - .ofdata_to_platdata = ks2_eth_ofdata_to_platdata, + .of_to_plat = ks2_eth_of_to_plat, .probe = ks2_eth_probe, .remove = ks2_eth_remove, .ops = &ks2_eth_ops, - .priv_auto_alloc_size = sizeof(struct ks2_eth_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ks2_eth_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index c436b8317d..ec48689372 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -131,11 +131,17 @@ static int tsec_mcast_addr(struct eth_device *dev, const u8 *mcast_mac, static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join) #endif { - struct tsec_private *priv = (struct tsec_private *)dev->priv; - struct tsec __iomem *regs = priv->regs; + struct tsec_private *priv; + struct tsec __iomem *regs; u32 result, value; u8 whichbit, whichreg; +#ifndef CONFIG_DM_ETH + priv = (struct tsec_private *)dev->priv; +#else + priv = dev_get_priv(dev); +#endif + regs = priv->regs; result = ether_crc(MAC_ADDR_LEN, mcast_mac); whichbit = (result >> 24) & 0x1f; /* the 5 LSB = which bit to set */ whichreg = result >> 29; /* the 3 MSB = which reg to set it in */ @@ -260,12 +266,18 @@ static int tsec_send(struct eth_device *dev, void *packet, int length) static int tsec_send(struct udevice *dev, void *packet, int length) #endif { - struct tsec_private *priv = (struct tsec_private *)dev->priv; - struct tsec __iomem *regs = priv->regs; + struct tsec_private *priv; + struct tsec __iomem *regs; int result = 0; u16 status; int i; +#ifndef CONFIG_DM_ETH + priv = (struct tsec_private *)dev->priv; +#else + priv = dev_get_priv(dev); +#endif + regs = priv->regs; /* Find an empty buffer descriptor */ for (i = 0; in_be16(&priv->txbd[priv->tx_idx].status) & TXBD_READY; @@ -339,7 +351,7 @@ static int tsec_recv(struct eth_device *dev) #else static int tsec_recv(struct udevice *dev, int flags, uchar **packetp) { - struct tsec_private *priv = (struct tsec_private *)dev->priv; + struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev); struct tsec __iomem *regs = priv->regs; int ret = -1; @@ -368,7 +380,7 @@ static int tsec_recv(struct udevice *dev, int flags, uchar **packetp) static int tsec_free_pkt(struct udevice *dev, uchar *packet, int length) { - struct tsec_private *priv = (struct tsec_private *)dev->priv; + struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev); u16 status; out_be16(&priv->rxbd[priv->rx_idx].length, 0); @@ -392,8 +404,14 @@ static void tsec_halt(struct eth_device *dev) static void tsec_halt(struct udevice *dev) #endif { - struct tsec_private *priv = (struct tsec_private *)dev->priv; - struct tsec __iomem *regs = priv->regs; + struct tsec_private *priv; + struct tsec __iomem *regs; +#ifndef CONFIG_DM_ETH + priv = (struct tsec_private *)dev->priv; +#else + priv = dev_get_priv(dev); +#endif + regs = priv->regs; clrbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); setbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); @@ -560,16 +578,22 @@ static int tsec_init(struct eth_device *dev, struct bd_info *bd) static int tsec_init(struct udevice *dev) #endif { - struct tsec_private *priv = (struct tsec_private *)dev->priv; + struct tsec_private *priv; + struct tsec __iomem *regs; #ifdef CONFIG_DM_ETH - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); #else struct eth_device *pdata = dev; #endif - struct tsec __iomem *regs = priv->regs; u32 tempval; int ret; +#ifndef CONFIG_DM_ETH + priv = (struct tsec_private *)dev->priv; +#else + priv = dev_get_priv(dev); +#endif + regs = priv->regs; /* Make sure the controller is stopped */ tsec_halt(dev); @@ -683,7 +707,8 @@ static int init_phy(struct tsec_private *priv) tsec_configure_serdes(priv); #if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO) - if (ofnode_valid(ofnode_find_subnode(priv->dev->node, "fixed-link"))) + if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev), + "fixed-link"))) phydev = phy_connect(NULL, 0, priv->dev, priv->interface); else phydev = dm_eth_phy_connect(priv->dev); @@ -799,7 +824,7 @@ int tsec_standard_init(struct bd_info *bis) #else /* CONFIG_DM_ETH */ int tsec_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct tsec_private *priv = dev_get_priv(dev); struct ofnode_phandle_args phandle_args; u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE; @@ -865,7 +890,7 @@ int tsec_probe(struct udevice *dev) int tsec_remove(struct udevice *dev) { - struct tsec_private *priv = dev->priv; + struct tsec_private *priv = dev_get_priv(dev); free(priv->phydev); mdio_unregister(priv->bus); @@ -904,8 +929,8 @@ U_BOOT_DRIVER(eth_tsec) = { .probe = tsec_probe, .remove = tsec_remove, .ops = &tsec_ops, - .priv_auto_alloc_size = sizeof(struct tsec_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct tsec_private), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 8af3711204..343ab69d19 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -425,7 +425,7 @@ static int axi_ethernet_init(struct axidma_priv *priv) static int axiemac_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct axidma_priv *priv = dev_get_priv(dev); struct axi_regs *regs = priv->iobase; @@ -697,7 +697,7 @@ static int axi_emac_probe(struct udevice *dev) priv->bus->write = axiemac_miiphy_write; priv->bus->priv = priv; - ret = mdio_register_seq(priv->bus, dev->seq); + ret = mdio_register_seq(priv->bus, dev_seq(dev)); if (ret) return ret; @@ -726,9 +726,9 @@ static const struct eth_ops axi_emac_ops = { .write_hwaddr = axiemac_write_hwaddr, }; -static int axi_emac_ofdata_to_platdata(struct udevice *dev) +static int axi_emac_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct axidma_priv *priv = dev_get_priv(dev); int node = dev_of_offset(dev); int offset = 0; @@ -787,10 +787,10 @@ U_BOOT_DRIVER(axi_emac) = { .name = "axi_emac", .id = UCLASS_ETH, .of_match = axi_emac_ids, - .ofdata_to_platdata = axi_emac_ofdata_to_platdata, + .of_to_plat = axi_emac_of_to_plat, .probe = axi_emac_probe, .remove = axi_emac_remove, .ops = &axi_emac_ops, - .priv_auto_alloc_size = sizeof(struct axidma_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct axidma_priv), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 64c18bae74..6b447537f6 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -322,7 +322,7 @@ static int setup_phy(struct udevice *dev) static int emaclite_start(struct udevice *dev) { struct xemaclite *emaclite = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct emaclite_regs *regs = emaclite->regs; debug("EmacLite Initialization Started\n"); @@ -457,7 +457,7 @@ static int emaclite_recv(struct udevice *dev, int flags, uchar **packetp) { u32 length, first_read, reg, attempt = 0; void *addr, *ack; - struct xemaclite *emaclite = dev->priv; + struct xemaclite *emaclite = dev_get_priv(dev); struct emaclite_regs *regs = emaclite->regs; struct ethernet_hdr *eth; struct ip_udp_hdr *ip; @@ -568,7 +568,7 @@ static int emaclite_probe(struct udevice *dev) emaclite->bus->write = emaclite_miiphy_write; emaclite->bus->priv = emaclite; - ret = mdio_register_seq(emaclite->bus, dev->seq); + ret = mdio_register_seq(emaclite->bus, dev_seq(dev)); if (ret) return ret; @@ -593,9 +593,9 @@ static const struct eth_ops emaclite_ops = { .stop = emaclite_stop, }; -static int emaclite_ofdata_to_platdata(struct udevice *dev) +static int emaclite_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct xemaclite *emaclite = dev_get_priv(dev); int offset = 0; @@ -631,10 +631,10 @@ U_BOOT_DRIVER(emaclite) = { .name = "emaclite", .id = UCLASS_ETH, .of_match = emaclite_ids, - .ofdata_to_platdata = emaclite_ofdata_to_platdata, + .of_to_plat = emaclite_of_to_plat, .probe = emaclite_probe, .remove = emaclite_remove, .ops = &emaclite_ops, - .priv_auto_alloc_size = sizeof(struct xemaclite), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct xemaclite), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 8afec8bbfc..5cb02bb3a7 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -270,7 +270,7 @@ static int phywrite(struct zynq_gem_priv *priv, u32 phy_addr, static int zynq_gem_setup_mac(struct udevice *dev) { u32 i, macaddrlow, macaddrhigh; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct zynq_gem_priv *priv = dev_get_priv(dev); struct zynq_gem_regs *regs = priv->iobase; @@ -635,7 +635,7 @@ __weak int zynq_board_read_rom_ethaddr(unsigned char *ethaddr) static int zynq_gem_read_rom_mac(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); if (!pdata) return -ENOSYS; @@ -705,7 +705,7 @@ static int zynq_gem_probe(struct udevice *dev) priv->bus->write = zynq_gem_miiphy_write; priv->bus->priv = priv; - ret = mdio_register_seq(priv->bus, dev->seq); + ret = mdio_register_seq(priv->bus, dev_seq(dev)); if (ret) goto err2; @@ -743,9 +743,9 @@ static const struct eth_ops zynq_gem_ops = { .read_rom_hwaddr = zynq_gem_read_rom_mac, }; -static int zynq_gem_ofdata_to_platdata(struct udevice *dev) +static int zynq_gem_of_to_plat(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct zynq_gem_priv *priv = dev_get_priv(dev); struct ofnode_phandle_args phandle_args; const char *phy_mode; @@ -807,10 +807,10 @@ U_BOOT_DRIVER(zynq_gem) = { .name = "zynq_gem", .id = UCLASS_ETH, .of_match = zynq_gem_ids, - .ofdata_to_platdata = zynq_gem_ofdata_to_platdata, + .of_to_plat = zynq_gem_of_to_plat, .probe = zynq_gem_probe, .remove = zynq_gem_remove, .ops = &zynq_gem_ops, - .priv_auto_alloc_size = sizeof(struct zynq_gem_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct zynq_gem_priv), + .plat_auto = sizeof(struct eth_pdata), }; diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index fc64d93ab8..5d6331ad34 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -673,10 +673,10 @@ int nvme_scan_namespace(void) static int nvme_blk_probe(struct udevice *udev) { struct nvme_dev *ndev = dev_get_priv(udev->parent); - struct blk_desc *desc = dev_get_uclass_platdata(udev); + struct blk_desc *desc = dev_get_uclass_plat(udev); struct nvme_ns *ns = dev_get_priv(udev); u8 flbas; - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; struct nvme_id_ns *id; id = memalign(ndev->page_size, sizeof(struct nvme_id_ns)); @@ -704,7 +704,7 @@ static int nvme_blk_probe(struct udevice *udev) desc->log2blksz = ns->lba_shift; desc->blksz = 1 << ns->lba_shift; desc->bdev = udev; - pplat = dev_get_parent_platdata(udev->parent); + pplat = dev_get_parent_plat(udev->parent); sprintf(desc->vendor, "0x%.4x", pplat->vendor); memcpy(desc->product, ndev->serial, sizeof(ndev->serial)); memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev)); @@ -719,7 +719,7 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr, struct nvme_ns *ns = dev_get_priv(udev); struct nvme_dev *dev = ns->dev; struct nvme_command c; - struct blk_desc *desc = dev_get_uclass_platdata(udev); + struct blk_desc *desc = dev_get_uclass_plat(udev); int status; u64 prp2; u64 total_len = blkcnt << desc->log2blksz; @@ -795,7 +795,7 @@ U_BOOT_DRIVER(nvme_blk) = { .id = UCLASS_BLK, .probe = nvme_blk_probe, .ops = &nvme_blk_ops, - .priv_auto_alloc_size = sizeof(struct nvme_ns), + .priv_auto = sizeof(struct nvme_ns), }; static int nvme_bind(struct udevice *udev) @@ -869,7 +869,7 @@ U_BOOT_DRIVER(nvme) = { .id = UCLASS_NVME, .bind = nvme_bind, .probe = nvme_probe, - .priv_auto_alloc_size = sizeof(struct nvme_dev), + .priv_auto = sizeof(struct nvme_dev), }; struct pci_device_id nvme_supported[] = { diff --git a/drivers/pch/sandbox_pch.c b/drivers/pch/sandbox_pch.c index 76f552527e..37c368954b 100644 --- a/drivers/pch/sandbox_pch.c +++ b/drivers/pch/sandbox_pch.c @@ -82,5 +82,5 @@ U_BOOT_DRIVER(sandbox_pch_drv) = { .id = UCLASS_PCH, .of_match = sandbox_pch_ids, .ops = &sandbox_pch_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_pch_priv), + .priv_auto = sizeof(struct sandbox_pch_priv), }; diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c index 5c6e30e667..1534efb88e 100644 --- a/drivers/pci/pci-aardvark.c +++ b/drivers/pci/pci-aardvark.c @@ -638,7 +638,7 @@ static int pcie_advk_probe(struct udevice *dev) dev_warn(pcie->dev, "PCIE Reset on GPIO support is missing\n"); } - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); pcie->dev = pci_get_controller(dev); return pcie_advk_setup_hw(pcie); @@ -657,7 +657,7 @@ static int pcie_advk_remove(struct udevice *dev) } /** - * pcie_advk_ofdata_to_platdata() - Translate from DT to device state + * pcie_advk_of_to_plat() - Translate from DT to device state * * @dev: A pointer to the device being operated on * @@ -667,7 +667,7 @@ static int pcie_advk_remove(struct udevice *dev) * * Return: 0 on success, else -EINVAL */ -static int pcie_advk_ofdata_to_platdata(struct udevice *dev) +static int pcie_advk_of_to_plat(struct udevice *dev) { struct pcie_advk *pcie = dev_get_priv(dev); @@ -694,9 +694,9 @@ U_BOOT_DRIVER(pcie_advk) = { .id = UCLASS_PCI, .of_match = pcie_advk_ids, .ops = &pcie_advk_ops, - .ofdata_to_platdata = pcie_advk_ofdata_to_platdata, + .of_to_plat = pcie_advk_of_to_plat, .probe = pcie_advk_probe, .remove = pcie_advk_remove, .flags = DM_FLAG_OS_PREPARE, - .priv_auto_alloc_size = sizeof(struct pcie_advk), + .priv_auto = sizeof(struct pcie_advk), }; diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c index a52064341e..a0b8afb87a 100644 --- a/drivers/pci/pci-emul-uclass.c +++ b/drivers/pci/pci-emul-uclass.c @@ -82,7 +82,7 @@ uint sandbox_pci_read_bar(u32 barval, int type, uint size) static int sandbox_pci_emul_post_probe(struct udevice *dev) { - struct sandbox_pci_emul_priv *priv = dev->uclass->priv; + struct sandbox_pci_emul_priv *priv = uclass_get_priv(dev->uclass); priv->dev_count++; sandbox_set_enable_pci_map(true); @@ -92,7 +92,7 @@ static int sandbox_pci_emul_post_probe(struct udevice *dev) static int sandbox_pci_emul_pre_remove(struct udevice *dev) { - struct sandbox_pci_emul_priv *priv = dev->uclass->priv; + struct sandbox_pci_emul_priv *priv = uclass_get_priv(dev->uclass); priv->dev_count--; sandbox_set_enable_pci_map(priv->dev_count > 0); @@ -105,14 +105,14 @@ UCLASS_DRIVER(pci_emul) = { .name = "pci_emul", .post_probe = sandbox_pci_emul_post_probe, .pre_remove = sandbox_pci_emul_pre_remove, - .priv_auto_alloc_size = sizeof(struct sandbox_pci_emul_priv), - .per_device_auto_alloc_size = sizeof(struct pci_emul_uc_priv), + .priv_auto = sizeof(struct sandbox_pci_emul_priv), + .per_device_auto = sizeof(struct pci_emul_uc_priv), }; /* - * This uclass is a child of the pci bus. Its platdata is not defined here so - * is defined by its parent, UCLASS_PCI, which uses struct pci_child_platdata. - * See per_child_platdata_auto_alloc_size in UCLASS_DRIVER(pci). + * This uclass is a child of the pci bus. Its plat is not defined here so + * is defined by its parent, UCLASS_PCI, which uses struct pci_child_plat. + * See per_child_plat_auto in UCLASS_DRIVER(pci). */ UCLASS_DRIVER(pci_emul_parent) = { .id = UCLASS_PCI_EMUL_PARENT, diff --git a/drivers/pci/pci-rcar-gen2.c b/drivers/pci/pci-rcar-gen2.c index e76abc1f84..dc11402781 100644 --- a/drivers/pci/pci-rcar-gen2.c +++ b/drivers/pci/pci-rcar-gen2.c @@ -231,7 +231,7 @@ static int rcar_gen2_pci_probe(struct udevice *dev) return 0; } -static int rcar_gen2_pci_ofdata_to_platdata(struct udevice *dev) +static int rcar_gen2_pci_of_to_plat(struct udevice *dev) { struct rcar_gen2_pci_priv *priv = dev_get_priv(dev); @@ -259,6 +259,6 @@ U_BOOT_DRIVER(rcar_gen2_pci) = { .of_match = rcar_gen2_pci_ids, .ops = &rcar_gen2_pci_ops, .probe = rcar_gen2_pci_probe, - .ofdata_to_platdata = rcar_gen2_pci_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct rcar_gen2_pci_priv), + .of_to_plat = rcar_gen2_pci_of_to_plat, + .priv_auto = sizeof(struct rcar_gen2_pci_priv), }; diff --git a/drivers/pci/pci-rcar-gen3.c b/drivers/pci/pci-rcar-gen3.c index 1f51854ccc..0d5b01f9f8 100644 --- a/drivers/pci/pci-rcar-gen3.c +++ b/drivers/pci/pci-rcar-gen3.c @@ -129,7 +129,7 @@ struct rcar_gen3_pcie_priv { static void rcar_rmw32(struct udevice *dev, int where, u32 mask, u32 data) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); int shift = 8 * (where & 3); clrsetbits_le32(priv->regs + (where & ~3), @@ -138,7 +138,7 @@ static void rcar_rmw32(struct udevice *dev, int where, u32 mask, u32 data) static u32 rcar_read_conf(const struct udevice *dev, int where) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); int shift = 8 * (where & 3); return readl(priv->regs + (where & ~3)) >> shift; @@ -148,7 +148,7 @@ static int rcar_pcie_config_access(const struct udevice *udev, unsigned char access_type, pci_dev_t bdf, int where, ulong *data) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(udev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(udev); u32 reg = where & ~3; /* Clear errors */ @@ -241,7 +241,7 @@ static int rcar_gen3_pcie_write_config(struct udevice *dev, pci_dev_t bdf, static int rcar_gen3_pcie_wait_for_phyrdy(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); return wait_for_bit_le32((void *)priv->regs + PCIEPHYSR, PHYRDY, true, 50, false); @@ -249,7 +249,7 @@ static int rcar_gen3_pcie_wait_for_phyrdy(struct udevice *dev) static int rcar_gen3_pcie_wait_for_dl(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); return wait_for_bit_le32((void *)priv->regs + PCIETSTR, DATA_LINK_ACTIVE, true, 50, false); @@ -257,7 +257,7 @@ static int rcar_gen3_pcie_wait_for_dl(struct udevice *dev) static int rcar_gen3_pcie_hw_init(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); int ret; /* Begin initialization */ @@ -313,7 +313,7 @@ static int rcar_gen3_pcie_hw_init(struct udevice *dev) static int rcar_gen3_pcie_probe(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); struct pci_controller *hose = dev_get_uclass_priv(dev); struct clk pci_clk; u32 mask; @@ -372,9 +372,9 @@ static int rcar_gen3_pcie_probe(struct udevice *dev) return 0; } -static int rcar_gen3_pcie_ofdata_to_platdata(struct udevice *dev) +static int rcar_gen3_pcie_of_to_plat(struct udevice *dev) { - struct rcar_gen3_pcie_priv *priv = dev_get_platdata(dev); + struct rcar_gen3_pcie_priv *priv = dev_get_plat(dev); priv->regs = devfdt_get_addr_index(dev, 0); if (!priv->regs) @@ -399,6 +399,6 @@ U_BOOT_DRIVER(rcar_gen3_pcie) = { .of_match = rcar_gen3_pcie_ids, .ops = &rcar_gen3_pcie_ops, .probe = rcar_gen3_pcie_probe, - .ofdata_to_platdata = rcar_gen3_pcie_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct rcar_gen3_pcie_priv), + .of_to_plat = rcar_gen3_pcie_of_to_plat, + .plat_auto = sizeof(struct rcar_gen3_pcie_priv), }; diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index eb07d25301..4cdd06b125 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -14,6 +14,7 @@ #include <asm/io.h> #include <dm/device-internal.h> #include <dm/lists.h> +#include <dm/uclass-internal.h> #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP) #include <asm/fsp/fsp_support.h> #endif @@ -49,7 +50,7 @@ struct udevice *pci_get_controller(struct udevice *dev) pci_dev_t dm_pci_get_bdf(const struct udevice *dev) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); struct udevice *bus = dev->parent; /* @@ -58,14 +59,14 @@ pci_dev_t dm_pci_get_bdf(const struct udevice *dev) * will produce a bad BDF> * * A common cause of this problem is that this function is called in the - * ofdata_to_platdata() method of @dev. Accessing the PCI bus in that + * of_to_plat() method of @dev. Accessing the PCI bus in that * method is not allowed, since it has not yet been probed. To fix this, * move that access to the probe() method of @dev instead. */ if (!device_active(bus)) log_err("PCI: Device '%s' on unprobed bus '%s'\n", dev->name, bus->name); - return PCI_ADD_BUS(bus->seq, pplat->devfn); + return PCI_ADD_BUS(dev_seq(bus), pplat->devfn); } /** @@ -81,8 +82,8 @@ static int pci_get_bus_max(void) ret = uclass_get(UCLASS_PCI, &uc); uclass_foreach_dev(bus, uc) { - if (bus->seq > ret) - ret = bus->seq; + if (dev_seq(bus) > ret) + ret = dev_seq(bus); } debug("%s: ret=%d\n", __func__, ret); @@ -136,9 +137,9 @@ int pci_bus_find_devfn(const struct udevice *bus, pci_dev_t find_devfn, for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (pplat && pplat->devfn == find_devfn) { *devp = dev; return 0; @@ -162,10 +163,10 @@ int dm_pci_bus_find_bdf(pci_dev_t bdf, struct udevice **devp) static int pci_device_matches_ids(struct udevice *dev, struct pci_device_id *ids) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; int i; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (!pplat) return -EINVAL; for (i = 0; ids[i].vendor != 0; i++) { @@ -218,13 +219,13 @@ static int dm_pci_bus_find_device(struct udevice *bus, unsigned int vendor, unsigned int device, int *indexp, struct udevice **devp) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; struct udevice *dev; for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (pplat->vendor == vendor && pplat->device == device) { if (!(*indexp)--) { *devp = dev; @@ -261,7 +262,7 @@ int dm_pci_find_class(uint find_class, int index, struct udevice **devp) for (pci_find_first_device(&dev); dev; pci_find_next_device(&dev)) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); if (pplat->class == find_class && !index--) { *devp = dev; @@ -513,7 +514,7 @@ static void set_vga_bridge_bits(struct udevice *dev) struct udevice *parent = dev->parent; u16 bc; - while (parent->seq != 0) { + while (dev_seq(parent) != 0) { dm_pci_read_config16(parent, PCI_BRIDGE_CONTROL, &bc); bc |= PCI_BRIDGE_CTL_VGA; dm_pci_write_config16(parent, PCI_BRIDGE_CONTROL, bc); @@ -523,13 +524,13 @@ static void set_vga_bridge_bits(struct udevice *dev) int pci_auto_config_devices(struct udevice *bus) { - struct pci_controller *hose = bus->uclass_priv; - struct pci_child_platdata *pplat; + struct pci_controller *hose = dev_get_uclass_priv(bus); + struct pci_child_plat *pplat; unsigned int sub_bus; struct udevice *dev; int ret; - sub_bus = bus->seq; + sub_bus = dev_seq(bus); debug("%s: start\n", __func__); pciauto_config_init(hose); for (ret = device_find_first_child(bus, &dev); @@ -539,22 +540,22 @@ int pci_auto_config_devices(struct udevice *bus) int ret; debug("%s: device %s\n", __func__, dev->name); - if (dev_of_valid(dev) && + if (dev_has_ofnode(dev) && dev_read_bool(dev, "pci,no-autoconfig")) continue; ret = dm_pciauto_config_device(dev); if (ret < 0) - return ret; + return log_msg_ret("auto", ret); max_bus = ret; sub_bus = max(sub_bus, max_bus); - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); if (pplat->class == (PCI_CLASS_DISPLAY_VGA << 8)) set_vga_bridge_bits(dev); } debug("%s: done\n", __func__); - return sub_bus; + return log_msg_ret("sub", sub_bus); } int pci_generic_mmap_write_config( @@ -641,17 +642,9 @@ int dm_pci_hose_probe_bus(struct udevice *bus) if (ret) { debug("%s: Cannot probe bus %s: %d\n", __func__, bus->name, ret); - return ret; + return log_msg_ret("probe", ret); } - if (!ea_pos) { - if (sub_bus != bus->seq) { - debug("%s: Internal error, bus '%s' got seq %d, expected %d\n", - __func__, bus->name, bus->seq, sub_bus); - return -EPIPE; - } - sub_bus = pci_get_bus_max(); - } dm_pciauto_postscan_setup_bridge(bus, sub_bus); return sub_bus; @@ -714,7 +707,7 @@ static int pci_find_and_bind_driver(struct udevice *parent, if (ofnode_valid(node) && !ofnode_is_available(node)) { debug("%s: Ignoring disabled device\n", __func__); - return -EPERM; + return log_msg_ret("dis", -EPERM); } start = ll_entry_start(struct pci_driver_entry, pci_driver_entry); @@ -740,18 +733,18 @@ static int pci_find_and_bind_driver(struct udevice *parent, */ if (!(gd->flags & GD_FLG_RELOC) && !(drv->flags & DM_FLAG_PRE_RELOC)) - return -EPERM; + return log_msg_ret("pre", -EPERM); /* * We could pass the descriptor to the driver as - * platdata (instead of NULL) and allow its bind() + * plat (instead of NULL) and allow its bind() * method to return -ENOENT if it doesn't support this * device. That way we could continue the search to * find another driver. For now this doesn't seem * necesssary, so just bind the first match. */ - ret = device_bind_ofnode(parent, drv, drv->name, NULL, - node, &dev); + ret = device_bind(parent, drv, drv->name, NULL, node, + &dev); if (ret) goto error; debug("%s: Match found: %s\n", __func__, drv->name); @@ -768,10 +761,10 @@ static int pci_find_and_bind_driver(struct udevice *parent, * limited (ie: using Cache As RAM). */ if (!(gd->flags & GD_FLG_RELOC) && !bridge) - return -EPERM; + return log_msg_ret("notbr", -EPERM); /* Bind a generic driver so that the device can be used */ - sprintf(name, "pci_%x:%x.%x", parent->seq, PCI_DEV(bdf), + sprintf(name, "pci_%x:%x.%x", dev_seq(parent), PCI_DEV(bdf), PCI_FUNC(bdf)); str = strdup(name); if (!str) @@ -803,11 +796,11 @@ int pci_bind_bus_devices(struct udevice *bus) int ret; found_multi = false; - end = PCI_BDF(bus->seq, PCI_MAX_PCI_DEVICES - 1, + end = PCI_BDF(dev_seq(bus), PCI_MAX_PCI_DEVICES - 1, PCI_MAX_PCI_FUNCTIONS - 1); - for (bdf = PCI_BDF(bus->seq, 0, 0); bdf <= end; + for (bdf = PCI_BDF(dev_seq(bus), 0, 0); bdf <= end; bdf += PCI_BDF(0, 0, 1)) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; struct udevice *dev; ulong class; @@ -832,7 +825,7 @@ int pci_bind_bus_devices(struct udevice *bus) found_multi = header_type & 0x80; debug("%s: bus %d/%s: found device %x, function %d", __func__, - bus->seq, bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); + dev_seq(bus), bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); pci_bus_read_config(bus, bdf, PCI_DEVICE_ID, &device, PCI_SIZE_16); pci_bus_read_config(bus, bdf, PCI_CLASS_REVISION, &class, @@ -868,7 +861,7 @@ int pci_bind_bus_devices(struct udevice *bus) return ret; /* Update the platform data */ - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); pplat->devfn = PCI_MASK_BUS(bdf); pplat->vendor = vendor; pplat->device = device; @@ -1009,10 +1002,25 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, static int pci_uclass_pre_probe(struct udevice *bus) { struct pci_controller *hose; + struct uclass *uc; + int ret; - debug("%s, bus=%d/%s, parent=%s\n", __func__, bus->seq, bus->name, + debug("%s, bus=%d/%s, parent=%s\n", __func__, dev_seq(bus), bus->name, bus->parent->name); - hose = bus->uclass_priv; + hose = dev_get_uclass_priv(bus); + + /* + * Set the sequence number, if device_bind() doesn't. We want control + * of this so that numbers are allocated as devices are probed. That + * ensures that sub-bus numbered is correct (sub-buses must get numbers + * higher than their parents) + */ + if (dev_seq(bus) == -1) { + ret = uclass_get(UCLASS_PCI, &uc); + if (ret) + return ret; + bus->seq_ = uclass_find_next_free_seq(uc); + } /* For bridges, use the top-level PCI controller */ if (!device_is_on_pci_bus(bus)) { @@ -1024,10 +1032,11 @@ static int pci_uclass_pre_probe(struct udevice *bus) parent_hose = dev_get_uclass_priv(bus->parent); hose->ctlr = parent_hose->bus; } + hose->bus = bus; - hose->first_busno = bus->seq; - hose->last_busno = bus->seq; - if (dev_of_valid(bus)) { + hose->first_busno = dev_seq(bus); + hose->last_busno = dev_seq(bus); + if (dev_has_ofnode(bus)) { hose->skip_auto_config_until_reloc = dev_read_bool(bus, "u-boot,skip-auto-config-until-reloc"); @@ -1041,17 +1050,17 @@ static int pci_uclass_post_probe(struct udevice *bus) struct pci_controller *hose = dev_get_uclass_priv(bus); int ret; - debug("%s: probing bus %d\n", __func__, bus->seq); + debug("%s: probing bus %d\n", __func__, dev_seq(bus)); ret = pci_bind_bus_devices(bus); if (ret) - return ret; + return log_msg_ret("bind", ret); if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() && (!hose->skip_auto_config_until_reloc || (gd->flags & GD_FLG_RELOC))) { ret = pci_auto_config_devices(bus); if (ret < 0) - return log_msg_ret("pci auto-config", ret); + return log_msg_ret("cfg", ret); } #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP) @@ -1068,10 +1077,10 @@ static int pci_uclass_post_probe(struct udevice *bus) * Note we only call this 1) after U-Boot is relocated, and 2) * root bus has finished probing. */ - if ((gd->flags & GD_FLG_RELOC) && bus->seq == 0 && ll_boot_init()) { + if ((gd->flags & GD_FLG_RELOC) && dev_seq(bus) == 0 && ll_boot_init()) { ret = fsp_init_phase_pci(); if (ret) - return ret; + return log_msg_ret("fsp", ret); } #endif @@ -1080,12 +1089,12 @@ static int pci_uclass_post_probe(struct udevice *bus) static int pci_uclass_child_post_bind(struct udevice *dev) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); /* Extract vendor id and device id if available */ ofnode_read_pci_vendev(dev_ofnode(dev), &pplat->vendor, &pplat->device); @@ -1100,7 +1109,7 @@ static int pci_bridge_read_config(const struct udevice *bus, pci_dev_t bdf, uint offset, ulong *valuep, enum pci_size_t size) { - struct pci_controller *hose = bus->uclass_priv; + struct pci_controller *hose = dev_get_uclass_priv(bus); return pci_bus_read_config(hose->ctlr, bdf, offset, valuep, size); } @@ -1109,7 +1118,7 @@ static int pci_bridge_write_config(struct udevice *bus, pci_dev_t bdf, uint offset, ulong value, enum pci_size_t size) { - struct pci_controller *hose = bus->uclass_priv; + struct pci_controller *hose = dev_get_uclass_priv(bus); return pci_bus_write_config(hose->ctlr, bdf, offset, value, size); } @@ -1441,7 +1450,7 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t phys_addr, } static phys_addr_t dm_pci_map_ea_virt(struct udevice *dev, int ea_off, - struct pci_child_platdata *pdata) + struct pci_child_plat *pdata) { phys_addr_t addr = 0; @@ -1472,7 +1481,7 @@ static phys_addr_t dm_pci_map_ea_virt(struct udevice *dev, int ea_off, } static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags, - int ea_off, struct pci_child_platdata *pdata) + int ea_off, struct pci_child_plat *pdata) { int ea_cnt, i, entry_size; int bar_id = (bar - PCI_BASE_ADDRESS_0) >> 2; @@ -1523,7 +1532,7 @@ static void *dm_pci_map_ea_bar(struct udevice *dev, int bar, int flags, void *dm_pci_map_bar(struct udevice *dev, int bar, int flags) { - struct pci_child_platdata *pdata = dev_get_parent_platdata(dev); + struct pci_child_plat *pdata = dev_get_parent_plat(dev); struct udevice *udev = dev; pci_addr_t pci_bus_addr; u32 bar_response; @@ -1725,14 +1734,14 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) bdf += PCI_BDF(0, 0, vf_offset); for (vf = 0; vf < num_vfs; vf++) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; ulong class; pci_bus_read_config(bus, bdf, PCI_CLASS_DEVICE, &class, PCI_SIZE_16); debug("%s: bus %d/%s: found VF %x:%x\n", __func__, - bus->seq, bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); + dev_seq(bus), bus->name, PCI_DEV(bdf), PCI_FUNC(bdf)); /* Find this device in the device tree */ ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev); @@ -1753,7 +1762,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) } /* Update the platform data */ - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); pplat->devfn = PCI_MASK_BUS(bdf); pplat->vendor = vendor; pplat->device = device; @@ -1763,7 +1772,7 @@ int pci_sriov_init(struct udevice *pdev, int vf_en) pplat->virtid = vf * vf_stride + vf_offset; debug("%s: bus %d/%s: found VF %x:%x %x:%x class %lx id %x\n", - __func__, dev->seq, dev->name, PCI_DEV(bdf), + __func__, dev_seq(dev), dev->name, PCI_DEV(bdf), PCI_FUNC(bdf), vendor, device, class, pplat->virtid); bdf += PCI_BDF(0, 0, vf_stride); } @@ -1791,14 +1800,13 @@ int pci_sriov_get_totalvfs(struct udevice *pdev) UCLASS_DRIVER(pci) = { .id = UCLASS_PCI, .name = "pci", - .flags = DM_UC_FLAG_SEQ_ALIAS, + .flags = DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ, .post_bind = dm_scan_fdt_dev, .pre_probe = pci_uclass_pre_probe, .post_probe = pci_uclass_post_probe, .child_post_bind = pci_uclass_child_post_bind, - .per_device_auto_alloc_size = sizeof(struct pci_controller), - .per_child_platdata_auto_alloc_size = - sizeof(struct pci_child_platdata), + .per_device_auto = sizeof(struct pci_controller), + .per_child_plat_auto = sizeof(struct pci_child_plat), }; static const struct dm_pci_ops pci_bridge_ops = { diff --git a/drivers/pci/pci_auto.c b/drivers/pci/pci_auto.c index 3f46b7697d..68ef4e8092 100644 --- a/drivers/pci/pci_auto.c +++ b/drivers/pci/pci_auto.c @@ -189,8 +189,8 @@ void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus) /* Configure bus number registers */ dm_pci_write_config8(dev, PCI_PRIMARY_BUS, - PCI_BUS(dm_pci_get_bdf(dev)) - ctlr->seq); - dm_pci_write_config8(dev, PCI_SECONDARY_BUS, sub_bus - ctlr->seq); + PCI_BUS(dm_pci_get_bdf(dev)) - dev_seq(ctlr)); + dm_pci_write_config8(dev, PCI_SECONDARY_BUS, sub_bus - dev_seq(ctlr)); dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, 0xff); if (pci_mem) { @@ -265,7 +265,7 @@ void dm_pciauto_postscan_setup_bridge(struct udevice *dev, int sub_bus) pci_io = ctlr_hose->pci_io; /* Configure bus number registers */ - dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, sub_bus - ctlr->seq); + dm_pci_write_config8(dev, PCI_SUBORDINATE_BUS, sub_bus - dev_seq(ctlr)); if (pci_mem) { /* Round memory allocator to 1MB boundary */ @@ -321,7 +321,7 @@ int dm_pciauto_config_device(struct udevice *dev) bool enum_only = false; struct udevice *ctlr = pci_get_controller(dev); struct pci_controller *ctlr_hose = dev_get_uclass_priv(ctlr); - int n; + int ret; #ifdef CONFIG_PCI_ENUM_ONLY enum_only = true; @@ -341,10 +341,10 @@ int dm_pciauto_config_device(struct udevice *dev) dm_pciauto_setup_device(dev, 2, pci_mem, pci_prefetch, pci_io, enum_only); - n = dm_pci_hose_probe_bus(dev); - if (n < 0) - return n; - sub_bus = (unsigned int)n; + ret = dm_pci_hose_probe_bus(dev); + if (ret < 0) + return log_msg_ret("probe", ret); + sub_bus = ret; break; case PCI_CLASS_BRIDGE_CARDBUS: diff --git a/drivers/pci/pci_mpc85xx.c b/drivers/pci/pci_mpc85xx.c index 6576f53f52..ab6ff45a51 100644 --- a/drivers/pci/pci_mpc85xx.c +++ b/drivers/pci/pci_mpc85xx.c @@ -122,7 +122,7 @@ static int mpc85xx_pci_dm_remove(struct udevice *dev) return 0; } -static int mpc85xx_pci_ofdata_to_platdata(struct udevice *dev) +static int mpc85xx_pci_of_to_plat(struct udevice *dev) { struct mpc85xx_pci_priv *priv = dev_get_priv(dev); fdt_addr_t addr; @@ -154,6 +154,6 @@ U_BOOT_DRIVER(mpc85xx_pci) = { .ops = &mpc85xx_pci_ops, .probe = mpc85xx_pci_dm_probe, .remove = mpc85xx_pci_dm_remove, - .ofdata_to_platdata = mpc85xx_pci_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct mpc85xx_pci_priv), + .of_to_plat = mpc85xx_pci_of_to_plat, + .priv_auto = sizeof(struct mpc85xx_pci_priv), }; diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c index c9afe75150..cf6e0a2e7c 100644 --- a/drivers/pci/pci_mvebu.c +++ b/drivers/pci/pci_mvebu.c @@ -143,7 +143,7 @@ static int mvebu_pcie_read_config(const struct udevice *bus, pci_dev_t bdf, uint offset, ulong *valuep, enum pci_size_t size) { - struct mvebu_pcie *pcie = dev_get_platdata(bus); + struct mvebu_pcie *pcie = dev_get_plat(bus); int local_bus = PCI_BUS(pcie->dev); int local_dev = PCI_DEV(pcie->dev); u32 reg; @@ -187,7 +187,7 @@ static int mvebu_pcie_write_config(struct udevice *bus, pci_dev_t bdf, uint offset, ulong value, enum pci_size_t size) { - struct mvebu_pcie *pcie = dev_get_platdata(bus); + struct mvebu_pcie *pcie = dev_get_plat(bus); int local_bus = PCI_BUS(pcie->dev); int local_dev = PCI_DEV(pcie->dev); u32 data; @@ -277,7 +277,7 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie *pcie) static int mvebu_pcie_probe(struct udevice *dev) { - struct mvebu_pcie *pcie = dev_get_platdata(dev); + struct mvebu_pcie *pcie = dev_get_plat(dev); struct udevice *ctlr = pci_get_controller(dev); struct pci_controller *hose = dev_get_uclass_priv(ctlr); static int bus; @@ -410,9 +410,9 @@ static int mvebu_get_tgt_attr(ofnode node, int devfn, return -ENOENT; } -static int mvebu_pcie_ofdata_to_platdata(struct udevice *dev) +static int mvebu_pcie_of_to_plat(struct udevice *dev) { - struct mvebu_pcie *pcie = dev_get_platdata(dev); + struct mvebu_pcie *pcie = dev_get_plat(dev); int ret = 0; /* Get port number, lane number and memory target / attr */ @@ -470,8 +470,8 @@ static struct driver pcie_mvebu_drv = { .id = UCLASS_PCI, .ops = &mvebu_pcie_ops, .probe = mvebu_pcie_probe, - .ofdata_to_platdata = mvebu_pcie_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mvebu_pcie), + .of_to_plat = mvebu_pcie_of_to_plat, + .plat_auto = sizeof(struct mvebu_pcie), }; /* @@ -501,8 +501,8 @@ static int mvebu_pcie_bind(struct udevice *parent) return -ENOMEM; /* Create child device UCLASS_PCI and bind it */ - device_bind_ofnode(parent, &pcie_mvebu_drv, pcie->name, pcie, - subnode, &dev); + device_bind(parent, &pcie_mvebu_drv, pcie->name, pcie, subnode, + &dev); } return 0; diff --git a/drivers/pci/pci_octeontx.c b/drivers/pci/pci_octeontx.c index 30537543a0..16932839a5 100644 --- a/drivers/pci/pci_octeontx.c +++ b/drivers/pci/pci_octeontx.c @@ -311,7 +311,7 @@ int pci_octeontx_write_config(struct udevice *bus, pci_dev_t bdf, return ret; } -static int pci_octeontx_ofdata_to_platdata(struct udevice *dev) +static int pci_octeontx_of_to_plat(struct udevice *dev) { return 0; } @@ -357,8 +357,8 @@ U_BOOT_DRIVER(pci_octeontx) = { .id = UCLASS_PCI, .of_match = pci_octeontx_ids, .ops = &pci_octeontx_ops, - .ofdata_to_platdata = pci_octeontx_ofdata_to_platdata, + .of_to_plat = pci_octeontx_of_to_plat, .probe = pci_octeontx_probe, - .priv_auto_alloc_size = sizeof(struct octeontx_pci), + .priv_auto = sizeof(struct octeontx_pci), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c index fa29d69e85..4a21813a82 100644 --- a/drivers/pci/pci_rom.c +++ b/drivers/pci/pci_rom.c @@ -68,7 +68,7 @@ __weak uint32_t board_map_oprom_vendev(uint32_t vendev) static int pci_rom_probe(struct udevice *dev, struct pci_rom_header **hdrp) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); struct pci_rom_header *rom_header; struct pci_rom_data *rom_data; u16 rom_vendor, rom_device; @@ -236,7 +236,7 @@ void setup_video(struct screen_info *screen_info) int dm_pci_run_vga_bios(struct udevice *dev, int (*int15_handler)(void), int exec_method) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); struct pci_rom_header *rom = NULL, *ram = NULL; int vesa_mode = -1; bool emulate, alloced; @@ -328,7 +328,7 @@ err: #ifdef CONFIG_DM_VIDEO int vbe_setup_video_priv(struct vesa_mode_info *vesa, struct video_priv *uc_priv, - struct video_uc_platdata *plat) + struct video_uc_plat *plat) { if (!vesa->x_resolution) return log_msg_ret("No x resolution", -ENXIO); @@ -363,7 +363,7 @@ int vbe_setup_video_priv(struct vesa_mode_info *vesa, int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); int ret; diff --git a/drivers/pci/pci_sandbox.c b/drivers/pci/pci_sandbox.c index 8745f286bd..ca44d00237 100644 --- a/drivers/pci/pci_sandbox.c +++ b/drivers/pci/pci_sandbox.c @@ -128,10 +128,9 @@ U_BOOT_DRIVER(pci_sandbox) = { .of_match = sandbox_pci_ids, .ops = &sandbox_pci_ops, .probe = sandbox_pci_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_pci_priv), + .priv_auto = sizeof(struct sandbox_pci_priv), /* Attach an emulator if we can */ .child_post_bind = dm_scan_fdt_dev, - .per_child_platdata_auto_alloc_size = - sizeof(struct pci_child_platdata), + .per_child_plat_auto = sizeof(struct pci_child_plat), }; diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c index 82f5c59d91..9cb4414836 100644 --- a/drivers/pci/pci_tegra.c +++ b/drivers/pci/pci_tegra.c @@ -1092,7 +1092,7 @@ static const struct tegra_pcie_soc pci_tegra_soc[] = { }, }; -static int pci_tegra_ofdata_to_platdata(struct udevice *dev) +static int pci_tegra_of_to_plat(struct udevice *dev) { struct tegra_pcie *pcie = dev_get_priv(dev); enum tegra_pci_id id; @@ -1197,7 +1197,7 @@ U_BOOT_DRIVER(pci_tegra) = { .id = UCLASS_PCI, .of_match = pci_tegra_ids, .ops = &pci_tegra_ops, - .ofdata_to_platdata = pci_tegra_ofdata_to_platdata, + .of_to_plat = pci_tegra_of_to_plat, .probe = pci_tegra_probe, - .priv_auto_alloc_size = sizeof(struct tegra_pcie), + .priv_auto = sizeof(struct tegra_pcie), }; diff --git a/drivers/pci/pcie_brcmstb.c b/drivers/pci/pcie_brcmstb.c index dade79e9c8..dd2a4ef629 100644 --- a/drivers/pci/pcie_brcmstb.c +++ b/drivers/pci/pcie_brcmstb.c @@ -579,7 +579,7 @@ static int brcm_pcie_probe(struct udevice *dev) return 0; } -static int brcm_pcie_ofdata_to_platdata(struct udevice *dev) +static int brcm_pcie_of_to_plat(struct udevice *dev) { struct brcm_pcie *pcie = dev_get_priv(dev); ofnode dn = dev_ofnode(dev); @@ -618,6 +618,6 @@ U_BOOT_DRIVER(pcie_brcm_base) = { .ops = &brcm_pcie_ops, .of_match = brcm_pcie_ids, .probe = brcm_pcie_probe, - .ofdata_to_platdata = brcm_pcie_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct brcm_pcie), + .of_to_plat = brcm_pcie_of_to_plat, + .priv_auto = sizeof(struct brcm_pcie), }; diff --git a/drivers/pci/pcie_dw_mvebu.c b/drivers/pci/pcie_dw_mvebu.c index c773f8d28d..7ec149d178 100644 --- a/drivers/pci/pcie_dw_mvebu.c +++ b/drivers/pci/pcie_dw_mvebu.c @@ -500,13 +500,13 @@ static int pcie_dw_mvebu_probe(struct udevice *dev) debug("PCIE Reset on GPIO support is missing\n"); #endif /* DM_GPIO */ - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); /* Don't register host if link is down */ if (!pcie_dw_mvebu_pcie_link_up(pcie->ctrl_base, LINK_SPEED_GEN_3)) { - printf("PCIE-%d: Link down\n", dev->seq); + printf("PCIE-%d: Link down\n", dev_seq(dev)); } else { - printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev->seq, + printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev_seq(dev), pcie_dw_get_link_speed(pcie->ctrl_base), pcie_dw_get_link_width(pcie->ctrl_base), hose->first_busno); @@ -535,7 +535,7 @@ static int pcie_dw_mvebu_probe(struct udevice *dev) } /** - * pcie_dw_mvebu_ofdata_to_platdata() - Translate from DT to device state + * pcie_dw_mvebu_of_to_plat() - Translate from DT to device state * * @dev: A pointer to the device being operated on * @@ -545,7 +545,7 @@ static int pcie_dw_mvebu_probe(struct udevice *dev) * * Return: 0 on success, else -EINVAL */ -static int pcie_dw_mvebu_ofdata_to_platdata(struct udevice *dev) +static int pcie_dw_mvebu_of_to_plat(struct udevice *dev) { struct pcie_dw_mvebu *pcie = dev_get_priv(dev); @@ -578,7 +578,7 @@ U_BOOT_DRIVER(pcie_dw_mvebu) = { .id = UCLASS_PCI, .of_match = pcie_dw_mvebu_ids, .ops = &pcie_dw_mvebu_ops, - .ofdata_to_platdata = pcie_dw_mvebu_ofdata_to_platdata, + .of_to_plat = pcie_dw_mvebu_of_to_plat, .probe = pcie_dw_mvebu_probe, - .priv_auto_alloc_size = sizeof(struct pcie_dw_mvebu), + .priv_auto = sizeof(struct pcie_dw_mvebu), }; diff --git a/drivers/pci/pcie_dw_ti.c b/drivers/pci/pcie_dw_ti.c index 742dd93633..5e00fcda97 100644 --- a/drivers/pci/pcie_dw_ti.c +++ b/drivers/pci/pcie_dw_ti.c @@ -634,7 +634,7 @@ static int pcie_dw_ti_probe(struct udevice *dev) generic_phy_init(&phy1); generic_phy_power_on(&phy1); - pci->first_busno = dev->seq; + pci->first_busno = dev_seq(dev); pci->dev = dev; pcie_dw_setup_host(pci); @@ -644,11 +644,11 @@ static int pcie_dw_ti_probe(struct udevice *dev) pcie_am654_set_mode(pci, DW_PCIE_RC_TYPE); if (!pcie_dw_ti_pcie_link_up(pci, LINK_SPEED_GEN_2)) { - printf("PCIE-%d: Link down\n", dev->seq); + printf("PCIE-%d: Link down\n", dev_seq(dev)); return -ENODEV; } - printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev->seq, + printf("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n", dev_seq(dev), pcie_dw_get_link_speed(pci), pcie_dw_get_link_width(pci), hose->first_busno); @@ -671,7 +671,7 @@ static int pcie_dw_ti_probe(struct udevice *dev) } /** - * pcie_dw_ti_ofdata_to_platdata() - Translate from DT to device state + * pcie_dw_ti_of_to_plat() - Translate from DT to device state * * @dev: A pointer to the device being operated on * @@ -681,7 +681,7 @@ static int pcie_dw_ti_probe(struct udevice *dev) * * Return: 0 on success, else -EINVAL */ -static int pcie_dw_ti_ofdata_to_platdata(struct udevice *dev) +static int pcie_dw_ti_of_to_plat(struct udevice *dev) { struct pcie_dw_ti *pcie = dev_get_priv(dev); @@ -724,7 +724,7 @@ U_BOOT_DRIVER(pcie_dw_ti) = { .id = UCLASS_PCI, .of_match = pcie_dw_ti_ids, .ops = &pcie_dw_ti_ops, - .ofdata_to_platdata = pcie_dw_ti_ofdata_to_platdata, + .of_to_plat = pcie_dw_ti_of_to_plat, .probe = pcie_dw_ti_probe, - .priv_auto_alloc_size = sizeof(struct pcie_dw_ti), + .priv_auto = sizeof(struct pcie_dw_ti), }; diff --git a/drivers/pci/pcie_ecam_generic.c b/drivers/pci/pcie_ecam_generic.c index 890b6a8fb6..7d1f13d637 100644 --- a/drivers/pci/pcie_ecam_generic.c +++ b/drivers/pci/pcie_ecam_generic.c @@ -113,7 +113,7 @@ static int pci_generic_ecam_write_config(struct udevice *bus, pci_dev_t bdf, } /** - * pci_generic_ecam_ofdata_to_platdata() - Translate from DT to device state + * pci_generic_ecam_of_to_plat() - Translate from DT to device state * @dev: A pointer to the device being operated on * * Translate relevant data from the device tree pertaining to device @dev into @@ -122,7 +122,7 @@ static int pci_generic_ecam_write_config(struct udevice *bus, pci_dev_t bdf, * * Return: 0 on success, else -EINVAL */ -static int pci_generic_ecam_ofdata_to_platdata(struct udevice *dev) +static int pci_generic_ecam_of_to_plat(struct udevice *dev) { struct generic_ecam_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -146,7 +146,7 @@ static int pci_generic_ecam_probe(struct udevice *dev) { struct generic_ecam_pcie *pcie = dev_get_priv(dev); - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); return 0; } @@ -167,6 +167,6 @@ U_BOOT_DRIVER(pci_generic_ecam) = { .of_match = pci_generic_ecam_ids, .ops = &pci_generic_ecam_ops, .probe = pci_generic_ecam_probe, - .ofdata_to_platdata = pci_generic_ecam_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct generic_ecam_pcie), + .of_to_plat = pci_generic_ecam_of_to_plat, + .priv_auto = sizeof(struct generic_ecam_pcie), }; diff --git a/drivers/pci/pcie_fsl.c b/drivers/pci/pcie_fsl.c index fb50b8f518..b061b31cae 100644 --- a/drivers/pci/pcie_fsl.c +++ b/drivers/pci/pcie_fsl.c @@ -29,16 +29,16 @@ static int fsl_pcie_addr_valid(struct fsl_pcie *pcie, pci_dev_t bdf) if (!pcie->enabled) return -ENXIO; - if (PCI_BUS(bdf) < bus->seq) + if (PCI_BUS(bdf) < dev_seq(bus)) return -EINVAL; - if (PCI_BUS(bdf) > bus->seq && (!fsl_pcie_link_up(pcie) || pcie->mode)) + if (PCI_BUS(bdf) > dev_seq(bus) && (!fsl_pcie_link_up(pcie) || pcie->mode)) return -EINVAL; - if (PCI_BUS(bdf) == bus->seq && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0)) + if (PCI_BUS(bdf) == dev_seq(bus) && (PCI_DEV(bdf) > 0 || PCI_FUNC(bdf) > 0)) return -EINVAL; - if (PCI_BUS(bdf) == (bus->seq + 1) && (PCI_DEV(bdf) > 0)) + if (PCI_BUS(bdf) == (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0)) return -EINVAL; return 0; @@ -57,7 +57,7 @@ static int fsl_pcie_read_config(const struct udevice *bus, pci_dev_t bdf, return 0; } - bdf = bdf - PCI_BDF(bus->seq, 0, 0); + bdf = bdf - PCI_BDF(dev_seq(bus), 0, 0); val = bdf | (offset & 0xfc) | ((offset & 0xf00) << 16) | 0x80000000; out_be32(®s->cfg_addr, val); @@ -93,7 +93,7 @@ static int fsl_pcie_write_config(struct udevice *bus, pci_dev_t bdf, if (fsl_pcie_addr_valid(pcie, bdf)) return 0; - bdf = bdf - PCI_BDF(bus->seq, 0, 0); + bdf = bdf - PCI_BDF(dev_seq(bus), 0, 0); val = bdf | (offset & 0xfc) | ((offset & 0xf00) << 16) | 0x80000000; out_be32(®s->cfg_addr, val); @@ -123,7 +123,7 @@ static int fsl_pcie_hose_read_config(struct fsl_pcie *pcie, uint offset, int ret; struct udevice *bus = pcie->bus; - ret = fsl_pcie_read_config(bus, PCI_BDF(bus->seq, 0, 0), + ret = fsl_pcie_read_config(bus, PCI_BDF(dev_seq(bus), 0, 0), offset, valuep, size); return ret; @@ -134,7 +134,7 @@ static int fsl_pcie_hose_write_config(struct fsl_pcie *pcie, uint offset, { struct udevice *bus = pcie->bus; - return fsl_pcie_write_config(bus, PCI_BDF(bus->seq, 0, 0), + return fsl_pcie_write_config(bus, PCI_BDF(dev_seq(bus), 0, 0), offset, value, size); } @@ -593,7 +593,7 @@ static int fsl_pcie_probe(struct udevice *dev) return 0; } -static int fsl_pcie_ofdata_to_platdata(struct udevice *dev) +static int fsl_pcie_of_to_plat(struct udevice *dev) { struct fsl_pcie *pcie = dev_get_priv(dev); struct fsl_pcie_data *info; @@ -661,7 +661,7 @@ U_BOOT_DRIVER(fsl_pcie) = { .id = UCLASS_PCI, .of_match = fsl_pcie_ids, .ops = &fsl_pcie_ops, - .ofdata_to_platdata = fsl_pcie_ofdata_to_platdata, + .of_to_plat = fsl_pcie_of_to_plat, .probe = fsl_pcie_probe, - .priv_auto_alloc_size = sizeof(struct fsl_pcie), + .priv_auto = sizeof(struct fsl_pcie), }; diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c index cbf12371a0..d9c2325a22 100644 --- a/drivers/pci/pcie_imx.c +++ b/drivers/pci/pcie_imx.c @@ -799,7 +799,7 @@ static int imx_pcie_dm_remove(struct udevice *dev) return 0; } -static int imx_pcie_ofdata_to_platdata(struct udevice *dev) +static int imx_pcie_of_to_plat(struct udevice *dev) { struct imx_pcie_priv *priv = dev_get_priv(dev); @@ -829,8 +829,8 @@ U_BOOT_DRIVER(imx_pcie) = { .ops = &imx_pcie_ops, .probe = imx_pcie_dm_probe, .remove = imx_pcie_dm_remove, - .ofdata_to_platdata = imx_pcie_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct imx_pcie_priv), + .of_to_plat = imx_pcie_of_to_plat, + .priv_auto = sizeof(struct imx_pcie_priv), .flags = DM_FLAG_OS_PREPARE, }; #endif diff --git a/drivers/pci/pcie_intel_fpga.c b/drivers/pci/pcie_intel_fpga.c index 9f102c64c6..b4964757c7 100644 --- a/drivers/pci/pcie_intel_fpga.c +++ b/drivers/pci/pcie_intel_fpga.c @@ -369,7 +369,7 @@ static int pcie_intel_fpga_probe(struct udevice *dev) struct intel_fpga_pcie *pcie = dev_get_priv(dev); pcie->bus = pci_get_controller(dev); - pcie->first_busno = dev->seq; + pcie->first_busno = dev_seq(dev); /* clear all interrupts */ cra_writel(pcie, P2A_INT_STS_ALL, P2A_INT_STATUS); @@ -379,7 +379,7 @@ static int pcie_intel_fpga_probe(struct udevice *dev) return 0; } -static int pcie_intel_fpga_ofdata_to_platdata(struct udevice *dev) +static int pcie_intel_fpga_of_to_plat(struct udevice *dev) { struct intel_fpga_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -428,7 +428,7 @@ U_BOOT_DRIVER(pcie_intel_fpga) = { .id = UCLASS_PCI, .of_match = pcie_intel_fpga_ids, .ops = &pcie_intel_fpga_ops, - .ofdata_to_platdata = pcie_intel_fpga_ofdata_to_platdata, + .of_to_plat = pcie_intel_fpga_of_to_plat, .probe = pcie_intel_fpga_probe, - .priv_auto_alloc_size = sizeof(struct intel_fpga_pcie), + .priv_auto = sizeof(struct intel_fpga_pcie), }; diff --git a/drivers/pci/pcie_iproc.c b/drivers/pci/pcie_iproc.c index d77735fcf2..6725ff6437 100644 --- a/drivers/pci/pcie_iproc.c +++ b/drivers/pci/pcie_iproc.c @@ -1282,6 +1282,6 @@ U_BOOT_DRIVER(pci_iproc) = { .ops = &iproc_pcie_ops, .probe = iproc_pcie_probe, .remove = iproc_pcie_remove, - .priv_auto_alloc_size = sizeof(struct iproc_pcie), + .priv_auto = sizeof(struct iproc_pcie), .flags = DM_REMOVE_OS_PREPARE, }; diff --git a/drivers/pci/pcie_layerscape_ep.c b/drivers/pci/pcie_layerscape_ep.c index d7d4a44b22..041a526f0b 100644 --- a/drivers/pci/pcie_layerscape_ep.c +++ b/drivers/pci/pcie_layerscape_ep.c @@ -332,5 +332,5 @@ U_BOOT_DRIVER(pci_layerscape_ep) = { .ops = &ls_pcie_ep_ops, .probe = ls_pcie_ep_probe, .remove = ls_pcie_ep_remove, - .priv_auto_alloc_size = sizeof(struct ls_pcie_ep), + .priv_auto = sizeof(struct ls_pcie_ep), }; diff --git a/drivers/pci/pcie_layerscape_fixup.c b/drivers/pci/pcie_layerscape_fixup.c index c75cf26e0a..a58e7a3892 100644 --- a/drivers/pci/pcie_layerscape_fixup.c +++ b/drivers/pci/pcie_layerscape_fixup.c @@ -479,7 +479,7 @@ static int fdt_fixup_pci_vfs(void *blob, struct extra_iommu_entry *entry, for (bus = dev; device_is_on_pci_bus(bus);) bus = bus->parent; - bdf = entry->bdf - PCI_BDF(bus->seq, 0, 0) + (vf_offset << 8); + bdf = entry->bdf - PCI_BDF(dev_seq(bus), 0, 0) + (vf_offset << 8); for (i = 0; i < entry->num_vfs; i++) { if (fdt_fixup_pcie_device_ls(blob, bdf, pcie_rc) < 0) @@ -518,7 +518,7 @@ static void fdt_fixup_pcie_ls(void *blob) pcie_rc = dev_get_priv(bus); /* the DT fixup must be relative to the hose first_busno */ - bdf = dm_pci_get_bdf(dev) - PCI_BDF(bus->seq, 0, 0); + bdf = dm_pci_get_bdf(dev) - PCI_BDF(dev_seq(bus), 0, 0); if (fdt_fixup_pcie_device_ls(blob, bdf, pcie_rc) < 0) break; diff --git a/drivers/pci/pcie_layerscape_gen4.c b/drivers/pci/pcie_layerscape_gen4.c index 6e71173621..be9cb6285c 100644 --- a/drivers/pci/pcie_layerscape_gen4.c +++ b/drivers/pci/pcie_layerscape_gen4.c @@ -191,13 +191,13 @@ static int ls_pcie_g4_addr_valid(struct ls_pcie_g4 *pcie, pci_dev_t bdf) if (!pcie->enabled) return -ENXIO; - if (PCI_BUS(bdf) < bus->seq) + if (PCI_BUS(bdf) < dev_seq(bus)) return -EINVAL; - if ((PCI_BUS(bdf) > bus->seq) && (!ls_pcie_g4_link_up(pcie))) + if ((PCI_BUS(bdf) > dev_seq(bus)) && (!ls_pcie_g4_link_up(pcie))) return -EINVAL; - if (PCI_BUS(bdf) <= (bus->seq + 1) && (PCI_DEV(bdf) > 0)) + if (PCI_BUS(bdf) <= (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0)) return -EINVAL; return 0; @@ -209,7 +209,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf, struct udevice *bus = pcie->bus; u32 target; - if (PCI_BUS(bdf) == bus->seq) { + if (PCI_BUS(bdf) == dev_seq(bus)) { if (offset < INDIRECT_ADDR_BNDRY) { ccsr_set_page(pcie, 0); return pcie->ccsr + offset; @@ -219,7 +219,7 @@ void *ls_pcie_g4_conf_address(struct ls_pcie_g4 *pcie, pci_dev_t bdf, return pcie->ccsr + OFFSET_TO_PAGE_ADDR(offset); } - target = PAB_TARGET_BUS(PCI_BUS(bdf) - bus->seq) | + target = PAB_TARGET_BUS(PCI_BUS(bdf) - dev_seq(bus)) | PAB_TARGET_DEV(PCI_DEV(bdf)) | PAB_TARGET_FUNC(PCI_FUNC(bdf)); @@ -580,5 +580,5 @@ U_BOOT_DRIVER(pcie_layerscape_gen4) = { .of_match = ls_pcie_g4_ids, .ops = &ls_pcie_g4_ops, .probe = ls_pcie_g4_probe, - .priv_auto_alloc_size = sizeof(struct ls_pcie_g4), + .priv_auto = sizeof(struct ls_pcie_g4), }; diff --git a/drivers/pci/pcie_layerscape_gen4_fixup.c b/drivers/pci/pcie_layerscape_gen4_fixup.c index 148b5d17ed..e9ee15558e 100644 --- a/drivers/pci/pcie_layerscape_gen4_fixup.c +++ b/drivers/pci/pcie_layerscape_gen4_fixup.c @@ -166,7 +166,7 @@ static void fdt_fixup_pcie_ls_gen4(void *blob) } /* the DT fixup must be relative to the hose first_busno */ - bdf = dm_pci_get_bdf(dev) - PCI_BDF(bus->seq, 0, 0); + bdf = dm_pci_get_bdf(dev) - PCI_BDF(dev_seq(bus), 0, 0); /* map PCI b.d.f to streamID in LUT */ ls_pcie_g4_lut_set_mapping(pcie, index, bdf >> 8, streamid); /* update msi-map in device tree */ diff --git a/drivers/pci/pcie_layerscape_rc.c b/drivers/pci/pcie_layerscape_rc.c index cdfcad6b0b..517e7b5ceb 100644 --- a/drivers/pci/pcie_layerscape_rc.c +++ b/drivers/pci/pcie_layerscape_rc.c @@ -130,13 +130,13 @@ static int ls_pcie_addr_valid(struct ls_pcie_rc *pcie_rc, pci_dev_t bdf) if (!pcie_rc->enabled) return -ENXIO; - if (PCI_BUS(bdf) < bus->seq) + if (PCI_BUS(bdf) < dev_seq(bus)) return -EINVAL; - if ((PCI_BUS(bdf) > bus->seq) && (!ls_pcie_link_up(pcie))) + if ((PCI_BUS(bdf) > dev_seq(bus)) && (!ls_pcie_link_up(pcie))) return -EINVAL; - if (PCI_BUS(bdf) <= (bus->seq + 1) && (PCI_DEV(bdf) > 0)) + if (PCI_BUS(bdf) <= (dev_seq(bus) + 1) && (PCI_DEV(bdf) > 0)) return -EINVAL; return 0; @@ -152,16 +152,16 @@ int ls_pcie_conf_address(const struct udevice *bus, pci_dev_t bdf, if (ls_pcie_addr_valid(pcie_rc, bdf)) return -EINVAL; - if (PCI_BUS(bdf) == bus->seq) { + if (PCI_BUS(bdf) == dev_seq(bus)) { *paddress = pcie->dbi + offset; return 0; } - busdev = PCIE_ATU_BUS(PCI_BUS(bdf) - bus->seq) | + busdev = PCIE_ATU_BUS(PCI_BUS(bdf) - dev_seq(bus)) | PCIE_ATU_DEV(PCI_DEV(bdf)) | PCIE_ATU_FUNC(PCI_FUNC(bdf)); - if (PCI_BUS(bdf) == bus->seq + 1) { + if (PCI_BUS(bdf) == dev_seq(bus) + 1) { ls_pcie_cfg0_set_busdev(pcie_rc, busdev); *paddress = pcie_rc->cfg0 + offset; } else { @@ -383,5 +383,5 @@ U_BOOT_DRIVER(pci_layerscape) = { .of_match = ls_pcie_ids, .ops = &ls_pcie_ops, .probe = ls_pcie_probe, - .priv_auto_alloc_size = sizeof(struct ls_pcie_rc), + .priv_auto = sizeof(struct ls_pcie_rc), }; diff --git a/drivers/pci/pcie_mediatek.c b/drivers/pci/pcie_mediatek.c index 55b6a40f25..f555671387 100644 --- a/drivers/pci/pcie_mediatek.c +++ b/drivers/pci/pcie_mediatek.c @@ -251,7 +251,7 @@ static struct mtk_pcie_port *mtk_pcie_find_port(const struct udevice *bus, struct mtk_pcie *pcie = dev_get_priv(bus); struct mtk_pcie_port *port; struct udevice *dev; - struct pci_child_platdata *pplat = NULL; + struct pci_child_plat *pplat = NULL; int ret = 0; if (PCI_BUS(bdf) != 0) { @@ -261,10 +261,10 @@ static struct mtk_pcie_port *mtk_pcie_find_port(const struct udevice *bus, return NULL; } - while (dev->parent->seq != 0) + while (dev_seq(dev->parent) != 0) dev = dev->parent; - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); } list_for_each_entry(port, &pcie->ports, list) { @@ -728,7 +728,7 @@ U_BOOT_DRIVER(pcie_mediatek_v1) = { .of_match = mtk_pcie_ids, .ops = &mtk_pcie_ops, .probe = mtk_pcie_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pcie), + .priv_auto = sizeof(struct mtk_pcie), }; static const struct udevice_id mtk_pcie_ids_v2[] = { @@ -742,5 +742,5 @@ U_BOOT_DRIVER(pcie_mediatek_v2) = { .of_match = mtk_pcie_ids_v2, .ops = &mtk_pcie_ops_v2, .probe = mtk_pcie_probe_v2, - .priv_auto_alloc_size = sizeof(struct mtk_pcie), + .priv_auto = sizeof(struct mtk_pcie), }; diff --git a/drivers/pci/pcie_phytium.c b/drivers/pci/pcie_phytium.c index 51b2171f9f..03ea04ceaa 100644 --- a/drivers/pci/pcie_phytium.c +++ b/drivers/pci/pcie_phytium.c @@ -147,7 +147,7 @@ static int pci_phytium_write_config(struct udevice *bus, pci_dev_t bdf, } /** - * pci_phytium_ofdata_to_platdata() - Translate from DT to device state + * pci_phytium_of_to_plat() - Translate from DT to device state * @dev: A pointer to the device being operated on * * Translate relevant data from the device tree pertaining to device @dev into @@ -156,7 +156,7 @@ static int pci_phytium_write_config(struct udevice *bus, pci_dev_t bdf, * * Return: 0 on success, else -EINVAL */ -static int pci_phytium_ofdata_to_platdata(struct udevice *dev) +static int pci_phytium_of_to_plat(struct udevice *dev) { struct phytium_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -194,6 +194,6 @@ U_BOOT_DRIVER(pci_phytium) = { .id = UCLASS_PCI, .of_match = pci_phytium_ids, .ops = &pci_phytium_ops, - .ofdata_to_platdata = pci_phytium_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct phytium_pcie), + .of_to_plat = pci_phytium_of_to_plat, + .priv_auto = sizeof(struct phytium_pcie), }; diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c index 04609f1296..027745e42e 100644 --- a/drivers/pci/pcie_rockchip.c +++ b/drivers/pci/pcie_rockchip.c @@ -373,7 +373,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) /* Configure Address Translation. */ ret = rockchip_pcie_atr_init(priv); if (ret) { - dev_err(dev, "PCIE-%d: ATR init failed\n", dev->seq); + dev_err(dev, "PCIE-%d: ATR init failed\n", dev_seq(dev)); goto err_power_off_phy; } @@ -528,7 +528,7 @@ static int rockchip_pcie_probe(struct udevice *dev) struct pci_controller *hose = dev_get_uclass_priv(ctlr); int ret; - priv->first_busno = dev->seq; + priv->first_busno = dev_seq(dev); priv->dev = dev; ret = rockchip_pcie_parse_dt(dev); @@ -544,7 +544,7 @@ static int rockchip_pcie_probe(struct udevice *dev) return ret; dev_info(dev, "PCIE-%d: Link up (Bus%d)\n", - dev->seq, hose->first_busno); + dev_seq(dev), hose->first_busno); return 0; } @@ -565,5 +565,5 @@ U_BOOT_DRIVER(rockchip_pcie) = { .of_match = rockchip_pcie_ids, .ops = &rockchip_pcie_ops, .probe = rockchip_pcie_probe, - .priv_auto_alloc_size = sizeof(struct rockchip_pcie), + .priv_auto = sizeof(struct rockchip_pcie), }; diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c index 713ad49d04..00879a2d72 100644 --- a/drivers/pci/pcie_xilinx.c +++ b/drivers/pci/pcie_xilinx.c @@ -129,7 +129,7 @@ static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf, } /** - * pcie_xilinx_ofdata_to_platdata() - Translate from DT to device state + * pcie_xilinx_of_to_plat() - Translate from DT to device state * @dev: A pointer to the device being operated on * * Translate relevant data from the device tree pertaining to device @dev into @@ -138,7 +138,7 @@ static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf, * * Return: 0 on success, else -EINVAL */ -static int pcie_xilinx_ofdata_to_platdata(struct udevice *dev) +static int pcie_xilinx_of_to_plat(struct udevice *dev) { struct xilinx_pcie *pcie = dev_get_priv(dev); struct fdt_resource reg_res; @@ -174,6 +174,6 @@ U_BOOT_DRIVER(pcie_xilinx) = { .id = UCLASS_PCI, .of_match = pcie_xilinx_ids, .ops = &pcie_xilinx_ops, - .ofdata_to_platdata = pcie_xilinx_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct xilinx_pcie), + .of_to_plat = pcie_xilinx_of_to_plat, + .priv_auto = sizeof(struct xilinx_pcie), }; diff --git a/drivers/pci_endpoint/pcie-cadence-ep.c b/drivers/pci_endpoint/pcie-cadence-ep.c index 74dfdde154..7313428fe0 100644 --- a/drivers/pci_endpoint/pcie-cadence-ep.c +++ b/drivers/pci_endpoint/pcie-cadence-ep.c @@ -173,5 +173,5 @@ U_BOOT_DRIVER(cdns_pcie) = { .ops = &cdns_pci_ep_ops, .probe = cdns_pci_ep_probe, .remove = cdns_pci_ep_remove, - .priv_auto_alloc_size = sizeof(struct cdns_pcie), + .priv_auto = sizeof(struct cdns_pcie), }; diff --git a/drivers/pci_endpoint/sandbox-pci_ep.c b/drivers/pci_endpoint/sandbox-pci_ep.c index 8e05d5ba89..de148cddb9 100644 --- a/drivers/pci_endpoint/sandbox-pci_ep.c +++ b/drivers/pci_endpoint/sandbox-pci_ep.c @@ -175,5 +175,5 @@ U_BOOT_DRIVER(pci_ep_sandbox) = { .of_match = sandbox_pci_ep_ids, .probe = sandbox_pci_ep_probe, .ops = &sandbox_pci_ep_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_pci_ep_priv), + .priv_auto = sizeof(struct sandbox_pci_ep_priv), }; diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index 7b9d3eefc5..5723c98032 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -428,7 +428,7 @@ static struct phy_ops sun4i_usb_phy_ops = { static int sun4i_usb_phy_probe(struct udevice *dev) { - struct sun4i_usb_phy_plat *plat = dev_get_platdata(dev); + struct sun4i_usb_phy_plat *plat = dev_get_plat(dev); struct sun4i_usb_phy_data *data = dev_get_priv(dev); int i, ret; @@ -646,6 +646,6 @@ U_BOOT_DRIVER(sun4i_usb_phy) = { .of_match = sun4i_usb_phy_ids, .ops = &sun4i_usb_phy_ops, .probe = sun4i_usb_phy_probe, - .platdata_auto_alloc_size = sizeof(struct sun4i_usb_phy_plat[MAX_PHYS]), - .priv_auto_alloc_size = sizeof(struct sun4i_usb_phy_data), + .plat_auto = sizeof(struct sun4i_usb_phy_plat[MAX_PHYS]), + .priv_auto = sizeof(struct sun4i_usb_phy_data), }; diff --git a/drivers/phy/bcm6318-usbh-phy.c b/drivers/phy/bcm6318-usbh-phy.c index d29344ddb4..60608a55bc 100644 --- a/drivers/phy/bcm6318-usbh-phy.c +++ b/drivers/phy/bcm6318-usbh-phy.c @@ -138,6 +138,6 @@ U_BOOT_DRIVER(bcm6318_usbh) = { .id = UCLASS_PHY, .of_match = bcm6318_usbh_ids, .ops = &bcm6318_usbh_ops, - .priv_auto_alloc_size = sizeof(struct bcm6318_usbh_priv), + .priv_auto = sizeof(struct bcm6318_usbh_priv), .probe = bcm6318_usbh_probe, }; diff --git a/drivers/phy/bcm6348-usbh-phy.c b/drivers/phy/bcm6348-usbh-phy.c index 8d28292726..1b6b5ad177 100644 --- a/drivers/phy/bcm6348-usbh-phy.c +++ b/drivers/phy/bcm6348-usbh-phy.c @@ -87,6 +87,6 @@ U_BOOT_DRIVER(bcm6348_usbh) = { .id = UCLASS_PHY, .of_match = bcm6348_usbh_ids, .ops = &bcm6348_usbh_ops, - .priv_auto_alloc_size = sizeof(struct bcm6348_usbh_priv), + .priv_auto = sizeof(struct bcm6348_usbh_priv), .probe = bcm6348_usbh_probe, }; diff --git a/drivers/phy/bcm6358-usbh-phy.c b/drivers/phy/bcm6358-usbh-phy.c index 501b97f3e2..bfdcfb0d24 100644 --- a/drivers/phy/bcm6358-usbh-phy.c +++ b/drivers/phy/bcm6358-usbh-phy.c @@ -87,6 +87,6 @@ U_BOOT_DRIVER(bcm6358_usbh) = { .id = UCLASS_PHY, .of_match = bcm6358_usbh_ids, .ops = &bcm6358_usbh_ops, - .priv_auto_alloc_size = sizeof(struct bcm6358_usbh_priv), + .priv_auto = sizeof(struct bcm6358_usbh_priv), .probe = bcm6358_usbh_probe, }; diff --git a/drivers/phy/bcm6368-usbh-phy.c b/drivers/phy/bcm6368-usbh-phy.c index 99fdd33499..4d3a63faad 100644 --- a/drivers/phy/bcm6368-usbh-phy.c +++ b/drivers/phy/bcm6368-usbh-phy.c @@ -191,6 +191,6 @@ U_BOOT_DRIVER(bcm6368_usbh) = { .id = UCLASS_PHY, .of_match = bcm6368_usbh_ids, .ops = &bcm6368_usbh_ops, - .priv_auto_alloc_size = sizeof(struct bcm6368_usbh_priv), + .priv_auto = sizeof(struct bcm6368_usbh_priv), .probe = bcm6368_usbh_probe, }; diff --git a/drivers/phy/keystone-usb-phy.c b/drivers/phy/keystone-usb-phy.c index 9faf501003..12f8a265f7 100644 --- a/drivers/phy/keystone-usb-phy.c +++ b/drivers/phy/keystone-usb-phy.c @@ -130,5 +130,5 @@ U_BOOT_DRIVER(keystone_usb_phy) = { .of_match = keystone_usb_phy_ids, .ops = &keystone_usb_phy_ops, .probe = keystone_usb_phy_probe, - .priv_auto_alloc_size = sizeof(struct keystone_usb_phy), + .priv_auto = sizeof(struct keystone_usb_phy), }; diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c index 5e8ce740cd..b2203277c4 100644 --- a/drivers/phy/marvell/comphy_core.c +++ b/drivers/phy/marvell/comphy_core.c @@ -189,5 +189,5 @@ U_BOOT_DRIVER(mvebu_comphy) = { .id = UCLASS_MISC, .of_match = comphy_ids, .probe = comphy_probe, - .priv_auto_alloc_size = sizeof(struct chip_serdes_phy_config), + .priv_auto = sizeof(struct chip_serdes_phy_config), }; diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c index 447ce7283d..2fbba7fdae 100644 --- a/drivers/phy/meson-g12a-usb2.c +++ b/drivers/phy/meson-g12a-usb2.c @@ -215,5 +215,5 @@ U_BOOT_DRIVER(meson_g12a_usb2_phy) = { .of_match = meson_g12a_usb2_phy_ids, .probe = meson_g12a_usb2_phy_probe, .ops = &meson_g12a_usb2_phy_ops, - .priv_auto_alloc_size = sizeof(struct phy_meson_g12a_usb2_priv), + .priv_auto = sizeof(struct phy_meson_g12a_usb2_priv), }; diff --git a/drivers/phy/meson-g12a-usb3-pcie.c b/drivers/phy/meson-g12a-usb3-pcie.c index 4e9696fd59..0433d93474 100644 --- a/drivers/phy/meson-g12a-usb3-pcie.c +++ b/drivers/phy/meson-g12a-usb3-pcie.c @@ -343,5 +343,5 @@ U_BOOT_DRIVER(meson_g12a_usb3_pcie_phy) = { .of_match = meson_g12a_usb3_pcie_phy_ids, .probe = meson_g12a_usb3_pcie_phy_probe, .ops = &meson_g12a_usb3_pcie_phy_ops, - .priv_auto_alloc_size = sizeof(struct phy_g12a_usb3_pcie_priv), + .priv_auto = sizeof(struct phy_g12a_usb3_pcie_priv), }; diff --git a/drivers/phy/meson-gxbb-usb2.c b/drivers/phy/meson-gxbb-usb2.c index d1beebee43..7a2e3d2739 100644 --- a/drivers/phy/meson-gxbb-usb2.c +++ b/drivers/phy/meson-gxbb-usb2.c @@ -232,5 +232,5 @@ U_BOOT_DRIVER(meson_gxbb_usb2_phy) = { .probe = meson_gxbb_usb2_phy_probe, .remove = meson_gxbb_usb2_phy_remove, .ops = &meson_gxbb_usb2_phy_ops, - .priv_auto_alloc_size = sizeof(struct phy_meson_gxbb_usb2_priv), + .priv_auto = sizeof(struct phy_meson_gxbb_usb2_priv), }; diff --git a/drivers/phy/meson-gxl-usb2.c b/drivers/phy/meson-gxl-usb2.c index 2267bd08c2..9fb376cec4 100644 --- a/drivers/phy/meson-gxl-usb2.c +++ b/drivers/phy/meson-gxl-usb2.c @@ -251,5 +251,5 @@ U_BOOT_DRIVER(meson_gxl_usb2_phy) = { .of_match = meson_gxl_usb2_phy_ids, .probe = meson_gxl_usb2_phy_probe, .ops = &meson_gxl_usb2_phy_ops, - .priv_auto_alloc_size = sizeof(struct phy_meson_gxl_usb2_priv), + .priv_auto = sizeof(struct phy_meson_gxl_usb2_priv), }; diff --git a/drivers/phy/msm8916-usbh-phy.c b/drivers/phy/msm8916-usbh-phy.c index 4efaddd701..7c9d030a4d 100644 --- a/drivers/phy/msm8916-usbh-phy.c +++ b/drivers/phy/msm8916-usbh-phy.c @@ -106,5 +106,5 @@ U_BOOT_DRIVER(msm8916_usbphy) = { .of_match = msm_phy_ids, .ops = &msm_phy_ops, .probe = msm_phy_probe, - .priv_auto_alloc_size = sizeof(struct msm_phy_priv), + .priv_auto = sizeof(struct msm_phy_priv), }; diff --git a/drivers/phy/mt76x8-usb-phy.c b/drivers/phy/mt76x8-usb-phy.c index 4c0818f6e8..4069208b67 100644 --- a/drivers/phy/mt76x8-usb-phy.c +++ b/drivers/phy/mt76x8-usb-phy.c @@ -248,5 +248,5 @@ U_BOOT_DRIVER(mt76x8_usb_phy) = { .of_match = mt76x8_usb_phy_ids, .ops = &mt76x8_usb_phy_ops, .probe = mt76x8_usb_phy_probe, - .priv_auto_alloc_size = sizeof(struct mt76x8_usb_phy), + .priv_auto = sizeof(struct mt76x8_usb_phy), }; diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c index ba71785fe4..84aac80623 100644 --- a/drivers/phy/nop-phy.c +++ b/drivers/phy/nop-phy.c @@ -56,5 +56,5 @@ U_BOOT_DRIVER(nop_phy) = { .of_match = nop_phy_ids, .ops = &nop_phy_ops, .probe = nop_phy_probe, - .priv_auto_alloc_size = sizeof(struct nop_phy_priv), + .priv_auto = sizeof(struct nop_phy_priv), }; diff --git a/drivers/phy/omap-usb2-phy.c b/drivers/phy/omap-usb2-phy.c index a981cb2f8d..cb99143732 100644 --- a/drivers/phy/omap-usb2-phy.c +++ b/drivers/phy/omap-usb2-phy.c @@ -261,5 +261,5 @@ U_BOOT_DRIVER(omap_usb2_phy) = { .of_match = omap_usb2_id_table, .probe = omap_usb2_phy_probe, .ops = &omap_usb2_phy_ops, - .priv_auto_alloc_size = sizeof(struct omap_usb2_phy), + .priv_auto = sizeof(struct omap_usb2_phy), }; diff --git a/drivers/phy/phy-bcm-sr-pcie.c b/drivers/phy/phy-bcm-sr-pcie.c index 36c77c4b63..f0e795333b 100644 --- a/drivers/phy/phy-bcm-sr-pcie.c +++ b/drivers/phy/phy-bcm-sr-pcie.c @@ -172,6 +172,6 @@ U_BOOT_DRIVER(sr_pcie_phy) = { .probe = sr_pcie_phy_probe, .of_match = sr_pcie_phy_match_table, .ops = &sr_pcie_phy_ops, - .platdata_auto_alloc_size = sizeof(struct sr_pcie_phy_core), - .priv_auto_alloc_size = sizeof(struct sr_pcie_phy_core), + .plat_auto = sizeof(struct sr_pcie_phy_core), + .priv_auto = sizeof(struct sr_pcie_phy_core), }; diff --git a/drivers/phy/phy-mtk-tphy.c b/drivers/phy/phy-mtk-tphy.c index 3d7b9cd2b1..824244b852 100644 --- a/drivers/phy/phy-mtk-tphy.c +++ b/drivers/phy/phy-mtk-tphy.c @@ -749,5 +749,5 @@ U_BOOT_DRIVER(mtk_tphy) = { .of_match = mtk_tphy_id_table, .ops = &mtk_tphy_ops, .probe = mtk_tphy_probe, - .priv_auto_alloc_size = sizeof(struct mtk_tphy), + .priv_auto = sizeof(struct mtk_tphy), }; diff --git a/drivers/phy/phy-qcom-ipq4019-usb.c b/drivers/phy/phy-qcom-ipq4019-usb.c index 465f0d3a01..5808489249 100644 --- a/drivers/phy/phy-qcom-ipq4019-usb.c +++ b/drivers/phy/phy-qcom-ipq4019-usb.c @@ -75,7 +75,7 @@ U_BOOT_DRIVER(ipq4019_usb_ss_phy) = { .of_match = ipq4019_usb_ss_phy_ids, .ops = &ipq4019_usb_ss_phy_ops, .probe = ipq4019_usb_ss_phy_probe, - .priv_auto_alloc_size = sizeof(struct ipq4019_usb_phy), + .priv_auto = sizeof(struct ipq4019_usb_phy), }; static int ipq4019_hs_phy_power_off(struct phy *_phy) @@ -141,5 +141,5 @@ U_BOOT_DRIVER(ipq4019_usb_hs_phy) = { .of_match = ipq4019_usb_hs_phy_ids, .ops = &ipq4019_usb_hs_phy_ops, .probe = ipq4019_usb_hs_phy_probe, - .priv_auto_alloc_size = sizeof(struct ipq4019_usb_phy), + .priv_auto = sizeof(struct ipq4019_usb_phy), }; diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c index 18da86e4be..1794095924 100644 --- a/drivers/phy/phy-rcar-gen2.c +++ b/drivers/phy/phy-rcar-gen2.c @@ -189,5 +189,5 @@ U_BOOT_DRIVER(rcar_gen2_phy) = { .ops = &rcar_gen2_phy_phy_ops, .probe = rcar_gen2_phy_probe, .remove = rcar_gen2_phy_remove, - .priv_auto_alloc_size = sizeof(struct rcar_gen2_phy), + .priv_auto = sizeof(struct rcar_gen2_phy), }; diff --git a/drivers/phy/phy-rcar-gen3.c b/drivers/phy/phy-rcar-gen3.c index ce39cd8f9e..8c59631428 100644 --- a/drivers/phy/phy-rcar-gen3.c +++ b/drivers/phy/phy-rcar-gen3.c @@ -158,5 +158,5 @@ U_BOOT_DRIVER(rcar_gen3_phy) = { .ops = &rcar_gen3_phy_phy_ops, .probe = rcar_gen3_phy_probe, .remove = rcar_gen3_phy_remove, - .priv_auto_alloc_size = sizeof(struct rcar_gen3_phy), + .priv_auto = sizeof(struct rcar_gen3_phy), }; diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c index ab4a913c93..f23aef4fb0 100644 --- a/drivers/phy/phy-stm32-usbphyc.c +++ b/drivers/phy/phy-stm32-usbphyc.c @@ -419,5 +419,5 @@ U_BOOT_DRIVER(stm32_usb_phyc) = { .of_match = stm32_usbphyc_of_match, .ops = &stm32_usbphyc_phy_ops, .probe = stm32_usbphyc_probe, - .priv_auto_alloc_size = sizeof(struct stm32_usbphyc), + .priv_auto = sizeof(struct stm32_usbphyc), }; diff --git a/drivers/phy/phy-ti-am654.c b/drivers/phy/phy-ti-am654.c index cc73760c8b..82010e7c96 100644 --- a/drivers/phy/phy-ti-am654.c +++ b/drivers/phy/phy-ti-am654.c @@ -187,7 +187,7 @@ U_BOOT_DRIVER(serdes_am654_mux_clk) = { .name = "ti-serdes-am654-mux-clk", .id = UCLASS_CLK, .probe = serdes_am654_mux_clk_probe, - .priv_auto_alloc_size = sizeof(struct serdes_am654_mux_clk_data), + .priv_auto = sizeof(struct serdes_am654_mux_clk_data), .ops = &serdes_am654_mux_clk_ops, }; @@ -344,7 +344,7 @@ static int serdes_am654_bind(struct udevice *dev) ret = device_bind_driver_to_node(dev->parent, "ti-serdes-am654-mux-clk", - dev_read_name(dev), dev->node, + dev_read_name(dev), dev_ofnode(dev), NULL); if (ret) { dev_err(dev, "%s: not able to bind clock driver\n", __func__); @@ -412,5 +412,5 @@ U_BOOT_DRIVER(am654_serdes_phy) = { .bind = serdes_am654_bind, .ops = &serdes_am654_phy_ops, .probe = serdes_am654_probe, - .priv_auto_alloc_size = sizeof(struct serdes_am654), + .priv_auto = sizeof(struct serdes_am654), }; diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index c5ea6ca31f..6744b8b227 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -308,5 +308,5 @@ U_BOOT_DRIVER(rockchip_usb2phy) = { .of_match = rockchip_usb2phy_ids, .probe = rockchip_usb2phy_probe, .bind = rockchip_usb2phy_bind, - .priv_auto_alloc_size = sizeof(struct rockchip_usb2phy), + .priv_auto = sizeof(struct rockchip_usb2phy), }; diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c index 617943fd82..bc6c0feed0 100644 --- a/drivers/phy/rockchip/phy-rockchip-pcie.c +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -267,5 +267,5 @@ U_BOOT_DRIVER(rockchip_pcie_phy) = { .of_match = rockchip_pcie_phy_ids, .ops = &rockchip_pcie_phy_ops, .probe = rockchip_pcie_phy_probe, - .priv_auto_alloc_size = sizeof(struct rockchip_pcie_phy), + .priv_auto = sizeof(struct rockchip_pcie_phy), }; diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c index da00daa447..a45a318e47 100644 --- a/drivers/phy/rockchip/phy-rockchip-typec.c +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -792,5 +792,5 @@ U_BOOT_DRIVER(rockchip_typec_phy) = { .of_match = rockchip_typec_phy_ids, .probe = rockchip_tcphy_probe, .bind = rockchip_tcphy_bind, - .priv_auto_alloc_size = sizeof(struct rockchip_tcphy), + .priv_auto = sizeof(struct rockchip_tcphy), }; diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c index 5f36da7692..7b3d988613 100644 --- a/drivers/phy/sandbox-phy.c +++ b/drivers/phy/sandbox-phy.c @@ -116,5 +116,5 @@ U_BOOT_DRIVER(phy_sandbox) = { .of_match = sandbox_phy_ids, .ops = &sandbox_phy_ops, .probe = sandbox_phy_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_phy_priv), + .priv_auto = sizeof(struct sandbox_phy_priv), }; diff --git a/drivers/phy/sti_usb_phy.c b/drivers/phy/sti_usb_phy.c index 51468b4573..87c1bcddb4 100644 --- a/drivers/phy/sti_usb_phy.c +++ b/drivers/phy/sti_usb_phy.c @@ -177,5 +177,5 @@ U_BOOT_DRIVER(sti_usb_phy) = { .of_match = sti_usb_phy_ids, .probe = sti_usb_phy_probe, .ops = &sti_usb_phy_ops, - .priv_auto_alloc_size = sizeof(struct sti_usb_phy), + .priv_auto = sizeof(struct sti_usb_phy), }; diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c index 3f49851bca..98fe6c6fce 100644 --- a/drivers/phy/ti-pipe3-phy.c +++ b/drivers/phy/ti-pipe3-phy.c @@ -604,5 +604,5 @@ U_BOOT_DRIVER(pipe3_phy) = { .of_match = pipe3_phy_ids, .ops = &pipe3_phy_ops, .probe = pipe3_phy_probe, - .priv_auto_alloc_size = sizeof(struct omap_pipe3), + .priv_auto = sizeof(struct omap_pipe3), }; diff --git a/drivers/pinctrl/aspeed/pinctrl_ast2500.c b/drivers/pinctrl/aspeed/pinctrl_ast2500.c index 05ef24864f..3c2e10b88e 100644 --- a/drivers/pinctrl/aspeed/pinctrl_ast2500.c +++ b/drivers/pinctrl/aspeed/pinctrl_ast2500.c @@ -121,7 +121,7 @@ U_BOOT_DRIVER(pinctrl_ast2500) = { .name = "aspeed_ast2500_pinctrl", .id = UCLASS_PINCTRL, .of_match = ast2500_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct ast2500_pinctrl_priv), + .priv_auto = sizeof(struct ast2500_pinctrl_priv), .ops = &ast2500_pinctrl_ops, .probe = ast2500_pinctrl_probe, }; diff --git a/drivers/pinctrl/ath79/pinctrl_ar933x.c b/drivers/pinctrl/ath79/pinctrl_ar933x.c index 61e8081874..14408da2e7 100644 --- a/drivers/pinctrl/ath79/pinctrl_ar933x.c +++ b/drivers/pinctrl/ath79/pinctrl_ar933x.c @@ -130,7 +130,7 @@ U_BOOT_DRIVER(pinctrl_ar933x) = { .name = "pinctrl_ar933x", .id = UCLASS_PINCTRL, .of_match = ar933x_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct ar933x_pinctrl_priv), + .priv_auto = sizeof(struct ar933x_pinctrl_priv), .ops = &ar933x_pinctrl_ops, .probe = ar933x_pinctrl_probe, }; diff --git a/drivers/pinctrl/ath79/pinctrl_qca953x.c b/drivers/pinctrl/ath79/pinctrl_qca953x.c index 2d5a4a3ab2..b1c78bead3 100644 --- a/drivers/pinctrl/ath79/pinctrl_qca953x.c +++ b/drivers/pinctrl/ath79/pinctrl_qca953x.c @@ -150,7 +150,7 @@ U_BOOT_DRIVER(pinctrl_qca953x) = { .name = "pinctrl_qca953x", .id = UCLASS_PINCTRL, .of_match = qca953x_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct qca953x_pinctrl_priv), + .priv_auto = sizeof(struct qca953x_pinctrl_priv), .ops = &qca953x_pinctrl_ops, .probe = qca953x_pinctrl_probe, }; diff --git a/drivers/pinctrl/broadcom/pinctrl-bcm283x.c b/drivers/pinctrl/broadcom/pinctrl-bcm283x.c index 41da814123..44a310f83d 100644 --- a/drivers/pinctrl/broadcom/pinctrl-bcm283x.c +++ b/drivers/pinctrl/broadcom/pinctrl-bcm283x.c @@ -104,7 +104,7 @@ static const struct udevice_id bcm2835_pinctrl_id[] = { {} }; -int bcm283x_pinctl_ofdata_to_platdata(struct udevice *dev) +int bcm283x_pinctl_of_to_plat(struct udevice *dev) { struct bcm283x_pinctrl_priv *priv; @@ -126,7 +126,7 @@ int bcm283x_pinctl_probe(struct udevice *dev) /* Create GPIO device as well */ ret = device_bind(dev, lists_driver_lookup_name("gpio_bcm2835"), - "gpio_bcm2835", NULL, dev_of_offset(dev), &pdev); + "gpio_bcm2835", NULL, dev_ofnode(dev), &pdev); if (ret) { /* * While we really want the pinctrl driver to work to make @@ -149,8 +149,8 @@ U_BOOT_DRIVER(pinctrl_bcm283x) = { .name = "bcm283x_pinctrl", .id = UCLASS_PINCTRL, .of_match = of_match_ptr(bcm2835_pinctrl_id), - .ofdata_to_platdata = bcm283x_pinctl_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct bcm283x_pinctrl_priv), + .of_to_plat = bcm283x_pinctl_of_to_plat, + .priv_auto = sizeof(struct bcm283x_pinctrl_priv), .ops = &bcm283x_pinctrl_ops, .probe = bcm283x_pinctl_probe, #if CONFIG_IS_ENABLED(OF_BOARD) diff --git a/drivers/pinctrl/broadcom/pinctrl-bcm6838.c b/drivers/pinctrl/broadcom/pinctrl-bcm6838.c index 6c8a990f57..58f28a1370 100644 --- a/drivers/pinctrl/broadcom/pinctrl-bcm6838.c +++ b/drivers/pinctrl/broadcom/pinctrl-bcm6838.c @@ -157,6 +157,6 @@ U_BOOT_DRIVER(bcm6838_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = bcm6838_pinctrl_match, .ops = &bcm6838_pinctrl_ops, - .priv_auto_alloc_size = sizeof(struct bcm6838_pinctrl_priv), + .priv_auto = sizeof(struct bcm6838_pinctrl_priv), .probe = bcm6838_pinctrl_probe, }; diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c index 4cdc071d55..64d78213a8 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos.c +++ b/drivers/pinctrl/exynos/pinctrl-exynos.c @@ -133,7 +133,7 @@ int exynos_pinctrl_probe(struct udevice *dev) priv->base = base; priv->pin_ctrl = (struct samsung_pin_ctrl *)dev_get_driver_data(dev) + - dev->req_seq; + dev_seq(dev); return 0; } diff --git a/drivers/pinctrl/exynos/pinctrl-exynos7420.c b/drivers/pinctrl/exynos/pinctrl-exynos7420.c index ff6d6c4143..07870b7f51 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos7420.c +++ b/drivers/pinctrl/exynos/pinctrl-exynos7420.c @@ -110,7 +110,7 @@ U_BOOT_DRIVER(pinctrl_exynos7420) = { .name = "pinctrl_exynos7420", .id = UCLASS_PINCTRL, .of_match = exynos7420_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct exynos_pinctrl_priv), + .priv_auto = sizeof(struct exynos_pinctrl_priv), .ops = &exynos7420_pinctrl_ops, .probe = exynos_pinctrl_probe, }; diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c index e3d2464634..987a56b715 100644 --- a/drivers/pinctrl/intel/pinctrl.c +++ b/drivers/pinctrl/intel/pinctrl.c @@ -143,7 +143,7 @@ static int pinctrl_get_device(uint pad, struct udevice **devp) /* * We have to probe each one of these since the community link is only - * attached in intel_pinctrl_ofdata_to_platdata(). + * attached in intel_pinctrl_of_to_plat(). */ uclass_foreach_dev_probe(UCLASS_PINCTRL, dev) { struct intel_pinctrl_priv *priv = dev_get_priv(dev); @@ -274,7 +274,9 @@ static int pinctrl_configure_itss(struct udevice *dev, irq = pcr_read32(dev, PAD_CFG1_OFFSET(pad_cfg_offset)); irq &= PAD_CFG1_IRQ_MASK; if (!irq) { - log_err("GPIO %u doesn't support APIC routing\n", cfg->pad); + if (spl_phase() > PHASE_TPL) + log_err("GPIO %u doesn't support APIC routing\n", + cfg->pad); return -EPROTONOSUPPORT; } @@ -314,7 +316,8 @@ static int pinctrl_pad_reset_config_override(const struct pad_community *comm, return config_value; } } - log_err("Logical-to-Chipset mapping not found\n"); + if (spl_phase() > PHASE_TPL) + log_err("Logical-to-Chipset mapping not found\n"); return -ENOENT; } @@ -613,15 +616,16 @@ int pinctrl_config_pads_for_node(struct udevice *dev, ofnode node) return 0; } -int intel_pinctrl_ofdata_to_platdata(struct udevice *dev, - const struct pad_community *comm, - int num_cfgs) +int intel_pinctrl_of_to_plat(struct udevice *dev, + const struct pad_community *comm, int num_cfgs) { - struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); + struct p2sb_child_plat *pplat = dev_get_parent_plat(dev); struct intel_pinctrl_priv *priv = dev_get_priv(dev); if (!comm) { - log_err("Cannot find community for pid %d\n", pplat->pid); + if (spl_phase() > PHASE_TPL) + log_err("Cannot find community for pid %d\n", + pplat->pid); return -EDOM; } priv->comm = comm; diff --git a/drivers/pinctrl/intel/pinctrl_apl.c b/drivers/pinctrl/intel/pinctrl_apl.c index 727bacfd04..acaa55d2e7 100644 --- a/drivers/pinctrl/intel/pinctrl_apl.c +++ b/drivers/pinctrl/intel/pinctrl_apl.c @@ -17,18 +17,6 @@ #include <asm-generic/gpio.h> #include <asm/intel_pinctrl_defs.h> -/** - * struct apl_gpio_platdata - platform data for each device - * - * @dtplat: of-platdata data from C struct - */ -struct apl_gpio_platdata { -#if CONFIG_IS_ENABLED(OF_PLATDATA) - /* Put this first since driver model will copy the data here */ - struct dtd_intel_apl_pinctrl dtplat; -#endif -}; - static const struct reset_mapping rst_map[] = { { .logical = PAD_CFG0_LOGICAL_RESET_PWROK, .chipset = 0U << 30 }, { .logical = PAD_CFG0_LOGICAL_RESET_DEEP, .chipset = 1U << 30 }, @@ -136,14 +124,14 @@ static const struct pad_community apl_gpio_communities[] = { }, }; -static int apl_pinctrl_ofdata_to_platdata(struct udevice *dev) +static int apl_pinctrl_of_to_plat(struct udevice *dev) { - struct p2sb_child_platdata *pplat; + struct p2sb_child_plat *pplat; const struct pad_community *comm = NULL; int i; #if CONFIG_IS_ENABLED(OF_PLATDATA) - struct apl_gpio_platdata *plat = dev_get_platdata(dev); + struct apl_gpio_plat *plat = dev_get_plat(dev); int ret; /* @@ -152,38 +140,38 @@ static int apl_pinctrl_ofdata_to_platdata(struct udevice *dev) * linker list (i.e. alphabetical order by driver name). So the GPIO * device may well be bound before its parent (p2sb), and this call * will fail if p2sb is not bound yet. - * - * TODO(sjg@chromium.org): Add a parent pointer to child devices in dtoc */ ret = p2sb_set_port_id(dev, plat->dtplat.intel_p2sb_port_id); if (ret) return log_msg_ret("Could not set port id", ret); #endif /* Attach this device to its community structure */ - pplat = dev_get_parent_platdata(dev); + pplat = dev_get_parent_plat(dev); for (i = 0; i < ARRAY_SIZE(apl_gpio_communities); i++) { if (apl_gpio_communities[i].port == pplat->pid) comm = &apl_gpio_communities[i]; } - return intel_pinctrl_ofdata_to_platdata(dev, comm, 2); + return intel_pinctrl_of_to_plat(dev, comm, 2); } +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id apl_gpio_ids[] = { { .compatible = "intel,apl-pinctrl"}, { } }; +#endif U_BOOT_DRIVER(intel_apl_pinctrl) = { .name = "intel_apl_pinctrl", .id = UCLASS_PINCTRL, - .of_match = apl_gpio_ids, + .of_match = of_match_ptr(apl_gpio_ids), .probe = intel_pinctrl_probe, .ops = &intel_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, #endif - .ofdata_to_platdata = apl_pinctrl_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct intel_pinctrl_priv), - .platdata_auto_alloc_size = sizeof(struct apl_gpio_platdata), + .of_to_plat = apl_pinctrl_of_to_plat, + .priv_auto = sizeof(struct intel_pinctrl_priv), + .plat_auto = sizeof(struct apl_gpio_plat), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c index 1aa323c009..b413a4c7e4 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c @@ -748,7 +748,7 @@ U_BOOT_DRIVER(mt7622_pinctrl) = { .of_match = mt7622_pctrl_match, .ops = &mtk_pinctrl_ops, .probe = mtk_pinctrl_mt7622_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pinctrl_priv), + .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7623.c b/drivers/pinctrl/mediatek/pinctrl-mt7623.c index 0f5dcb2c63..2e3ae34b8b 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7623.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7623.c @@ -1411,5 +1411,5 @@ U_BOOT_DRIVER(mt7623_pinctrl) = { .of_match = mt7623_pctrl_match, .ops = &mtk_pinctrl_ops, .probe = mtk_pinctrl_mt7623_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pinctrl_priv), + .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7629.c b/drivers/pinctrl/mediatek/pinctrl-mt7629.c index 37640dd2b6..7ce64fde25 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7629.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7629.c @@ -407,5 +407,5 @@ U_BOOT_DRIVER(mt7629_pinctrl) = { .of_match = mt7629_pctrl_match, .ops = &mtk_pinctrl_ops, .probe = mtk_pinctrl_mt7629_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pinctrl_priv), + .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8512.c b/drivers/pinctrl/mediatek/pinctrl-mt8512.c index bf2a8dd90f..3d9c0abe36 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8512.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8512.c @@ -383,5 +383,5 @@ U_BOOT_DRIVER(mt8512_pinctrl) = { .of_match = mt8512_pctrl_match, .ops = &mtk_pinctrl_ops, .probe = mtk_pinctrl_mt8512_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pinctrl_priv), + .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8516.c b/drivers/pinctrl/mediatek/pinctrl-mt8516.c index 62e339e931..6f94f762d9 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8516.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8516.c @@ -389,5 +389,5 @@ U_BOOT_DRIVER(mt8516_pinctrl) = { .of_match = mt8516_pctrl_match, .ops = &mtk_pinctrl_ops, .probe = mtk_pinctrl_mt8516_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pinctrl_priv), + .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8518.c b/drivers/pinctrl/mediatek/pinctrl-mt8518.c index 91427aed4b..ed51bd3bbc 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8518.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8518.c @@ -409,5 +409,5 @@ U_BOOT_DRIVER(mt8518_pinctrl) = { .of_match = mt8518_pctrl_match, .ops = &mtk_pinctrl_ops, .probe = mtk_pinctrl_mt8518_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pinctrl_priv), + .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/meson/pinctrl-meson-axg.c b/drivers/pinctrl/meson/pinctrl-meson-axg.c index 11809b29f3..5d234bca3d 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-axg.c +++ b/drivers/pinctrl/meson/pinctrl-meson-axg.c @@ -975,6 +975,6 @@ U_BOOT_DRIVER(meson_axg_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(meson_axg_pinctrl_match), .probe = meson_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct meson_pinctrl), + .priv_auto = sizeof(struct meson_pinctrl), .ops = &meson_axg_pinctrl_ops, }; diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c index 115e8b5616..8bd265ad95 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c +++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c @@ -1289,6 +1289,6 @@ U_BOOT_DRIVER(meson_axg_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(meson_g12a_pinctrl_match), .probe = meson_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct meson_pinctrl), + .priv_auto = sizeof(struct meson_pinctrl), .ops = &meson_axg_pinctrl_ops, }; diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c index 9e2e151164..8c01c73906 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c +++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c @@ -472,6 +472,6 @@ U_BOOT_DRIVER(meson_gxbb_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(meson_gxbb_pinctrl_match), .probe = meson_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct meson_pinctrl), + .priv_auto = sizeof(struct meson_pinctrl), .ops = &meson_gx_pinctrl_ops, }; diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c b/drivers/pinctrl/meson/pinctrl-meson-gxl.c index 5acc21b9c2..51a0b4c5ca 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-gxl.c +++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c @@ -734,6 +734,6 @@ U_BOOT_DRIVER(meson_gxl_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(meson_gxl_pinctrl_match), .probe = meson_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct meson_pinctrl), + .priv_auto = sizeof(struct meson_pinctrl), .ops = &meson_gx_pinctrl_ops, }; diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 5065b62436..b11a40e11a 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -347,6 +347,7 @@ int meson_pinctrl_probe(struct udevice *dev) int na, ns; char *name; + /* FIXME: Should use livetree */ na = fdt_address_cells(gd->fdt_blob, dev_of_offset(dev->parent)); if (na < 1) { debug("bad #address-cells\n"); @@ -419,8 +420,8 @@ int meson_pinctrl_probe(struct udevice *dev) sprintf(name, "meson-gpio"); /* Create child device UCLASS_GPIO and bind it */ - device_bind(dev, priv->data->gpio_driver, name, NULL, gpio, &gpio_dev); - dev_set_of_offset(gpio_dev, gpio); + device_bind(dev, priv->data->gpio_driver, name, NULL, + offset_to_ofnode(gpio), &gpio_dev); return 0; } diff --git a/drivers/pinctrl/mscc/pinctrl-jr2.c b/drivers/pinctrl/mscc/pinctrl-jr2.c index 72a9470854..cb340581cc 100644 --- a/drivers/pinctrl/mscc/pinctrl-jr2.c +++ b/drivers/pinctrl/mscc/pinctrl-jr2.c @@ -300,7 +300,7 @@ static int jr2_pinctrl_probe(struct udevice *dev) return ret; ret = device_bind(dev, &jr2_gpio_driver, "jr2-gpio", NULL, - dev_of_offset(dev), NULL); + dev_ofnode(dev), NULL); if (ret) return ret; @@ -318,6 +318,6 @@ U_BOOT_DRIVER(jr2_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(jr2_pinctrl_of_match), .probe = jr2_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct mscc_pinctrl), + .priv_auto = sizeof(struct mscc_pinctrl), .ops = &mscc_pinctrl_ops, }; diff --git a/drivers/pinctrl/mscc/pinctrl-luton.c b/drivers/pinctrl/mscc/pinctrl-luton.c index 17fbc53c25..325c9a9705 100644 --- a/drivers/pinctrl/mscc/pinctrl-luton.c +++ b/drivers/pinctrl/mscc/pinctrl-luton.c @@ -166,7 +166,7 @@ int luton_pinctrl_probe(struct udevice *dev) return ret; ret = device_bind(dev, &luton_gpio_driver, "luton-gpio", NULL, - dev_of_offset(dev), NULL); + dev_ofnode(dev), NULL); return 0; } @@ -181,6 +181,6 @@ U_BOOT_DRIVER(luton_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(luton_pinctrl_of_match), .probe = luton_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct mscc_pinctrl), + .priv_auto = sizeof(struct mscc_pinctrl), .ops = &mscc_pinctrl_ops, }; diff --git a/drivers/pinctrl/mscc/pinctrl-ocelot.c b/drivers/pinctrl/mscc/pinctrl-ocelot.c index 49e026bc98..57e2ef0d7c 100644 --- a/drivers/pinctrl/mscc/pinctrl-ocelot.c +++ b/drivers/pinctrl/mscc/pinctrl-ocelot.c @@ -182,7 +182,7 @@ int ocelot_pinctrl_probe(struct udevice *dev) return ret; ret = device_bind(dev, &ocelot_gpio_driver, "ocelot-gpio", NULL, - dev_of_offset(dev), NULL); + dev_ofnode(dev), NULL); return ret; } @@ -197,6 +197,6 @@ U_BOOT_DRIVER(ocelot_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(ocelot_pinctrl_of_match), .probe = ocelot_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct mscc_pinctrl), + .priv_auto = sizeof(struct mscc_pinctrl), .ops = &mscc_pinctrl_ops, }; diff --git a/drivers/pinctrl/mscc/pinctrl-serval.c b/drivers/pinctrl/mscc/pinctrl-serval.c index d59f08d4eb..a6b9796df8 100644 --- a/drivers/pinctrl/mscc/pinctrl-serval.c +++ b/drivers/pinctrl/mscc/pinctrl-serval.c @@ -210,7 +210,7 @@ static int serval_pinctrl_probe(struct udevice *dev) return ret; ret = device_bind(dev, &serval_gpio_driver, "serval-gpio", NULL, - dev_of_offset(dev), NULL); + dev_ofnode(dev), NULL); if (ret) return ret; @@ -228,6 +228,6 @@ U_BOOT_DRIVER(serval_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(serval_pinctrl_of_match), .probe = serval_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct mscc_pinctrl), + .priv_auto = sizeof(struct mscc_pinctrl), .ops = &mscc_pinctrl_ops, }; diff --git a/drivers/pinctrl/mscc/pinctrl-servalt.c b/drivers/pinctrl/mscc/pinctrl-servalt.c index 592b7c547b..8e8678580d 100644 --- a/drivers/pinctrl/mscc/pinctrl-servalt.c +++ b/drivers/pinctrl/mscc/pinctrl-servalt.c @@ -246,7 +246,7 @@ static int servalt_pinctrl_probe(struct udevice *dev) return ret; ret = device_bind(dev, &servalt_gpio_driver, "servalt-gpio", NULL, - dev_of_offset(dev), NULL); + dev_ofnode(dev), NULL); if (ret) return ret; @@ -264,6 +264,6 @@ U_BOOT_DRIVER(servalt_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(servalt_pinctrl_of_match), .probe = servalt_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct mscc_pinctrl), + .priv_auto = sizeof(struct mscc_pinctrl), .ops = &mscc_pinctrl_ops, }; diff --git a/drivers/pinctrl/mtmips/pinctrl-mt7628.c b/drivers/pinctrl/mtmips/pinctrl-mt7628.c index fc9d8b5ad1..c15da6be0e 100644 --- a/drivers/pinctrl/mtmips/pinctrl-mt7628.c +++ b/drivers/pinctrl/mtmips/pinctrl-mt7628.c @@ -534,7 +534,7 @@ static int mt7628_pinctrl_probe(struct udevice *dev) return ret; } -static int mt7628_pinctrl_ofdata_to_platdata(struct udevice *dev) +static int mt7628_pinctrl_of_to_plat(struct udevice *dev) { struct mt7628_pinctrl_priv *priv = dev_get_priv(dev); @@ -578,8 +578,8 @@ U_BOOT_DRIVER(mt7628_pinctrl) = { .name = "mt7628-pinctrl", .id = UCLASS_PINCTRL, .of_match = mt7628_pinctrl_ids, - .ofdata_to_platdata = mt7628_pinctrl_ofdata_to_platdata, + .of_to_plat = mt7628_pinctrl_of_to_plat, .ops = &mt7628_pinctrl_ops, .probe = mt7628_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct mt7628_pinctrl_priv), + .priv_auto = sizeof(struct mt7628_pinctrl_priv), }; diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index fb497803b9..4797d3250f 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -547,13 +547,14 @@ static int armada_37xx_gpiochip_register(struct udevice *parent, int subnode; char *name; - /* Lookup GPIO driver */ + /* FIXME: Should not need to lookup GPIO uclass */ drv = lists_uclass_lookup(UCLASS_GPIO); if (!drv) { puts("Cannot find GPIO driver\n"); return -ENOENT; } + /* FIXME: Use livtree and check the result of device_bind() below */ fdt_for_each_subnode(subnode, blob, node) { if (fdtdec_get_bool(blob, subnode, "gpio-controller")) { ret = 0; @@ -567,9 +568,8 @@ static int armada_37xx_gpiochip_register(struct udevice *parent, sprintf(name, "armada-37xx-gpio"); /* Create child device UCLASS_GPIO and bind it */ - device_bind(parent, &armada_37xx_gpio_driver, name, NULL, subnode, - &dev); - dev_set_of_offset(dev, subnode); + device_bind(parent, &armada_37xx_gpio_driver, name, NULL, + offset_to_ofnode(subnode), &dev); return 0; } @@ -643,6 +643,6 @@ U_BOOT_DRIVER(armada_37xx_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(armada_37xx_pinctrl_of_match), .probe = armada_37xx_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct armada_37xx_pinctrl), + .priv_auto = sizeof(struct armada_37xx_pinctrl), .ops = &armada_37xx_pinctrl_ops, }; diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 146f5c6e42..5ced4fea88 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -229,7 +229,7 @@ U_BOOT_DRIVER(pinctrl_mvebu) = { .name = "mvebu_pinctrl", .id = UCLASS_PINCTRL, .of_match = mvebu_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct mvebu_pinctrl_priv), + .priv_auto = sizeof(struct mvebu_pinctrl_priv), .ops = &mvebu_pinctrl_ops, .probe = mvebu_pinctl_probe }; diff --git a/drivers/pinctrl/nexell/pinctrl-s5pxx18.c b/drivers/pinctrl/nexell/pinctrl-s5pxx18.c index 96a2ed38a0..adc687a3b5 100644 --- a/drivers/pinctrl/nexell/pinctrl-s5pxx18.c +++ b/drivers/pinctrl/nexell/pinctrl-s5pxx18.c @@ -213,7 +213,7 @@ U_BOOT_DRIVER(pinctrl_s5pxx18) = { .name = "pinctrl_s5pxx18", .id = UCLASS_PINCTRL, .of_match = s5pxx18_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct nexell_pinctrl_priv), + .priv_auto = sizeof(struct nexell_pinctrl_priv), .ops = &s5pxx18_pinctrl_ops, .probe = nexell_pinctrl_probe, .flags = DM_FLAG_PRE_RELOC diff --git a/drivers/pinctrl/nxp/pinctrl-imx5.c b/drivers/pinctrl/nxp/pinctrl-imx5.c index 9c3423bef3..71e0c94c96 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx5.c +++ b/drivers/pinctrl/nxp/pinctrl-imx5.c @@ -38,7 +38,7 @@ U_BOOT_DRIVER(imx5_pinctrl) = { .of_match = of_match_ptr(imx5_pinctrl_match), .probe = imx5_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c index 84004e5921..6994dbb61a 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx6.c +++ b/drivers/pinctrl/nxp/pinctrl-imx6.c @@ -47,9 +47,9 @@ U_BOOT_DRIVER(fsl_imx6q_iomuxc) = { .of_match = of_match_ptr(imx6_pinctrl_match), .probe = imx6_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DRIVER_ALIAS(fsl_imx6q_iomuxc, fsl_imx6dl_iomuxc) +DM_DRIVER_ALIAS(fsl_imx6q_iomuxc, fsl_imx6dl_iomuxc) diff --git a/drivers/pinctrl/nxp/pinctrl-imx7.c b/drivers/pinctrl/nxp/pinctrl-imx7.c index 66b58ba472..8301413ac7 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx7.c +++ b/drivers/pinctrl/nxp/pinctrl-imx7.c @@ -35,7 +35,7 @@ U_BOOT_DRIVER(imx7_pinctrl) = { .of_match = of_match_ptr(imx7_pinctrl_match), .probe = imx7_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c index 598bbfaf35..da0f6c9ba0 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c +++ b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c @@ -39,7 +39,7 @@ U_BOOT_DRIVER(imx7ulp_pinctrl) = { .of_match = of_match_ptr(imx7ulp_pinctrl_match), .probe = imx7ulp_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx8.c b/drivers/pinctrl/nxp/pinctrl-imx8.c index c1b0ca438a..2e5db2c6c2 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx8.c +++ b/drivers/pinctrl/nxp/pinctrl-imx8.c @@ -35,7 +35,7 @@ U_BOOT_DRIVER(imx8_pinctrl) = { .of_match = of_match_ptr(imx8_pinctrl_match), .probe = imx8_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx8m.c b/drivers/pinctrl/nxp/pinctrl-imx8m.c index 0626fde58f..99c6d014d6 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx8m.c +++ b/drivers/pinctrl/nxp/pinctrl-imx8m.c @@ -32,7 +32,7 @@ U_BOOT_DRIVER(imx8mq_pinctrl) = { .of_match = of_match_ptr(imx8m_pinctrl_match), .probe = imx8mq_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pinctrl/nxp/pinctrl-imxrt.c b/drivers/pinctrl/nxp/pinctrl-imxrt.c index 4a93941927..53b70da869 100644 --- a/drivers/pinctrl/nxp/pinctrl-imxrt.c +++ b/drivers/pinctrl/nxp/pinctrl-imxrt.c @@ -34,7 +34,7 @@ U_BOOT_DRIVER(imxrt_pinctrl) = { .of_match = of_match_ptr(imxrt_pinctrl_match), .probe = imxrt_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pinctrl/nxp/pinctrl-mxs.c b/drivers/pinctrl/nxp/pinctrl-mxs.c index db463fc04b..449a0aa8b5 100644 --- a/drivers/pinctrl/nxp/pinctrl-mxs.c +++ b/drivers/pinctrl/nxp/pinctrl-mxs.c @@ -188,8 +188,8 @@ U_BOOT_DRIVER(fsl_imx23_pinctrl) = { #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, #endif - .priv_auto_alloc_size = sizeof(struct mxs_pinctrl_priv), + .priv_auto = sizeof(struct mxs_pinctrl_priv), .ops = &mxs_pinctrl_ops, }; -U_BOOT_DRIVER_ALIAS(fsl_imx23_pinctrl, fsl_imx28_pinctrl) +DM_DRIVER_ALIAS(fsl_imx23_pinctrl, fsl_imx28_pinctrl) diff --git a/drivers/pinctrl/nxp/pinctrl-vf610.c b/drivers/pinctrl/nxp/pinctrl-vf610.c index e795b5fd8a..14e2e9d3ee 100644 --- a/drivers/pinctrl/nxp/pinctrl-vf610.c +++ b/drivers/pinctrl/nxp/pinctrl-vf610.c @@ -34,7 +34,7 @@ U_BOOT_DRIVER(vf610_pinctrl) = { .of_match = of_match_ptr(vf610_pinctrl_match), .probe = vf610_pinctrl_probe, .remove = imx_pinctrl_remove, - .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), + .priv_auto = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index bf85cc916a..1aba8a9150 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR; * framework groups, Atmel PIO groups will be called banks. */ -struct atmel_pio4_platdata { +struct atmel_pio4_plat { struct atmel_pio4_port *reg_base; }; @@ -95,7 +95,7 @@ static u32 atmel_pinctrl_get_pinconf(const void *blob, int node) static inline struct atmel_pio4_port *atmel_pio4_bank_base(struct udevice *dev, u32 bank) { - struct atmel_pio4_platdata *plat = dev_get_platdata(dev); + struct atmel_pio4_plat *plat = dev_get_plat(dev); struct atmel_pio4_port *bank_base = (struct atmel_pio4_port *)((u32)plat->reg_base + ATMEL_PIO_BANK_OFFSET * bank); @@ -154,7 +154,7 @@ const struct pinctrl_ops atmel_pinctrl_ops = { static int atmel_pinctrl_probe(struct udevice *dev) { - struct atmel_pio4_platdata *plat = dev_get_platdata(dev); + struct atmel_pio4_plat *plat = dev_get_plat(dev); fdt_addr_t addr_base; dev = dev_get_parent(dev); @@ -178,6 +178,6 @@ U_BOOT_DRIVER(atmel_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = atmel_pinctrl_match, .probe = atmel_pinctrl_probe, - .platdata_auto_alloc_size = sizeof(struct atmel_pio4_platdata), + .plat_auto = sizeof(struct atmel_pio4_plat), .ops = &atmel_pinctrl_ops, }; diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index cd7b32ce34..ddaad55ddc 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -524,8 +524,8 @@ U_BOOT_DRIVER(atmel_sama5d3_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = at91_pinctrl_match, .probe = at91_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct at91_pinctrl_priv), + .priv_auto = sizeof(struct at91_pinctrl_priv), .ops = &at91_pinctrl_ops, }; -U_BOOT_DRIVER_ALIAS(atmel_sama5d3_pinctrl, atmel_at91rm9200_pinctrl) +DM_DRIVER_ALIAS(atmel_sama5d3_pinctrl, atmel_at91rm9200_pinctrl) diff --git a/drivers/pinctrl/pinctrl-kendryte.c b/drivers/pinctrl/pinctrl-kendryte.c index 04162016cc..09d51ca676 100644 --- a/drivers/pinctrl/pinctrl-kendryte.c +++ b/drivers/pinctrl/pinctrl-kendryte.c @@ -735,6 +735,6 @@ U_BOOT_DRIVER(pinctrl_k210) = { .id = UCLASS_PINCTRL, .of_match = k210_pc_ids, .probe = k210_pc_probe, - .priv_auto_alloc_size = sizeof(struct k210_pc_priv), + .priv_auto = sizeof(struct k210_pc_priv), .ops = &k210_pc_pinctrl_ops, }; diff --git a/drivers/pinctrl/pinctrl-qe-io.c b/drivers/pinctrl/pinctrl-qe-io.c index 85521eabd4..e129ab2f83 100644 --- a/drivers/pinctrl/pinctrl-qe-io.c +++ b/drivers/pinctrl/pinctrl-qe-io.c @@ -18,12 +18,12 @@ #include <linux/ioport.h> /** - * struct qe_io_platdata + * struct qe_io_plat * * @base: Base register address * @num_par_io_ports number of io ports */ -struct qe_io_platdata { +struct qe_io_plat { qepio83xx_t *base; u32 num_io_ports; }; @@ -120,9 +120,9 @@ void qe_config_iopin(u8 port, u8 pin, int dir, int open_drain, int assign) qe_cfg_iopin(par_io, port, pin, dir, open_drain, assign); } #else -static int qe_io_ofdata_to_platdata(struct udevice *dev) +static int qe_io_of_to_plat(struct udevice *dev) { - struct qe_io_platdata *plat = dev->platdata; + struct qe_io_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -143,7 +143,7 @@ static int qe_io_ofdata_to_platdata(struct udevice *dev) */ static int par_io_of_config_node(struct udevice *dev, ofnode pio) { - struct qe_io_platdata *plat = dev->platdata; + struct qe_io_plat *plat = dev_get_plat(dev); qepio83xx_t *par_io = plat->base; const unsigned int *pio_map; int pio_map_len; @@ -245,8 +245,8 @@ U_BOOT_DRIVER(par_io_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(par_io_pinctrl_match), .probe = par_io_pinctrl_probe, - .ofdata_to_platdata = qe_io_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct qe_io_platdata), + .of_to_plat = qe_io_of_to_plat, + .plat_auto = sizeof(struct qe_io_plat), .ops = &par_io_pinctrl_ops, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/pinctrl/pinctrl-sandbox.c b/drivers/pinctrl/pinctrl-sandbox.c index d27f74248d..7765977450 100644 --- a/drivers/pinctrl/pinctrl-sandbox.c +++ b/drivers/pinctrl/pinctrl-sandbox.c @@ -296,6 +296,6 @@ U_BOOT_DRIVER(sandbox_pinctrl) = { .name = "sandbox_pinctrl", .id = UCLASS_PINCTRL, .of_match = sandbox_pinctrl_match, - .priv_auto_alloc_size = sizeof(struct sandbox_pinctrl_priv), + .priv_auto = sizeof(struct sandbox_pinctrl_priv), .ops = &sandbox_pinctrl_ops, }; diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 738f5bd636..20c3c82aa9 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -47,7 +47,7 @@ static int single_configure_pins(struct udevice *dev, const struct single_fdt_pin_cfg *pins, int size) { - struct single_pdata *pdata = dev->platdata; + struct single_pdata *pdata = dev_get_plat(dev); int count = size / sizeof(struct single_fdt_pin_cfg); phys_addr_t n, reg; u32 val; @@ -81,7 +81,7 @@ static int single_configure_bits(struct udevice *dev, const struct single_fdt_bits_cfg *pins, int size) { - struct single_pdata *pdata = dev->platdata; + struct single_pdata *pdata = dev_get_plat(dev); int count = size / sizeof(struct single_fdt_bits_cfg); phys_addr_t n, reg; u32 val, mask; @@ -148,12 +148,12 @@ static int single_set_state(struct udevice *dev, return len; } -static int single_ofdata_to_platdata(struct udevice *dev) +static int single_of_to_plat(struct udevice *dev) { fdt_addr_t addr; u32 of_reg[2]; int res; - struct single_pdata *pdata = dev->platdata; + struct single_pdata *pdata = dev_get_plat(dev); pdata->width = dev_read_u32_default(dev, "pinctrl-single,register-width", 0); @@ -191,6 +191,6 @@ U_BOOT_DRIVER(single_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = single_pinctrl_match, .ops = &single_pinctrl_ops, - .platdata_auto_alloc_size = sizeof(struct single_pdata), - .ofdata_to_platdata = single_ofdata_to_platdata, + .plat_auto = sizeof(struct single_pdata), + .of_to_plat = single_of_to_plat, }; diff --git a/drivers/pinctrl/pinctrl-sti.c b/drivers/pinctrl/pinctrl-sti.c index 2f3ee00453..c5baf5d211 100644 --- a/drivers/pinctrl/pinctrl-sti.c +++ b/drivers/pinctrl/pinctrl-sti.c @@ -41,7 +41,7 @@ DECLARE_GLOBAL_DATA_PTR; /* oe = 1, pu = 1, od = 1 */ #define BIDIR_PU (OE | PU | OD) -struct sti_pinctrl_platdata { +struct sti_pinctrl_plat { struct regmap *regmap; }; @@ -57,7 +57,7 @@ struct sti_pin_desc { */ void sti_alternate_select(struct udevice *dev, struct sti_pin_desc *pin_desc) { - struct sti_pinctrl_platdata *plat = dev_get_platdata(dev); + struct sti_pinctrl_plat *plat = dev_get_plat(dev); unsigned long sysconf, *sysconfreg; int alt = pin_desc->alt; int bank = pin_desc->bank; @@ -91,7 +91,7 @@ void sti_alternate_select(struct udevice *dev, struct sti_pin_desc *pin_desc) /* pin configuration */ void sti_pin_configure(struct udevice *dev, struct sti_pin_desc *pin_desc) { - struct sti_pinctrl_platdata *plat = dev_get_platdata(dev); + struct sti_pinctrl_plat *plat = dev_get_plat(dev); int bit; int oe = 0, pu = 0, od = 0; unsigned long *sysconfreg; @@ -277,7 +277,7 @@ static int sti_pinctrl_set_state(struct udevice *dev, struct udevice *config) static int sti_pinctrl_probe(struct udevice *dev) { - struct sti_pinctrl_platdata *plat = dev_get_platdata(dev); + struct sti_pinctrl_plat *plat = dev_get_plat(dev); struct udevice *syscon; int err; @@ -316,6 +316,6 @@ U_BOOT_DRIVER(pinctrl_sti) = { .of_match = sti_pinctrl_ids, .ops = &sti_pinctrl_ops, .probe = sti_pinctrl_probe, - .platdata_auto_alloc_size = sizeof(struct sti_pinctrl_platdata), + .plat_auto = sizeof(struct sti_pinctrl_plat), .ops = &sti_pinctrl_ops, }; diff --git a/drivers/pinctrl/pinctrl-stmfx.c b/drivers/pinctrl/pinctrl-stmfx.c index a62be44d2d..7cf08dbddd 100644 --- a/drivers/pinctrl/pinctrl-stmfx.c +++ b/drivers/pinctrl/pinctrl-stmfx.c @@ -293,7 +293,7 @@ static int stmfx_pinctrl_conf_set(struct udevice *dev, unsigned int pin, unsigned int param, unsigned int arg) { int ret, dir; - struct stmfx_pinctrl *plat = dev_get_platdata(dev); + struct stmfx_pinctrl *plat = dev_get_plat(dev); dir = stmfx_gpio_get_function(plat->gpio, pin); @@ -334,7 +334,7 @@ static int stmfx_pinctrl_conf_set(struct udevice *dev, unsigned int pin, static int stmfx_pinctrl_get_pins_count(struct udevice *dev) { - struct stmfx_pinctrl *plat = dev_get_platdata(dev); + struct stmfx_pinctrl *plat = dev_get_plat(dev); struct gpio_dev_priv *uc_priv; uc_priv = dev_get_uclass_priv(plat->gpio); @@ -390,7 +390,7 @@ static int stmfx_pinctrl_get_pin_muxing(struct udevice *dev, unsigned int selector, char *buf, int size) { - struct stmfx_pinctrl *plat = dev_get_platdata(dev); + struct stmfx_pinctrl *plat = dev_get_plat(dev); int func; func = stmfx_gpio_get_function(plat->gpio, selector); @@ -406,7 +406,7 @@ static int stmfx_pinctrl_get_pin_muxing(struct udevice *dev, static int stmfx_pinctrl_bind(struct udevice *dev) { - struct stmfx_pinctrl *plat = dev_get_platdata(dev); + struct stmfx_pinctrl *plat = dev_get_plat(dev); /* subnode name is not explicit: use father name */ device_set_name(dev, dev->parent->name); @@ -418,7 +418,7 @@ static int stmfx_pinctrl_bind(struct udevice *dev) static int stmfx_pinctrl_probe(struct udevice *dev) { - struct stmfx_pinctrl *plat = dev_get_platdata(dev); + struct stmfx_pinctrl *plat = dev_get_plat(dev); return device_probe(plat->gpio); }; @@ -446,7 +446,7 @@ U_BOOT_DRIVER(stmfx_pinctrl) = { .bind = stmfx_pinctrl_bind, .probe = stmfx_pinctrl_probe, .ops = &stmfx_pinctrl_ops, - .platdata_auto_alloc_size = sizeof(struct stmfx_pinctrl), + .plat_auto = sizeof(struct stmfx_pinctrl), }; static int stmfx_chip_init(struct udevice *dev) @@ -454,7 +454,7 @@ static int stmfx_chip_init(struct udevice *dev) u8 id; u8 version[2]; int ret; - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); ret = dm_i2c_reg_read(dev, STMFX_REG_CHIP_ID); if (ret < 0) { diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c index aba8810474..7919e54e8d 100644 --- a/drivers/pinctrl/pinctrl-uclass.c +++ b/drivers/pinctrl/pinctrl-uclass.c @@ -112,7 +112,7 @@ static int pinconfig_post_bind(struct udevice *dev) ofnode node; int ret; - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; dev_for_each_subnode(node, dev) { @@ -305,7 +305,7 @@ int pinctrl_select_state(struct udevice *dev, const char *statename) * Some device which is logical like mmc.blk, do not have * a valid ofnode. */ - if (!ofnode_valid(dev->node)) + if (!dev_has_ofnode(dev)) return 0; /* * Try full-implemented pinctrl first. @@ -416,7 +416,9 @@ static int __maybe_unused pinctrl_post_bind(struct udevice *dev) UCLASS_DRIVER(pinctrl) = { .id = UCLASS_PINCTRL, +#if !CONFIG_IS_ENABLED(OF_PLATDATA) .post_bind = pinctrl_post_bind, +#endif .flags = DM_UC_FLAG_SEQ_ALIAS, .name = "pinctrl", }; diff --git a/drivers/pinctrl/pinctrl_pic32.c b/drivers/pinctrl/pinctrl_pic32.c index 899c279975..a19758d59d 100644 --- a/drivers/pinctrl/pinctrl_pic32.c +++ b/drivers/pinctrl/pinctrl_pic32.c @@ -381,5 +381,5 @@ U_BOOT_DRIVER(pinctrl_pic32) = { .ops = &pic32_pinctrl_ops, .probe = pic32_pinctrl_probe, .bind = dm_scan_fdt_dev, - .priv_auto_alloc_size = sizeof(struct pic32_pinctrl_priv), + .priv_auto = sizeof(struct pic32_pinctrl_priv), }; diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c index 262b2c3d7e..591cd1a0ec 100644 --- a/drivers/pinctrl/pinctrl_stm32.c +++ b/drivers/pinctrl/pinctrl_stm32.c @@ -500,5 +500,5 @@ U_BOOT_DRIVER(pinctrl_stm32) = { .ops = &stm32_pinctrl_ops, .bind = stm32_pinctrl_bind, .probe = stm32_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct stm32_pinctrl_priv), + .priv_auto = sizeof(struct stm32_pinctrl_priv), }; diff --git a/drivers/pinctrl/renesas/pfc-r7s72100.c b/drivers/pinctrl/renesas/pfc-r7s72100.c index 9d7814a5f2..82bdf05b24 100644 --- a/drivers/pinctrl/renesas/pfc-r7s72100.c +++ b/drivers/pinctrl/renesas/pfc-r7s72100.c @@ -32,14 +32,14 @@ DECLARE_GLOBAL_DATA_PTR; -struct r7s72100_pfc_platdata { +struct r7s72100_pfc_plat { void __iomem *base; }; static void r7s72100_pfc_set_function(struct udevice *dev, u16 bank, u16 line, u16 func, u16 inbuf, u16 bidir) { - struct r7s72100_pfc_platdata *plat = dev_get_platdata(dev); + struct r7s72100_pfc_plat *plat = dev_get_plat(dev); clrsetbits_le16(plat->base + PFCAE(bank), BIT(line), (func & BIT(2)) ? BIT(line) : 0); @@ -108,7 +108,7 @@ const struct pinctrl_ops r7s72100_pfc_ops = { static int r7s72100_pfc_probe(struct udevice *dev) { - struct r7s72100_pfc_platdata *plat = dev_get_platdata(dev); + struct r7s72100_pfc_plat *plat = dev_get_plat(dev); fdt_addr_t addr_base; ofnode node; @@ -142,6 +142,6 @@ U_BOOT_DRIVER(r7s72100_pfc) = { .id = UCLASS_PINCTRL, .of_match = r7s72100_pfc_match, .probe = r7s72100_pfc_probe, - .platdata_auto_alloc_size = sizeof(struct r7s72100_pfc_platdata), + .plat_auto = sizeof(struct r7s72100_pfc_plat), .ops = &r7s72100_pfc_ops, }; diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c index fb811a95bc..8bb7e16f94 100644 --- a/drivers/pinctrl/renesas/pfc.c +++ b/drivers/pinctrl/renesas/pfc.c @@ -990,7 +990,7 @@ U_BOOT_DRIVER(pinctrl_sh_pfc) = { .name = "sh_pfc_pinctrl", .id = UCLASS_PINCTRL, .of_match = sh_pfc_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct sh_pfc_pinctrl_priv), + .priv_auto = sizeof(struct sh_pfc_pinctrl_priv), .ops = &sh_pfc_pinctrl_ops, .probe = sh_pfc_pinctrl_probe, }; diff --git a/drivers/pinctrl/rockchip/pinctrl-px30.c b/drivers/pinctrl/rockchip/pinctrl-px30.c index 617721a626..6058d0f4c1 100644 --- a/drivers/pinctrl/rockchip/pinctrl-px30.c +++ b/drivers/pinctrl/rockchip/pinctrl-px30.c @@ -361,7 +361,7 @@ U_BOOT_DRIVER(pinctrl_px30) = { .name = "rockchip_px30_pinctrl", .id = UCLASS_PINCTRL, .of_match = px30_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3036.c b/drivers/pinctrl/rockchip/pinctrl-rk3036.c index d49e3007ce..9ccee465b0 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3036.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3036.c @@ -101,7 +101,7 @@ U_BOOT_DRIVER(pinctrl_rockchip) = { .name = "rk3036-pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3036_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3128.c b/drivers/pinctrl/rockchip/pinctrl-rk3128.c index a175d6c07f..85c2e611b6 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3128.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3128.c @@ -203,7 +203,7 @@ U_BOOT_DRIVER(pinctrl_rk3128) = { .name = "pinctrl_rk3128", .id = UCLASS_PINCTRL, .of_match = rk3128_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3188.c b/drivers/pinctrl/rockchip/pinctrl-rk3188.c index 8f197110e5..06d53e22d2 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3188.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3188.c @@ -124,7 +124,7 @@ U_BOOT_DRIVER(rockchip_rk3188_pinctrl) = { .name = "rockchip_rk3188_pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3188_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk322x.c b/drivers/pinctrl/rockchip/pinctrl-rk322x.c index 85bc0ef0f3..fe386933c5 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk322x.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk322x.c @@ -290,7 +290,7 @@ U_BOOT_DRIVER(pinctrl_rk3228) = { .name = "rockchip_rk3228_pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3228_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3288.c b/drivers/pinctrl/rockchip/pinctrl-rk3288.c index 011ca286ec..fc2810248b 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3288.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3288.c @@ -246,7 +246,7 @@ U_BOOT_DRIVER(rockchip_rk3288_pinctrl) = { .name = "rockchip_rk3288_pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3288_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3308.c b/drivers/pinctrl/rockchip/pinctrl-rk3308.c index db2b10a690..a9b87b7457 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3308.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3308.c @@ -457,7 +457,7 @@ U_BOOT_DRIVER(pinctrl_rk3308) = { .name = "rockchip_rk3308_pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3308_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3328.c b/drivers/pinctrl/rockchip/pinctrl-rk3328.c index 61eb9e0af0..aa8bd76d6f 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3328.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3328.c @@ -321,7 +321,7 @@ U_BOOT_DRIVER(rockchip_rk3328_pinctrl) = { .name = "rockchip_rk3328_pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3328_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3368.c b/drivers/pinctrl/rockchip/pinctrl-rk3368.c index d8ccd4de57..18d3e3a9b5 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3368.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3368.c @@ -175,7 +175,7 @@ U_BOOT_DRIVER(rockchip_rk3368_pinctrl) = { .name = "rockchip_rk3368_pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3368_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rk3399.c b/drivers/pinctrl/rockchip/pinctrl-rk3399.c index d04c1afb09..0c1adc3794 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rk3399.c +++ b/drivers/pinctrl/rockchip/pinctrl-rk3399.c @@ -315,7 +315,7 @@ U_BOOT_DRIVER(pinctrl_rk3399) = { .name = "rockchip_rk3399_pinctrl", .id = UCLASS_PINCTRL, .of_match = rk3399_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/rockchip/pinctrl-rv1108.c b/drivers/pinctrl/rockchip/pinctrl-rv1108.c index 22334329ed..d35425b5fa 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rv1108.c +++ b/drivers/pinctrl/rockchip/pinctrl-rv1108.c @@ -289,7 +289,7 @@ U_BOOT_DRIVER(pinctrl_rv1108) = { .name = "pinctrl_rv1108", .id = UCLASS_PINCTRL, .of_match = rv1108_pinctrl_ids, - .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv), + .priv_auto = sizeof(struct rockchip_pinctrl_priv), .ops = &rockchip_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .bind = dm_scan_fdt_dev, diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c index 5efaa2f66b..a1a3cd7385 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld11.c @@ -119,6 +119,6 @@ U_BOOT_DRIVER(uniphier_ld11_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_ld11_pinctrl_match), .probe = uniphier_ld11_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c index d3c5833c99..7a92a46c17 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c @@ -152,6 +152,6 @@ U_BOOT_DRIVER(uniphier_ld20_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_ld20_pinctrl_match), .probe = uniphier_ld20_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c index bf1a9e9e98..d33e4d7dd2 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld4.c @@ -142,6 +142,6 @@ U_BOOT_DRIVER(uniphier_ld4_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_ld4_pinctrl_match), .probe = uniphier_ld4_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c index f22c046804..0e3eb131ec 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-ld6b.c @@ -153,6 +153,6 @@ U_BOOT_DRIVER(uniphier_ld6b_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_ld6b_pinctrl_match), .probe = uniphier_ld6b_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c index 8bae163a8e..7ba2266092 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c @@ -177,7 +177,7 @@ U_BOOT_DRIVER(uniphier_pro4_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_pro4_pinctrl_match), .probe = uniphier_pro4_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c index 1f4931bcf0..9ce2e2c270 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c @@ -163,7 +163,7 @@ U_BOOT_DRIVER(uniphier_pro5_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_pro5_pinctrl_match), .probe = uniphier_pro5_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c index 038a7dd7be..e8c2018097 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs2.c @@ -157,6 +157,6 @@ U_BOOT_DRIVER(uniphier_pxs2_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_pxs2_pinctrl_match), .probe = uniphier_pxs2_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c index 452d76d721..1fc7bdb5c8 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pxs3.c @@ -144,6 +144,6 @@ U_BOOT_DRIVER(uniphier_pxs3_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_pxs3_pinctrl_match), .probe = uniphier_pxs3_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c index 1e38ba16f9..04c06fb280 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-sld8.c @@ -139,6 +139,6 @@ U_BOOT_DRIVER(uniphier_sld8_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(uniphier_sld8_pinctrl_match), .probe = uniphier_sld8_pinctrl_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), + .priv_auto = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, }; diff --git a/drivers/power/acpi_pmc/acpi-pmc-uclass.c b/drivers/power/acpi_pmc/acpi-pmc-uclass.c index 828963d8a0..34446a34e6 100644 --- a/drivers/power/acpi_pmc/acpi-pmc-uclass.c +++ b/drivers/power/acpi_pmc/acpi-pmc-uclass.c @@ -8,6 +8,7 @@ #include <common.h> #include <dm.h> #include <log.h> +#include <spl.h> #include <acpi/acpi_s3.h> #ifdef CONFIG_X86 #include <asm/intel_pinctrl.h> @@ -60,7 +61,8 @@ int pmc_gpe_init(struct udevice *dev) * are different and if they aren't, use the reset values. */ if (dw[0] == dw[1] || dw[1] == dw[2]) { - log_info("PMC: Using default GPE route"); + if (spl_phase() > PHASE_TPL) + log_info("PMC: Using default GPE route"); gpio_cfg = readl(upriv->gpe_cfg); for (i = 0; i < upriv->gpe0_count; i++) dw[i] = gpio_cfg >> gpe0_shift(upriv, i); @@ -204,7 +206,7 @@ void pmc_dump_info(struct udevice *dev) upriv->gen_pmcon1, upriv->gen_pmcon2, upriv->gen_pmcon3); } -int pmc_ofdata_to_uc_platdata(struct udevice *dev) +int pmc_ofdata_to_uc_plat(struct udevice *dev) { struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev); int ret; @@ -231,5 +233,5 @@ int pmc_ofdata_to_uc_platdata(struct udevice *dev) UCLASS_DRIVER(acpi_pmc) = { .id = UCLASS_ACPI_PMC, .name = "power-mgr", - .per_device_auto_alloc_size = sizeof(struct acpi_pmc_upriv), + .per_device_auto = sizeof(struct acpi_pmc_upriv), }; diff --git a/drivers/power/acpi_pmc/pmc_emul.c b/drivers/power/acpi_pmc/pmc_emul.c index 5ed6fcca26..a61eb5bd85 100644 --- a/drivers/power/acpi_pmc/pmc_emul.c +++ b/drivers/power/acpi_pmc/pmc_emul.c @@ -14,12 +14,12 @@ #include <power/acpi_pmc.h> /** - * struct pmc_emul_platdata - platform data for this device + * struct pmc_emul_plat - platform data for this device * * @command: Current PCI command value * @bar: Current base address values */ -struct pmc_emul_platdata { +struct pmc_emul_plat { u16 command; u32 bar[6]; }; @@ -46,7 +46,7 @@ struct pmc_emul_priv { static int sandbox_pmc_emul_read_config(const struct udevice *emul, uint offset, ulong *valuep, enum pci_size_t size) { - struct pmc_emul_platdata *plat = dev_get_platdata(emul); + struct pmc_emul_plat *plat = dev_get_plat(emul); switch (offset) { case PCI_COMMAND: @@ -99,7 +99,7 @@ static int sandbox_pmc_emul_read_config(const struct udevice *emul, uint offset, static int sandbox_pmc_emul_write_config(struct udevice *emul, uint offset, ulong value, enum pci_size_t size) { - struct pmc_emul_platdata *plat = dev_get_platdata(emul); + struct pmc_emul_plat *plat = dev_get_plat(emul); switch (offset) { case PCI_COMMAND: @@ -127,7 +127,7 @@ static int sandbox_pmc_emul_write_config(struct udevice *emul, uint offset, static int sandbox_pmc_emul_find_bar(struct udevice *emul, unsigned int addr, int *barnump, unsigned int *offsetp) { - struct pmc_emul_platdata *plat = dev_get_platdata(emul); + struct pmc_emul_plat *plat = dev_get_plat(emul); int barnum; for (barnum = 0; barnum < ARRAY_SIZE(barinfo); barnum++) { @@ -235,8 +235,8 @@ U_BOOT_DRIVER(sandbox_pmc_emul_emul) = { .of_match = sandbox_pmc_emul_ids, .ops = &sandbox_pmc_emul_emul_ops, .probe = sandbox_pmc_probe, - .priv_auto_alloc_size = sizeof(struct pmc_emul_priv), - .platdata_auto_alloc_size = sizeof(struct pmc_emul_platdata), + .priv_auto = sizeof(struct pmc_emul_priv), + .plat_auto = sizeof(struct pmc_emul_plat), }; static struct pci_device_id sandbox_pmc_emul_supported[] = { diff --git a/drivers/power/acpi_pmc/sandbox.c b/drivers/power/acpi_pmc/sandbox.c index 48a6c663bd..8cf03f737c 100644 --- a/drivers/power/acpi_pmc/sandbox.c +++ b/drivers/power/acpi_pmc/sandbox.c @@ -74,7 +74,7 @@ static int sandbox_pmc_probe(struct udevice *dev) upriv->pmc_bar0 = map_sysmem(base, 0x2000); upriv->gpe_cfg = (u32 *)(upriv->pmc_bar0 + GPIO_GPE_CFG); - return pmc_ofdata_to_uc_platdata(dev); + return pmc_ofdata_to_uc_plat(dev); } static struct acpi_pmc_ops sandbox_pmc_ops = { @@ -94,5 +94,5 @@ U_BOOT_DRIVER(pmc_sandbox) = { .of_match = sandbox_pmc_ids, .probe = sandbox_pmc_probe, .ops = &sandbox_pmc_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_pmc_priv), + .priv_auto = sizeof(struct sandbox_pmc_priv), }; diff --git a/drivers/power/domain/bcm6328-power-domain.c b/drivers/power/domain/bcm6328-power-domain.c index a494bfa8c9..6e720e0798 100644 --- a/drivers/power/domain/bcm6328-power-domain.c +++ b/drivers/power/domain/bcm6328-power-domain.c @@ -75,6 +75,6 @@ U_BOOT_DRIVER(bcm6328_power_domain) = { .id = UCLASS_POWER_DOMAIN, .of_match = bcm6328_power_domain_ids, .ops = &bcm6328_power_domain_ops, - .priv_auto_alloc_size = sizeof(struct bcm6328_power_domain), + .priv_auto = sizeof(struct bcm6328_power_domain), .probe = bcm6328_power_domain_probe, }; diff --git a/drivers/power/domain/imx8-power-domain-legacy.c b/drivers/power/domain/imx8-power-domain-legacy.c index 889b65a47f..ec369aedd3 100644 --- a/drivers/power/domain/imx8-power-domain-legacy.c +++ b/drivers/power/domain/imx8-power-domain-legacy.c @@ -100,7 +100,7 @@ static int imx8_power_domain_free(struct power_domain *power_domain) static int imx8_power_domain_on(struct power_domain *power_domain) { struct udevice *dev = power_domain->dev; - struct imx8_power_domain_platdata *pdata; + struct imx8_power_domain_plat *pdata; struct imx8_power_domain_priv *ppriv; sc_err_t ret; int err; @@ -116,7 +116,7 @@ static int imx8_power_domain_on(struct power_domain *power_domain) return err; } - pdata = (struct imx8_power_domain_platdata *)dev_get_platdata(dev); + pdata = (struct imx8_power_domain_plat *)dev_get_plat(dev); ppriv = (struct imx8_power_domain_priv *)dev_get_priv(dev); debug("%s(power_domain=%s) resource_id %d\n", __func__, dev->name, @@ -151,11 +151,11 @@ static int imx8_power_domain_off_node(struct power_domain *power_domain) struct udevice *child; struct imx8_power_domain_priv *ppriv; struct imx8_power_domain_priv *child_ppriv; - struct imx8_power_domain_platdata *pdata; + struct imx8_power_domain_plat *pdata; sc_err_t ret; ppriv = dev_get_priv(dev); - pdata = dev_get_platdata(dev); + pdata = dev_get_plat(dev); debug("%s, %s, state_on %d\n", __func__, dev->name, ppriv->state_on); @@ -202,13 +202,13 @@ static int imx8_power_domain_off_parentnodes(struct power_domain *power_domain) struct udevice *child; struct imx8_power_domain_priv *ppriv; struct imx8_power_domain_priv *child_ppriv; - struct imx8_power_domain_platdata *pdata; + struct imx8_power_domain_plat *pdata; sc_err_t ret; struct power_domain parent_pd; if (device_get_uclass_id(parent) == UCLASS_POWER_DOMAIN) { pdata = - (struct imx8_power_domain_platdata *)dev_get_platdata(parent); + (struct imx8_power_domain_plat *)dev_get_plat(parent); ppriv = (struct imx8_power_domain_priv *)dev_get_priv(parent); debug("%s, %s, state_on %d\n", __func__, parent->name, @@ -340,10 +340,10 @@ static int imx8_power_domain_probe(struct udevice *dev) return 0; } -static int imx8_power_domain_ofdata_to_platdata(struct udevice *dev) +static int imx8_power_domain_of_to_plat(struct udevice *dev) { int reg; - struct imx8_power_domain_platdata *pdata = dev_get_platdata(dev); + struct imx8_power_domain_plat *pdata = dev_get_plat(dev); reg = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1); if (reg == -1) { @@ -376,9 +376,9 @@ U_BOOT_DRIVER(imx8_power_domain) = { .of_match = imx8_power_domain_ids, .bind = imx8_power_domain_bind, .probe = imx8_power_domain_probe, - .ofdata_to_platdata = imx8_power_domain_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct imx8_power_domain_platdata), - .priv_auto_alloc_size = sizeof(struct imx8_power_domain_priv), + .of_to_plat = imx8_power_domain_of_to_plat, + .plat_auto = sizeof(struct imx8_power_domain_plat), + .priv_auto = sizeof(struct imx8_power_domain_priv), .ops = &imx8_power_domain_ops, .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, }; diff --git a/drivers/power/domain/imx8m-power-domain.c b/drivers/power/domain/imx8m-power-domain.c index 0ef460df8c..341c83b136 100644 --- a/drivers/power/domain/imx8m-power-domain.c +++ b/drivers/power/domain/imx8m-power-domain.c @@ -30,9 +30,9 @@ static int imx8m_power_domain_free(struct power_domain *power_domain) static int imx8m_power_domain_on(struct power_domain *power_domain) { struct udevice *dev = power_domain->dev; - struct imx8m_power_domain_platdata *pdata; + struct imx8m_power_domain_plat *pdata; - pdata = dev_get_platdata(dev); + pdata = dev_get_plat(dev); if (pdata->resource_id < 0) return -EINVAL; @@ -49,8 +49,8 @@ static int imx8m_power_domain_on(struct power_domain *power_domain) static int imx8m_power_domain_off(struct power_domain *power_domain) { struct udevice *dev = power_domain->dev; - struct imx8m_power_domain_platdata *pdata; - pdata = dev_get_platdata(dev); + struct imx8m_power_domain_plat *pdata; + pdata = dev_get_plat(dev); if (pdata->resource_id < 0) return -EINVAL; @@ -104,9 +104,9 @@ static int imx8m_power_domain_probe(struct udevice *dev) return 0; } -static int imx8m_power_domain_ofdata_to_platdata(struct udevice *dev) +static int imx8m_power_domain_of_to_plat(struct udevice *dev) { - struct imx8m_power_domain_platdata *pdata = dev_get_platdata(dev); + struct imx8m_power_domain_plat *pdata = dev_get_plat(dev); pdata->resource_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1); @@ -136,7 +136,7 @@ U_BOOT_DRIVER(imx8m_power_domain) = { .of_match = imx8m_power_domain_ids, .bind = imx8m_power_domain_bind, .probe = imx8m_power_domain_probe, - .ofdata_to_platdata = imx8m_power_domain_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct imx8m_power_domain_platdata), + .of_to_plat = imx8m_power_domain_of_to_plat, + .plat_auto = sizeof(struct imx8m_power_domain_plat), .ops = &imx8m_power_domain_ops, }; diff --git a/drivers/power/domain/meson-ee-pwrc.c b/drivers/power/domain/meson-ee-pwrc.c index fa1ee93837..a4d50e701a 100644 --- a/drivers/power/domain/meson-ee-pwrc.c +++ b/drivers/power/domain/meson-ee-pwrc.c @@ -445,11 +445,11 @@ static int meson_ee_pwrc_probe(struct udevice *dev) if (!priv->data) return -EINVAL; - priv->regmap_hhi = syscon_node_to_regmap(dev_get_parent(dev)->node); + priv->regmap_hhi = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev))); if (IS_ERR(priv->regmap_hhi)) return PTR_ERR(priv->regmap_hhi); - ret = ofnode_read_u32(dev->node, "amlogic,ao-sysctrl", + ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl", &ao_phandle); if (ret) return ret; @@ -479,5 +479,5 @@ U_BOOT_DRIVER(meson_ee_pwrc) = { .of_match = meson_ee_pwrc_ids, .probe = meson_ee_pwrc_probe, .ops = &meson_ee_pwrc_ops, - .priv_auto_alloc_size = sizeof(struct meson_ee_pwrc_priv), + .priv_auto = sizeof(struct meson_ee_pwrc_priv), }; diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c b/drivers/power/domain/meson-gx-pwrc-vpu.c index a41b230448..eb94af2cf8 100644 --- a/drivers/power/domain/meson-gx-pwrc-vpu.c +++ b/drivers/power/domain/meson-gx-pwrc-vpu.c @@ -300,11 +300,11 @@ static int meson_gx_pwrc_vpu_probe(struct udevice *dev) ofnode hhi_node; int ret; - priv->regmap_ao = syscon_node_to_regmap(dev_get_parent(dev)->node); + priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev))); if (IS_ERR(priv->regmap_ao)) return PTR_ERR(priv->regmap_ao); - ret = ofnode_read_u32(dev->node, "amlogic,hhi-sysctrl", + ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl", &hhi_phandle); if (ret) return ret; @@ -334,5 +334,5 @@ U_BOOT_DRIVER(meson_gx_pwrc_vpu) = { .of_match = meson_gx_pwrc_vpu_ids, .probe = meson_gx_pwrc_vpu_probe, .ops = &meson_gx_pwrc_vpu_ops, - .priv_auto_alloc_size = sizeof(struct meson_gx_pwrc_vpu_priv), + .priv_auto = sizeof(struct meson_gx_pwrc_vpu_priv), }; diff --git a/drivers/power/domain/mtk-power-domain.c b/drivers/power/domain/mtk-power-domain.c index fae4749012..ca2ded00ef 100644 --- a/drivers/power/domain/mtk-power-domain.c +++ b/drivers/power/domain/mtk-power-domain.c @@ -411,5 +411,5 @@ U_BOOT_DRIVER(mtk_power_domain) = { .ops = &mtk_power_domain_ops, .probe = mtk_power_domain_probe, .of_match = mtk_power_domain_ids, - .priv_auto_alloc_size = sizeof(struct scp_domain), + .priv_auto = sizeof(struct scp_domain), }; diff --git a/drivers/power/domain/sandbox-power-domain-test.c b/drivers/power/domain/sandbox-power-domain-test.c index 2191a94146..1bf52f1d86 100644 --- a/drivers/power/domain/sandbox-power-domain-test.c +++ b/drivers/power/domain/sandbox-power-domain-test.c @@ -51,5 +51,5 @@ U_BOOT_DRIVER(sandbox_power_domain_test) = { .name = "sandbox_power_domain_test", .id = UCLASS_MISC, .of_match = sandbox_power_domain_test_ids, - .priv_auto_alloc_size = sizeof(struct sandbox_power_domain_test), + .priv_auto = sizeof(struct sandbox_power_domain_test), }; diff --git a/drivers/power/domain/sandbox-power-domain.c b/drivers/power/domain/sandbox-power-domain.c index 4d9a2006e6..04a071044f 100644 --- a/drivers/power/domain/sandbox-power-domain.c +++ b/drivers/power/domain/sandbox-power-domain.c @@ -88,7 +88,7 @@ U_BOOT_DRIVER(sandbox_power_domain) = { .of_match = sandbox_power_domain_ids, .bind = sandbox_power_domain_bind, .probe = sandbox_power_domain_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_power_domain), + .priv_auto = sizeof(struct sandbox_power_domain), .ops = &sandbox_power_domain_ops, }; diff --git a/drivers/power/domain/ti-sci-power-domain.c b/drivers/power/domain/ti-sci-power-domain.c index 7ee121dfb2..f18e45617a 100644 --- a/drivers/power/domain/ti-sci-power-domain.c +++ b/drivers/power/domain/ti-sci-power-domain.c @@ -135,6 +135,6 @@ U_BOOT_DRIVER(ti_sci_pm_domains) = { .id = UCLASS_POWER_DOMAIN, .of_match = ti_sci_power_domain_of_match, .probe = ti_sci_power_domain_probe, - .priv_auto_alloc_size = sizeof(struct ti_sci_power_domain_data), + .priv_auto = sizeof(struct ti_sci_power_domain_data), .ops = &ti_sci_power_domain_ops, }; diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c index 404fe008fe..abe3a1051f 100644 --- a/drivers/power/pmic/i2c_pmic_emul.c +++ b/drivers/power/pmic/i2c_pmic_emul.c @@ -30,7 +30,7 @@ struct sandbox_i2c_pmic_plat_data { static int sandbox_i2c_pmic_read_data(struct udevice *emul, uchar chip, uchar *buffer, int len) { - struct sandbox_i2c_pmic_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_pmic_plat_data *plat = dev_get_plat(emul); if (plat->rw_idx + len > plat->buf_size) { pr_err("Request exceeds PMIC register range! Max register: %#x", @@ -50,7 +50,7 @@ static int sandbox_i2c_pmic_write_data(struct udevice *emul, uchar chip, uchar *buffer, int len, bool next_is_read) { - struct sandbox_i2c_pmic_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_pmic_plat_data *plat = dev_get_plat(emul); /* Probe only */ if (!len) @@ -103,9 +103,9 @@ static int sandbox_i2c_pmic_xfer(struct udevice *emul, struct i2c_msg *msg, return ret; } -static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul) +static int sandbox_i2c_pmic_of_to_plat(struct udevice *emul) { - struct sandbox_i2c_pmic_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_pmic_plat_data *plat = dev_get_plat(emul); struct udevice *pmic_dev = i2c_emul_get_device(emul); debug("%s:%d Setting PMIC default registers\n", __func__, __LINE__); @@ -116,7 +116,7 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul) static int sandbox_i2c_pmic_probe(struct udevice *emul) { - struct sandbox_i2c_pmic_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_pmic_plat_data *plat = dev_get_plat(emul); struct udevice *pmic_dev = i2c_emul_get_device(emul); struct uc_pmic_priv *upriv = dev_get_uclass_priv(pmic_dev); const u8 *reg_defaults; @@ -159,8 +159,8 @@ U_BOOT_DRIVER(sandbox_i2c_pmic_emul) = { .name = "sandbox_i2c_pmic_emul", .id = UCLASS_I2C_EMUL, .of_match = sandbox_i2c_pmic_ids, - .ofdata_to_platdata = sandbox_i2c_pmic_ofdata_to_platdata, + .of_to_plat = sandbox_i2c_pmic_of_to_plat, .probe = sandbox_i2c_pmic_probe, - .platdata_auto_alloc_size = sizeof(struct sandbox_i2c_pmic_plat_data), + .plat_auto = sizeof(struct sandbox_i2c_pmic_plat_data), .ops = &sandbox_i2c_pmic_emul_ops, }; diff --git a/drivers/power/pmic/pm8916.c b/drivers/power/pmic/pm8916.c index ddc30604cf..5f4386d4ad 100644 --- a/drivers/power/pmic/pm8916.c +++ b/drivers/power/pmic/pm8916.c @@ -82,5 +82,5 @@ U_BOOT_DRIVER(pmic_pm8916) = { .bind = dm_scan_fdt_dev, .probe = pm8916_probe, .ops = &pm8916_ops, - .priv_auto_alloc_size = sizeof(struct pm8916_priv), + .priv_auto = sizeof(struct pm8916_priv), }; diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c index 7770171917..79166b8bbc 100644 --- a/drivers/power/pmic/pmic-uclass.c +++ b/drivers/power/pmic/pmic-uclass.c @@ -196,5 +196,5 @@ UCLASS_DRIVER(pmic) = { .id = UCLASS_PMIC, .name = "pmic", .pre_probe = pmic_pre_probe, - .per_device_auto_alloc_size = sizeof(struct uc_pmic_priv), + .per_device_auto = sizeof(struct uc_pmic_priv), }; diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c index 148ee29cca..5f442fea68 100644 --- a/drivers/power/pmic/rk8xx.c +++ b/drivers/power/pmic/rk8xx.c @@ -190,9 +190,9 @@ U_BOOT_DRIVER(rockchip_rk805) = { #if CONFIG_IS_ENABLED(PMIC_CHILDREN) .bind = rk8xx_bind, #endif - .priv_auto_alloc_size = sizeof(struct rk8xx_priv), + .priv_auto = sizeof(struct rk8xx_priv), .probe = rk8xx_probe, .ops = &rk8xx_ops, }; -U_BOOT_DRIVER_ALIAS(rockchip_rk805, rockchip_rk808) +DM_DRIVER_ALIAS(rockchip_rk805, rockchip_rk808) diff --git a/drivers/power/regulator/act8846.c b/drivers/power/regulator/act8846.c index 1783813a15..bdce97365d 100644 --- a/drivers/power/regulator/act8846.c +++ b/drivers/power/regulator/act8846.c @@ -128,10 +128,10 @@ static int reg_get_enable(struct udevice *dev) static int act8846_reg_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int reg = dev->driver_data; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = reg <= 4 ? REGULATOR_TYPE_BUCK : REGULATOR_TYPE_LDO; uc_pdata->mode_count = 0; diff --git a/drivers/power/regulator/as3722_regulator.c b/drivers/power/regulator/as3722_regulator.c index 0fee9bf00b..ec0776b440 100644 --- a/drivers/power/regulator/as3722_regulator.c +++ b/drivers/power/regulator/as3722_regulator.c @@ -114,9 +114,9 @@ static int ldo_get_enable(struct udevice *dev) static int as3722_stepdown_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; @@ -125,9 +125,9 @@ static int as3722_stepdown_probe(struct udevice *dev) static int as3722_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; diff --git a/drivers/power/regulator/bd71837.c b/drivers/power/regulator/bd71837.c index 931d753e34..74011d6298 100644 --- a/drivers/power/regulator/bd71837.c +++ b/drivers/power/regulator/bd71837.c @@ -35,7 +35,7 @@ struct bd71837_vrange { }; /** - * struct bd71837_platdata - describe regulator control registers + * struct bd71837_plat - describe regulator control registers * * @name: name of the regulator. Used for matching the dt-entry * @enable_reg: register address used to enable/disable regulator @@ -49,7 +49,7 @@ struct bd71837_vrange { * @sel_mask: bit to toggle in order to transfer the register control to SW * @dvs: whether the voltage can be changed when regulator is enabled */ -struct bd71837_platdata { +struct bd71837_plat { const char *name; u8 enable_reg; u8 enablemask; @@ -160,7 +160,7 @@ static struct bd71837_vrange ldo7_vranges[] = { * is powering NXP i.MX8. In this use-case we (for now) only allow control * for BUCK3 and BUCK4 which are not boot critical. */ -static struct bd71837_platdata bd71837_reg_data[] = { +static struct bd71837_plat bd71837_reg_data[] = { /* Bucks 1-4 which support dynamic voltage scaling */ BD_DATA("BUCK1", BD718XX_BUCK1_CTRL, HW_STATE_CONTROL, BD718XX_BUCK1_VOLT_RUN, DVS_BUCK_RUN_MASK, dvs_buck_vranges, 0, @@ -205,7 +205,7 @@ static struct bd71837_platdata bd71837_reg_data[] = { BD71837_LDO7_MASK, ldo7_vranges, 0, false, BD718XX_LDO_SEL), }; -static struct bd71837_platdata bd71847_reg_data[] = { +static struct bd71837_plat bd71847_reg_data[] = { /* Bucks 1 and 2 which support dynamic voltage scaling */ BD_DATA("BUCK1", BD718XX_BUCK1_CTRL, HW_STATE_CONTROL, BD718XX_BUCK1_VOLT_RUN, DVS_BUCK_RUN_MASK, dvs_buck_vranges, 0, @@ -274,7 +274,7 @@ static int vrange_find_selector(struct bd71837_vrange *r, int val, static int bd71837_get_enable(struct udevice *dev) { int val; - struct bd71837_platdata *plat = dev_get_platdata(dev); + struct bd71837_plat *plat = dev_get_plat(dev); /* * boot critical regulators on bd71837 must not be controlled by sw @@ -298,7 +298,7 @@ static int bd71837_get_enable(struct udevice *dev) static int bd71837_set_enable(struct udevice *dev, bool enable) { int val = 0; - struct bd71837_platdata *plat = dev_get_platdata(dev); + struct bd71837_plat *plat = dev_get_plat(dev); /* * boot critical regulators on bd71837 must not be controlled by sw @@ -321,7 +321,7 @@ static int bd71837_set_value(struct udevice *dev, int uvolt) unsigned int range; int i; int found = 0; - struct bd71837_platdata *plat = dev_get_platdata(dev); + struct bd71837_plat *plat = dev_get_plat(dev); /* * An under/overshooting may occur if voltage is changed for other @@ -369,7 +369,7 @@ static int bd71837_get_value(struct udevice *dev) { unsigned int reg, range; unsigned int tmp; - struct bd71837_platdata *plat = dev_get_platdata(dev); + struct bd71837_plat *plat = dev_get_plat(dev); int i; reg = pmic_reg_read(dev->parent, plat->volt_reg); @@ -399,11 +399,11 @@ static int bd71837_get_value(struct udevice *dev) static int bd71837_regulator_probe(struct udevice *dev) { - struct bd71837_platdata *plat = dev_get_platdata(dev); + struct bd71837_plat *plat = dev_get_plat(dev); int i, ret; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int type; - struct bd71837_platdata *init_data; + struct bd71837_plat *init_data; int data_amnt; type = dev_get_driver_data(dev_get_parent(dev)); @@ -433,7 +433,7 @@ static int bd71837_regulator_probe(struct udevice *dev) * the initial state matches dt flags and then * write the SEL bit */ - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = bd71837_set_enable(dev, !!(uc_pdata->boot_on || uc_pdata->always_on)); @@ -466,5 +466,5 @@ U_BOOT_DRIVER(bd71837_regulator) = { .id = UCLASS_REGULATOR, .ops = &bd71837_regulator_ops, .probe = bd71837_regulator_probe, - .platdata_auto_alloc_size = sizeof(struct bd71837_platdata), + .plat_auto = sizeof(struct bd71837_plat), }; diff --git a/drivers/power/regulator/da9063.c b/drivers/power/regulator/da9063.c index 5055e39cb7..8df1abcf78 100644 --- a/drivers/power/regulator/da9063.c +++ b/drivers/power/regulator/da9063.c @@ -135,7 +135,7 @@ static const struct da9063_reg_info da9063_buck_info[] = { static int da9063_get_enable(struct udevice *dev) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; int ret; @@ -148,7 +148,7 @@ static int da9063_get_enable(struct udevice *dev) static int da9063_set_enable(struct udevice *dev, bool enable) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; return pmic_clrsetbits(dev->parent, info->en_reg, @@ -157,7 +157,7 @@ static int da9063_set_enable(struct udevice *dev, bool enable) static int da9063_get_voltage(struct udevice *dev) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; int ret; @@ -170,7 +170,7 @@ static int da9063_get_voltage(struct udevice *dev) static int da9063_set_voltage(struct udevice *dev, int uV) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; uint sel; @@ -198,7 +198,7 @@ static const struct dm_regulator_mode static int ldo_get_mode(struct udevice *dev) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; int val; @@ -214,7 +214,7 @@ static int ldo_get_mode(struct udevice *dev) static int ldo_set_mode(struct udevice *dev, int mode_id) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; const struct dm_regulator_mode *mode; @@ -230,7 +230,7 @@ static int ldo_set_mode(struct udevice *dev, int mode_id) static int buck_get_mode(struct udevice *dev) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; int i; int val; @@ -261,7 +261,7 @@ static int buck_get_mode(struct udevice *dev) static int buck_set_mode(struct udevice *dev, int mode_id) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; const struct dm_regulator_mode *mode; @@ -277,7 +277,7 @@ static int buck_set_mode(struct udevice *dev, int mode_id) static int buck_get_current_limit(struct udevice *dev) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; int val; @@ -293,7 +293,7 @@ static int buck_get_current_limit(struct udevice *dev) static int buck_set_current_limit(struct udevice *dev, int uA) { - const struct da9063_priv *priv = dev->priv; + const struct da9063_priv *priv = dev_get_priv(dev); const struct da9063_reg_info *info = priv->reg_info; int val; @@ -309,8 +309,8 @@ static int buck_set_current_limit(struct udevice *dev, int uA) static int da9063_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; - struct da9063_priv *priv = dev->priv; + struct dm_regulator_uclass_plat *uc_pdata; + struct da9063_priv *priv = dev_get_priv(dev); /* LDOs are named numerically in DT so can directly index */ if (dev->driver_data < 1 || @@ -318,7 +318,7 @@ static int da9063_ldo_probe(struct udevice *dev) return -EINVAL; priv->reg_info = &da9063_ldo_info[dev->driver_data - 1]; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; uc_pdata->mode = da9063_ldo_modes; uc_pdata->mode_count = ARRAY_SIZE(da9063_ldo_modes); @@ -328,8 +328,8 @@ static int da9063_ldo_probe(struct udevice *dev) static int da9063_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; - struct da9063_priv *priv = dev->priv; + struct dm_regulator_uclass_plat *uc_pdata; + struct da9063_priv *priv = dev_get_priv(dev); int i; /* Bucks have names rather than numbers so need to match with DT */ @@ -344,7 +344,7 @@ static int da9063_buck_probe(struct udevice *dev) if (!priv->reg_info) return -ENODEV; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode = da9063_buck_modes; uc_pdata->mode_count = ARRAY_SIZE(da9063_buck_modes); @@ -366,7 +366,7 @@ U_BOOT_DRIVER(da9063_ldo) = { .id = UCLASS_REGULATOR, .ops = &da9063_ldo_ops, .probe = da9063_ldo_probe, - .priv_auto_alloc_size = sizeof(struct da9063_priv), + .priv_auto = sizeof(struct da9063_priv), }; static const struct dm_regulator_ops da9063_buck_ops = { @@ -385,5 +385,5 @@ U_BOOT_DRIVER(da9063_buck) = { .id = UCLASS_REGULATOR, .ops = &da9063_buck_ops, .probe = da9063_buck_probe, - .priv_auto_alloc_size = sizeof(struct da9063_priv), + .priv_auto = sizeof(struct da9063_priv), }; diff --git a/drivers/power/regulator/fan53555.c b/drivers/power/regulator/fan53555.c index b407f555fe..9d8a235b79 100644 --- a/drivers/power/regulator/fan53555.c +++ b/drivers/power/regulator/fan53555.c @@ -78,7 +78,7 @@ enum { FAN53555_MONITOR, }; -struct fan53555_platdata { +struct fan53555_plat { /* Voltage setting register */ unsigned int vol_reg; unsigned int sleep_reg; @@ -100,11 +100,11 @@ struct fan53555_priv { unsigned int sleep_vol_cache; }; -static int fan53555_regulator_ofdata_to_platdata(struct udevice *dev) +static int fan53555_regulator_of_to_plat(struct udevice *dev) { - struct fan53555_platdata *dev_pdata = dev_get_platdata(dev); - struct dm_regulator_uclass_platdata *uc_pdata = - dev_get_uclass_platdata(dev); + struct fan53555_plat *dev_pdata = dev_get_plat(dev); + struct dm_regulator_uclass_plat *uc_pdata = + dev_get_uclass_plat(dev); u32 sleep_vsel; /* This is a buck regulator */ @@ -136,7 +136,7 @@ static int fan53555_regulator_ofdata_to_platdata(struct udevice *dev) static int fan53555_regulator_get_value(struct udevice *dev) { - struct fan53555_platdata *pdata = dev_get_platdata(dev); + struct fan53555_plat *pdata = dev_get_plat(dev); struct fan53555_priv *priv = dev_get_priv(dev); int reg; int voltage; @@ -153,7 +153,7 @@ static int fan53555_regulator_get_value(struct udevice *dev) static int fan53555_regulator_set_value(struct udevice *dev, int uV) { - struct fan53555_platdata *pdata = dev_get_platdata(dev); + struct fan53555_plat *pdata = dev_get_plat(dev); struct fan53555_priv *priv = dev_get_priv(dev); u8 vol; @@ -238,8 +238,8 @@ U_BOOT_DRIVER(fan53555_regulator) = { .name = "fan53555_regulator", .id = UCLASS_REGULATOR, .ops = &fan53555_regulator_ops, - .ofdata_to_platdata = fan53555_regulator_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct fan53555_platdata), - .priv_auto_alloc_size = sizeof(struct fan53555_priv), + .of_to_plat = fan53555_regulator_of_to_plat, + .plat_auto = sizeof(struct fan53555_plat), + .priv_auto = sizeof(struct fan53555_priv), .probe = fan53555_probe, }; diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c index 2fa6c7e6b2..d3e0fb672d 100644 --- a/drivers/power/regulator/fixed.c +++ b/drivers/power/regulator/fixed.c @@ -14,26 +14,26 @@ #include "regulator_common.h" -static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) +static int fixed_regulator_of_to_plat(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; - struct regulator_common_platdata *dev_pdata; + struct dm_regulator_uclass_plat *uc_pdata; + struct regulator_common_plat *dev_pdata; - dev_pdata = dev_get_platdata(dev); - uc_pdata = dev_get_uclass_platdata(dev); + dev_pdata = dev_get_plat(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; uc_pdata->type = REGULATOR_TYPE_FIXED; - return regulator_common_ofdata_to_platdata(dev, dev_pdata, "gpio"); + return regulator_common_of_to_plat(dev, dev_pdata, "gpio"); } static int fixed_regulator_get_value(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; @@ -47,9 +47,9 @@ static int fixed_regulator_get_value(struct udevice *dev) static int fixed_regulator_get_current(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; @@ -63,12 +63,12 @@ static int fixed_regulator_get_current(struct udevice *dev) static int fixed_regulator_get_enable(struct udevice *dev) { - return regulator_common_get_enable(dev, dev_get_platdata(dev)); + return regulator_common_get_enable(dev, dev_get_plat(dev)); } static int fixed_regulator_set_enable(struct udevice *dev, bool enable) { - return regulator_common_set_enable(dev, dev_get_platdata(dev), enable); + return regulator_common_set_enable(dev, dev_get_plat(dev), enable); } static const struct dm_regulator_ops fixed_regulator_ops = { @@ -88,6 +88,6 @@ U_BOOT_DRIVER(regulator_fixed) = { .id = UCLASS_REGULATOR, .ops = &fixed_regulator_ops, .of_match = fixed_regulator_ids, - .ofdata_to_platdata = fixed_regulator_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct regulator_common_platdata), + .of_to_plat = fixed_regulator_of_to_plat, + .plat_auto = sizeof(struct regulator_common_plat), }; diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c index 28c9e222e2..e5e08a33d3 100644 --- a/drivers/power/regulator/gpio-regulator.c +++ b/drivers/power/regulator/gpio-regulator.c @@ -18,23 +18,23 @@ #define GPIO_REGULATOR_MAX_STATES 2 -struct gpio_regulator_platdata { - struct regulator_common_platdata common; +struct gpio_regulator_plat { + struct regulator_common_plat common; struct gpio_desc gpio; /* GPIO for regulator voltage control */ int states[GPIO_REGULATOR_MAX_STATES]; int voltages[GPIO_REGULATOR_MAX_STATES]; }; -static int gpio_regulator_ofdata_to_platdata(struct udevice *dev) +static int gpio_regulator_of_to_plat(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; - struct gpio_regulator_platdata *dev_pdata; + struct dm_regulator_uclass_plat *uc_pdata; + struct gpio_regulator_plat *dev_pdata; struct gpio_desc *gpio; int ret, count, i, j; u32 states_array[GPIO_REGULATOR_MAX_STATES * 2]; - dev_pdata = dev_get_platdata(dev); - uc_pdata = dev_get_uclass_platdata(dev); + dev_pdata = dev_get_plat(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; @@ -74,19 +74,19 @@ static int gpio_regulator_ofdata_to_platdata(struct udevice *dev) j++; } - return regulator_common_ofdata_to_platdata(dev, &dev_pdata->common, "enable-gpios"); + return regulator_common_of_to_plat(dev, &dev_pdata->common, "enable-gpios"); } static int gpio_regulator_get_value(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; - struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + struct dm_regulator_uclass_plat *uc_pdata; + struct gpio_regulator_plat *dev_pdata = dev_get_plat(dev); int enable; if (!dev_pdata->gpio.dev) return -ENOSYS; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (uc_pdata->min_uV > uc_pdata->max_uV) { debug("Invalid constraints for: %s\n", uc_pdata->name); return -EINVAL; @@ -101,7 +101,7 @@ static int gpio_regulator_get_value(struct udevice *dev) static int gpio_regulator_set_value(struct udevice *dev, int uV) { - struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + struct gpio_regulator_plat *dev_pdata = dev_get_plat(dev); int ret; bool enable; @@ -127,13 +127,13 @@ static int gpio_regulator_set_value(struct udevice *dev, int uV) static int gpio_regulator_get_enable(struct udevice *dev) { - struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + struct gpio_regulator_plat *dev_pdata = dev_get_plat(dev); return regulator_common_get_enable(dev, &dev_pdata->common); } static int gpio_regulator_set_enable(struct udevice *dev, bool enable) { - struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + struct gpio_regulator_plat *dev_pdata = dev_get_plat(dev); return regulator_common_set_enable(dev, &dev_pdata->common, enable); } @@ -154,6 +154,6 @@ U_BOOT_DRIVER(gpio_regulator) = { .id = UCLASS_REGULATOR, .ops = &gpio_regulator_ops, .of_match = gpio_regulator_ids, - .ofdata_to_platdata = gpio_regulator_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct gpio_regulator_platdata), + .of_to_plat = gpio_regulator_of_to_plat, + .plat_auto = sizeof(struct gpio_regulator_plat), }; diff --git a/drivers/power/regulator/lp873x_regulator.c b/drivers/power/regulator/lp873x_regulator.c index 5b73f54172..ec1037d7a5 100644 --- a/drivers/power/regulator/lp873x_regulator.c +++ b/drivers/power/regulator/lp873x_regulator.c @@ -24,9 +24,9 @@ static int lp873x_buck_enable(struct udevice *dev, int op, bool *enable) { int ret; unsigned int adr; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->ctrl_reg; ret = pmic_reg_read(dev->parent, adr); @@ -87,9 +87,9 @@ static int lp873x_buck_val(struct udevice *dev, int op, int *uV) { unsigned int hex, adr; int ret; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (op == PMIC_OP_GET) *uV = 0; @@ -126,9 +126,9 @@ static int lp873x_ldo_enable(struct udevice *dev, int op, bool *enable) { int ret; unsigned int adr; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->ctrl_reg; ret = pmic_reg_read(dev->parent, adr); @@ -182,12 +182,12 @@ static int lp873x_ldo_val(struct udevice *dev, int op, int *uV) unsigned int hex, adr; int ret; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; if (op == PMIC_OP_GET) *uV = 0; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->volt_reg; @@ -219,9 +219,9 @@ static int lp873x_ldo_val(struct udevice *dev, int op, int *uV) static int lp873x_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; int idx = dev->driver_data; @@ -272,10 +272,10 @@ static int ldo_set_enable(struct udevice *dev, bool enable) static int lp873x_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int idx; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; idx = dev->driver_data; diff --git a/drivers/power/regulator/lp87565_regulator.c b/drivers/power/regulator/lp87565_regulator.c index 4ea6c346d7..7214dc1b82 100644 --- a/drivers/power/regulator/lp87565_regulator.c +++ b/drivers/power/regulator/lp87565_regulator.c @@ -23,9 +23,9 @@ static int lp87565_buck_enable(struct udevice *dev, int op, bool *enable) { int ret; unsigned int adr; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->ctrl_reg; ret = pmic_reg_read(dev->parent, adr); @@ -86,9 +86,9 @@ static int lp87565_buck_val(struct udevice *dev, int op, int *uV) { unsigned int hex, adr; int ret; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (op == PMIC_OP_GET) *uV = 0; @@ -123,10 +123,10 @@ static int lp87565_buck_val(struct udevice *dev, int op, int *uV) static int lp87565_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int idx; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; idx = dev->driver_data; diff --git a/drivers/power/regulator/max77686.c b/drivers/power/regulator/max77686.c index 752dc88c40..f05d791b7c 100644 --- a/drivers/power/regulator/max77686.c +++ b/drivers/power/regulator/max77686.c @@ -657,9 +657,9 @@ static int max77686_buck_enable(struct udevice *dev, int op, bool *enable) static int max77686_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; uc_pdata->mode_count = max77686_ldo_modes(dev->driver_data, @@ -721,9 +721,9 @@ static int ldo_set_mode(struct udevice *dev, int mode) static int max77686_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode_count = max77686_buck_modes(dev->driver_data, diff --git a/drivers/power/regulator/palmas_regulator.c b/drivers/power/regulator/palmas_regulator.c index 78909f7018..aaa5f3cfc6 100644 --- a/drivers/power/regulator/palmas_regulator.c +++ b/drivers/power/regulator/palmas_regulator.c @@ -51,9 +51,9 @@ static int palmas_smps_enable(struct udevice *dev, int op, bool *enable) { int ret; unsigned int adr; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->ctrl_reg; ret = pmic_reg_read(dev->parent, adr); @@ -120,9 +120,9 @@ static int palmas_smps_val(struct udevice *dev, int op, int *uV) unsigned int hex, adr; int ret; bool range; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (op == PMIC_OP_GET) *uV = 0; @@ -163,7 +163,7 @@ static int palmas_smps_val(struct udevice *dev, int op, int *uV) static int palmas_ldo_bypass_enable(struct udevice *dev, bool enabled) { int type = dev_get_driver_data(dev_get_parent(dev)); - struct dm_regulator_uclass_platdata *p; + struct dm_regulator_uclass_plat *p; unsigned int adr; int reg; @@ -177,7 +177,7 @@ static int palmas_ldo_bypass_enable(struct udevice *dev, bool enabled) return -ENOTSUPP; } - p = dev_get_uclass_platdata(dev); + p = dev_get_uclass_plat(dev); adr = p->ctrl_reg; reg = pmic_reg_read(dev->parent, adr); @@ -196,9 +196,9 @@ static int palmas_ldo_enable(struct udevice *dev, int op, bool *enable) { int ret; unsigned int adr; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->ctrl_reg; ret = pmic_reg_read(dev->parent, adr); @@ -256,12 +256,12 @@ static int palmas_ldo_val(struct udevice *dev, int op, int *uV) unsigned int hex, adr; int ret; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; if (op == PMIC_OP_GET) *uV = 0; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->volt_reg; @@ -292,10 +292,10 @@ static int palmas_ldo_val(struct udevice *dev, int op, int *uV) static int palmas_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *parent; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); parent = dev_get_parent(dev); int type = dev_get_driver_data(parent); @@ -356,11 +356,11 @@ static int ldo_set_enable(struct udevice *dev, bool enable) static int palmas_smps_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *parent; int idx; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); parent = dev_get_parent(dev); int type = dev_get_driver_data(parent); diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c index 28a9a1470b..5bf186e4d4 100644 --- a/drivers/power/regulator/pbias_regulator.c +++ b/drivers/power/regulator/pbias_regulator.c @@ -16,6 +16,7 @@ #include <syscon.h> #include <linux/bitops.h> #include <linux/ioport.h> +#include <dm/device-internal.h> #include <dm/read.h> #ifdef CONFIG_MMC_OMAP36XX_PINS #include <asm/arch/sys_proto.h> @@ -64,7 +65,7 @@ static int pbias_read(struct udevice *dev, uint reg, uint8_t *buff, int len) return regmap_read(priv->regmap, priv->offset, (u32 *)buff); } -static int pbias_ofdata_to_platdata(struct udevice *dev) +static int pbias_of_to_plat(struct udevice *dev) { struct pbias_priv *priv = dev_get_priv(dev); struct udevice *syscon; @@ -102,7 +103,8 @@ static int pbias_bind(struct udevice *dev) { int children; - children = pmic_bind_children(dev, dev->node, pmic_children_info); + children = pmic_bind_children(dev, dev_ofnode(dev), + pmic_children_info); if (!children) debug("%s: %s - no child found\n", __func__, dev->name); @@ -129,8 +131,8 @@ U_BOOT_DRIVER(pbias_pmic) = { .of_match = pbias_ids, .bind = pbias_bind, .ops = &pbias_ops, - .ofdata_to_platdata = pbias_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct pbias_priv), + .of_to_plat = pbias_of_to_plat, + .priv_auto = sizeof(struct pbias_priv), }; static const struct pbias_reg_info pbias_mmc_omap2430 = { @@ -179,9 +181,9 @@ static const struct pbias_reg_info *pbias_reg_infos[] = { static int pbias_regulator_probe(struct udevice *dev) { const struct pbias_reg_info **p = pbias_reg_infos; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); while (*p) { int rc; @@ -208,7 +210,7 @@ static int pbias_regulator_probe(struct udevice *dev) } uc_pdata->type = REGULATOR_TYPE_OTHER; - dev->priv = (void *)*p; + dev_set_priv(dev, (void *)*p); return 0; } diff --git a/drivers/power/regulator/pfuze100.c b/drivers/power/regulator/pfuze100.c index b56843046f..698a6fa592 100644 --- a/drivers/power/regulator/pfuze100.c +++ b/drivers/power/regulator/pfuze100.c @@ -41,11 +41,11 @@ struct pfuze100_regulator_desc { }; /** - * struct pfuze100_regulator_platdata - platform data for pfuze100 + * struct pfuze100_regulator_plat - platform data for pfuze100 * * @desc: Points the description entry of one regulator of pfuze100 */ -struct pfuze100_regulator_platdata { +struct pfuze100_regulator_plat { struct pfuze100_regulator_desc *desc; }; @@ -260,8 +260,8 @@ static struct pfuze100_regulator_desc *se_desc(struct pfuze100_regulator_desc *d static int pfuze100_regulator_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; - struct pfuze100_regulator_platdata *plat = dev_get_platdata(dev); + struct dm_regulator_uclass_plat *uc_pdata; + struct pfuze100_regulator_plat *plat = dev_get_plat(dev); struct pfuze100_regulator_desc *desc; switch (dev_get_driver_data(dev_get_parent(dev))) { @@ -290,7 +290,7 @@ static int pfuze100_regulator_probe(struct udevice *dev) } plat->desc = desc; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = desc->type; if (uc_pdata->type == REGULATOR_TYPE_BUCK) { @@ -315,7 +315,7 @@ static int pfuze100_regulator_probe(struct udevice *dev) static int pfuze100_regulator_mode(struct udevice *dev, int op, int *opmode) { int val; - struct pfuze100_regulator_platdata *plat = dev_get_platdata(dev); + struct pfuze100_regulator_plat *plat = dev_get_plat(dev); struct pfuze100_regulator_desc *desc = plat->desc; if (op == PMIC_OP_GET) { @@ -386,8 +386,8 @@ static int pfuze100_regulator_enable(struct udevice *dev, int op, bool *enable) { int val; int ret, on_off; - struct dm_regulator_uclass_platdata *uc_pdata = - dev_get_uclass_platdata(dev); + struct dm_regulator_uclass_plat *uc_pdata = + dev_get_uclass_plat(dev); if (op == PMIC_OP_GET) { if (!strcmp(dev->name, "vrefddr")) { @@ -449,10 +449,10 @@ static int pfuze100_regulator_val(struct udevice *dev, int op, int *uV) { int i; int val; - struct pfuze100_regulator_platdata *plat = dev_get_platdata(dev); + struct pfuze100_regulator_plat *plat = dev_get_plat(dev); struct pfuze100_regulator_desc *desc = plat->desc; - struct dm_regulator_uclass_platdata *uc_pdata = - dev_get_uclass_platdata(dev); + struct dm_regulator_uclass_plat *uc_pdata = + dev_get_uclass_plat(dev); if (op == PMIC_OP_GET) { *uV = 0; @@ -572,5 +572,5 @@ U_BOOT_DRIVER(pfuze100_regulator) = { .id = UCLASS_REGULATOR, .ops = &pfuze100_regulator_ops, .probe = pfuze100_regulator_probe, - .platdata_auto_alloc_size = sizeof(struct pfuze100_regulator_platdata), + .plat_auto = sizeof(struct pfuze100_regulator_plat), }; diff --git a/drivers/power/regulator/pwm_regulator.c b/drivers/power/regulator/pwm_regulator.c index f870622705..18e57db076 100644 --- a/drivers/power/regulator/pwm_regulator.c +++ b/drivers/power/regulator/pwm_regulator.c @@ -89,7 +89,7 @@ static int pwm_regulator_set_voltage(struct udevice *dev, int uvolt) return ret; } -static int pwm_regulator_ofdata_to_platdata(struct udevice *dev) +static int pwm_regulator_of_to_plat(struct udevice *dev) { struct pwm_regulator_info *priv = dev_get_priv(dev); struct ofnode_phandle_args args; @@ -122,9 +122,9 @@ static int pwm_regulator_ofdata_to_platdata(struct udevice *dev) static int pwm_regulator_probe(struct udevice *dev) { struct pwm_regulator_info *priv = dev_get_priv(dev); - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode_count = 0; @@ -154,6 +154,6 @@ U_BOOT_DRIVER(pwm_regulator) = { .ops = &pwm_regulator_ops, .probe = pwm_regulator_probe, .of_match = pwm_regulator_ids, - .ofdata_to_platdata = pwm_regulator_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct pwm_regulator_info), + .of_to_plat = pwm_regulator_of_to_plat, + .priv_auto = sizeof(struct pwm_regulator_info), }; diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index da679a572c..4d2e730271 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -15,11 +15,11 @@ int regulator_mode(struct udevice *dev, struct dm_regulator_mode **modep) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; *modep = NULL; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; @@ -51,10 +51,10 @@ static void regulator_set_value_ramp_delay(struct udevice *dev, int old_uV, int regulator_set_value(struct udevice *dev, int uV) { const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int ret, old_uV = uV, is_enabled = 0; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV) return -EINVAL; if (uc_pdata->max_uV != -ENODATA && uV > uc_pdata->max_uV) @@ -82,9 +82,9 @@ int regulator_set_value(struct udevice *dev, int uV) int regulator_set_suspend_value(struct udevice *dev, int uV) { const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV) return -EINVAL; if (uc_pdata->max_uV != -ENODATA && uV > uc_pdata->max_uV) @@ -133,9 +133,9 @@ int regulator_get_current(struct udevice *dev) int regulator_set_current(struct udevice *dev, int uA) { const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (uc_pdata->min_uA != -ENODATA && uA < uc_pdata->min_uA) return -EINVAL; if (uc_pdata->max_uA != -ENODATA && uA > uc_pdata->max_uA) @@ -160,13 +160,13 @@ int regulator_get_enable(struct udevice *dev) int regulator_set_enable(struct udevice *dev, bool enable) { const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int ret, old_enable = 0; if (!ops || !ops->set_enable) return -ENOSYS; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!enable && uc_pdata->always_on) return -EACCES; @@ -241,7 +241,7 @@ int regulator_set_mode(struct udevice *dev, int mode) int regulator_get_by_platname(const char *plat_name, struct udevice **devp) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; int ret; @@ -254,7 +254,7 @@ int regulator_get_by_platname(const char *plat_name, struct udevice **devp) continue; } - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata || strcmp(plat_name, uc_pdata->name)) continue; @@ -280,10 +280,10 @@ int device_get_supply_regulator(struct udevice *dev, const char *supply_name, int regulator_autoset(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int ret = 0; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = regulator_set_suspend_enable(dev, uc_pdata->suspend_on); if (!ret && uc_pdata->suspend_on) { @@ -313,9 +313,9 @@ int regulator_autoset(struct udevice *dev) static void regulator_show(struct udevice *dev, int ret) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); printf("%s@%s: ", dev->name, uc_pdata->name); if (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UV) @@ -370,7 +370,7 @@ int regulator_list_autoset(const char *list_platname[], static bool regulator_name_is_unique(struct udevice *check_dev, const char *check_name) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; int check_len = strlen(check_name); int ret; @@ -381,7 +381,7 @@ static bool regulator_name_is_unique(struct udevice *check_dev, if (ret || dev == check_dev) continue; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); len = strlen(uc_pdata->name); if (len != check_len) continue; @@ -395,10 +395,10 @@ static bool regulator_name_is_unique(struct udevice *check_dev, static int regulator_post_bind(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; const char *property = "regulator-name"; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); /* Regulator's mandatory constraint */ uc_pdata->name = dev_read_string(dev, property); @@ -421,10 +421,10 @@ static int regulator_post_bind(struct udevice *dev) static int regulator_pre_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; ofnode node; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) return -ENXIO; @@ -500,6 +500,5 @@ UCLASS_DRIVER(regulator) = { .name = "regulator", .post_bind = regulator_post_bind, .pre_probe = regulator_pre_probe, - .per_device_platdata_auto_alloc_size = - sizeof(struct dm_regulator_uclass_platdata), + .per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat), }; diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c index 13906b9c6e..93d8196b38 100644 --- a/drivers/power/regulator/regulator_common.c +++ b/drivers/power/regulator/regulator_common.c @@ -12,8 +12,9 @@ #include "regulator_common.h" -int regulator_common_ofdata_to_platdata(struct udevice *dev, - struct regulator_common_platdata *dev_pdata, const char *enable_gpio_name) +int regulator_common_of_to_plat(struct udevice *dev, + struct regulator_common_plat *dev_pdata, + const char *enable_gpio_name) { struct gpio_desc *gpio; int flags = GPIOD_IS_OUT; @@ -48,7 +49,7 @@ int regulator_common_ofdata_to_platdata(struct udevice *dev, } int regulator_common_get_enable(const struct udevice *dev, - struct regulator_common_platdata *dev_pdata) + struct regulator_common_plat *dev_pdata) { /* Enable GPIO is optional */ if (!dev_pdata->gpio.dev) @@ -58,7 +59,7 @@ int regulator_common_get_enable(const struct udevice *dev, } int regulator_common_set_enable(const struct udevice *dev, - struct regulator_common_platdata *dev_pdata, bool enable) + struct regulator_common_plat *dev_pdata, bool enable) { int ret; diff --git a/drivers/power/regulator/regulator_common.h b/drivers/power/regulator/regulator_common.h index bf80439c78..c10492f016 100644 --- a/drivers/power/regulator/regulator_common.h +++ b/drivers/power/regulator/regulator_common.h @@ -9,17 +9,18 @@ #include <asm/gpio.h> -struct regulator_common_platdata { +struct regulator_common_plat { struct gpio_desc gpio; /* GPIO for regulator enable control */ unsigned int startup_delay_us; unsigned int off_on_delay_us; }; -int regulator_common_ofdata_to_platdata(struct udevice *dev, - struct regulator_common_platdata *dev_pdata, const char *enable_gpio_name); +int regulator_common_of_to_plat(struct udevice *dev, + struct regulator_common_plat *dev_pdata, const + char *enable_gpio_name); int regulator_common_get_enable(const struct udevice *dev, - struct regulator_common_platdata *dev_pdata); + struct regulator_common_plat *dev_pdata); int regulator_common_set_enable(const struct udevice *dev, - struct regulator_common_platdata *dev_pdata, bool enable); + struct regulator_common_plat *dev_pdata, bool enable); #endif /* _REGULATOR_COMMON_H */ diff --git a/drivers/power/regulator/rk8xx.c b/drivers/power/regulator/rk8xx.c index a08e2151f9..0ee07ad299 100644 --- a/drivers/power/regulator/rk8xx.c +++ b/drivers/power/regulator/rk8xx.c @@ -1034,9 +1034,9 @@ static int switch_set_value(struct udevice *dev, int uvolt) static int rk8xx_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode_count = 0; @@ -1046,9 +1046,9 @@ static int rk8xx_buck_probe(struct udevice *dev) static int rk8xx_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; uc_pdata->mode_count = 0; @@ -1058,9 +1058,9 @@ static int rk8xx_ldo_probe(struct udevice *dev) static int rk8xx_switch_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_FIXED; uc_pdata->mode_count = 0; diff --git a/drivers/power/regulator/s2mps11_regulator.c b/drivers/power/regulator/s2mps11_regulator.c index a6b4f158ef..1c6d8358d5 100644 --- a/drivers/power/regulator/s2mps11_regulator.c +++ b/drivers/power/regulator/s2mps11_regulator.c @@ -305,9 +305,9 @@ static int buck_set_mode(struct udevice *dev, int mode) static int s2mps11_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode = s2mps11_buck_modes; @@ -581,9 +581,9 @@ static int ldo_set_mode(struct udevice *dev, int mode) static int s2mps11_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; uc_pdata->mode = s2mps11_ldo_modes; uc_pdata->mode_count = ARRAY_SIZE(s2mps11_ldo_modes); diff --git a/drivers/power/regulator/s5m8767.c b/drivers/power/regulator/s5m8767.c index b46a2a486e..ad0b98621c 100644 --- a/drivers/power/regulator/s5m8767.c +++ b/drivers/power/regulator/s5m8767.c @@ -130,9 +130,9 @@ static int reg_set_value(struct udevice *dev, const struct s5m8767_para *param, static int s5m8767_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; uc_pdata->mode_count = 0; @@ -199,9 +199,9 @@ static int ldo_set_enable(struct udevice *dev, bool enable) static int s5m8767_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode_count = 0; diff --git a/drivers/power/regulator/sandbox.c b/drivers/power/regulator/sandbox.c index 9893a6b5f3..c52fe3d108 100644 --- a/drivers/power/regulator/sandbox.c +++ b/drivers/power/regulator/sandbox.c @@ -140,13 +140,13 @@ static int out_set_value(struct udevice *dev, int output_count, int reg_type, static int out_get_mode(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; uint8_t reg_val; uint reg; int ret; int i; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); reg = (dev->driver_data - 1) * OUT_REG_COUNT + OUT_REG_OM; ret = pmic_read(dev->parent, reg, ®_val, 1); @@ -166,13 +166,13 @@ static int out_get_mode(struct udevice *dev) static int out_set_mode(struct udevice *dev, int mode) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int reg_val = -1; uint reg; int ret; int i; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (mode >= uc_pdata->mode_count) return -EINVAL; @@ -246,9 +246,9 @@ static int buck_set_enable(struct udevice *dev, bool enable) static int sandbox_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode = sandbox_buck_modes; @@ -322,9 +322,9 @@ static int ldo_set_enable(struct udevice *dev, bool enable) static int sandbox_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; uc_pdata->mode = sandbox_ldo_modes; diff --git a/drivers/power/regulator/stm32-vrefbuf.c b/drivers/power/regulator/stm32-vrefbuf.c index 92136961c2..c2c5770fa5 100644 --- a/drivers/power/regulator/stm32-vrefbuf.c +++ b/drivers/power/regulator/stm32-vrefbuf.c @@ -165,5 +165,5 @@ U_BOOT_DRIVER(stm32_vrefbuf) = { .of_match = stm32_vrefbuf_ids, .probe = stm32_vrefbuf_probe, .ops = &stm32_vrefbuf_ops, - .priv_auto_alloc_size = sizeof(struct stm32_vrefbuf), + .priv_auto = sizeof(struct stm32_vrefbuf), }; diff --git a/drivers/power/regulator/stpmic1.c b/drivers/power/regulator/stpmic1.c index 3e342f4808..4839d83431 100644 --- a/drivers/power/regulator/stpmic1.c +++ b/drivers/power/regulator/stpmic1.c @@ -184,7 +184,7 @@ static int stpmic1_buck_get_enable(struct udevice *dev) static int stpmic1_buck_set_enable(struct udevice *dev, bool enable) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int delay = enable ? STPMIC1_DEFAULT_START_UP_DELAY_MS : STPMIC1_DEFAULT_STOP_DELAY_MS; int ret, uv; @@ -194,7 +194,7 @@ static int stpmic1_buck_set_enable(struct udevice *dev, bool enable) return 0; if (enable) { - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uv = stpmic1_buck_get_value(dev); if (uv < uc_pdata->min_uV || uv > uc_pdata->max_uV) stpmic1_buck_set_value(dev, uc_pdata->min_uV); @@ -231,12 +231,12 @@ static int stpmic1_buck_set_mode(struct udevice *dev, int mode) static int stpmic1_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; if (!dev->driver_data || dev->driver_data > STPMIC1_MAX_BUCK) return -EINVAL; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; uc_pdata->mode = (struct dm_regulator_mode *)buck_modes; @@ -363,7 +363,7 @@ static int stpmic1_ldo_get_enable(struct udevice *dev) static int stpmic1_ldo_set_enable(struct udevice *dev, bool enable) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int delay = enable ? STPMIC1_DEFAULT_START_UP_DELAY_MS : STPMIC1_DEFAULT_STOP_DELAY_MS; int ret, uv; @@ -373,7 +373,7 @@ static int stpmic1_ldo_set_enable(struct udevice *dev, bool enable) return 0; if (enable) { - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uv = stpmic1_ldo_get_value(dev); if (uv < uc_pdata->min_uV || uv > uc_pdata->max_uV) stpmic1_ldo_set_value(dev, uc_pdata->min_uV); @@ -437,12 +437,12 @@ static int stpmic1_ldo_set_mode(struct udevice *dev, int mode) static int stpmic1_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; if (!dev->driver_data || dev->driver_data > STPMIC1_MAX_LDO) return -EINVAL; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; if (dev->driver_data - 1 == STPMIC1_LDO3) { @@ -511,9 +511,9 @@ static int stpmic1_vref_ddr_set_enable(struct udevice *dev, bool enable) static int stpmic1_vref_ddr_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_FIXED; uc_pdata->mode_count = 0; @@ -575,9 +575,9 @@ static int stpmic1_boost_set_enable(struct udevice *dev, bool enable) static int stpmic1_boost_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_FIXED; uc_pdata->mode_count = 0; @@ -648,12 +648,12 @@ static int stpmic1_pwr_sw_set_enable(struct udevice *dev, bool enable) static int stpmic1_pwr_sw_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; if (!dev->driver_data || dev->driver_data > STPMIC1_MAX_PWR_SW) return -EINVAL; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_FIXED; uc_pdata->mode_count = 0; diff --git a/drivers/power/regulator/tps62360_regulator.c b/drivers/power/regulator/tps62360_regulator.c index ce54495490..b9f4504539 100644 --- a/drivers/power/regulator/tps62360_regulator.c +++ b/drivers/power/regulator/tps62360_regulator.c @@ -43,7 +43,7 @@ static struct tps62360_regulator_config tps62361_data = { static int tps62360_regulator_set_value(struct udevice *dev, int uV) { - struct tps62360_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps62360_regulator_pdata *pdata = dev_get_plat(dev); u8 regval; if (uV < pdata->config->vmin || uV > pdata->config->vmax) @@ -66,7 +66,7 @@ static int tps62360_regulator_get_value(struct udevice *dev) { u8 regval; int ret; - struct tps62360_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps62360_regulator_pdata *pdata = dev_get_plat(dev); ret = dm_i2c_read(pdata->i2c, TPS62360_REG_SET0 + pdata->vsel_offset, ®val, 1); @@ -80,7 +80,7 @@ static int tps62360_regulator_get_value(struct udevice *dev) static int tps62360_regulator_probe(struct udevice *dev) { - struct tps62360_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps62360_regulator_pdata *pdata = dev_get_plat(dev); u8 vsel0; u8 vsel1; int ret; @@ -119,6 +119,6 @@ U_BOOT_DRIVER(tps62360_regulator) = { .id = UCLASS_REGULATOR, .ops = &tps62360_regulator_ops, .of_match = tps62360_regulator_ids, - .platdata_auto_alloc_size = sizeof(struct tps62360_regulator_pdata), + .plat_auto = sizeof(struct tps62360_regulator_pdata), .probe = tps62360_regulator_probe, }; diff --git a/drivers/power/regulator/tps65090_regulator.c b/drivers/power/regulator/tps65090_regulator.c index 9e45627a74..174ee58d03 100644 --- a/drivers/power/regulator/tps65090_regulator.c +++ b/drivers/power/regulator/tps65090_regulator.c @@ -14,9 +14,9 @@ static int tps65090_fet_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_OTHER; uc_pdata->mode_count = 0; diff --git a/drivers/power/regulator/tps65910_regulator.c b/drivers/power/regulator/tps65910_regulator.c index 171afd34a5..0ed4952a1e 100644 --- a/drivers/power/regulator/tps65910_regulator.c +++ b/drivers/power/regulator/tps65910_regulator.c @@ -141,7 +141,7 @@ static int tps65910_regulator_get_value(struct udevice *dev, const struct regulator_props *rgp) { int sel, val, vout; - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); int vin = pdata->supply; val = pmic_reg_read(dev->parent, rgp->reg); @@ -156,7 +156,7 @@ static int tps65910_regulator_get_value(struct udevice *dev, static int tps65910_ldo_get_value(struct udevice *dev) { - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); int vin; if (!pdata) @@ -194,7 +194,7 @@ static int tps65910_regulator_set_value(struct udevice *dev, { int val; int sel = 0; - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); do { /* we only allow exact voltage matches */ @@ -216,7 +216,7 @@ static int tps65910_regulator_set_value(struct udevice *dev, static int tps65910_ldo_set_value(struct udevice *dev, int uV) { - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); int vin = pdata->supply; switch (pdata->unit) { @@ -249,7 +249,7 @@ static int tps65910_ldo_set_value(struct udevice *dev, int uV) static int tps65910_get_enable(struct udevice *dev) { int reg, val; - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); reg = get_ctrl_reg_from_unit_addr(pdata->unit); if (reg < 0) @@ -267,7 +267,7 @@ static int tps65910_set_enable(struct udevice *dev, bool enable) { int reg; uint clr, set; - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); reg = get_ctrl_reg_from_unit_addr(pdata->unit); if (reg < 0) @@ -305,7 +305,7 @@ static int buck_get_vdd1_vdd2_value(struct udevice *dev, int reg_vdd) static int tps65910_buck_get_value(struct udevice *dev) { - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); switch (pdata->unit) { case TPS65910_UNIT_VIO: @@ -323,8 +323,8 @@ static int buck_set_vdd1_vdd2_value(struct udevice *dev, int uV) { int ret, reg_vdd, gain; int val; - struct dm_regulator_uclass_platdata *uc_pdata; - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct dm_regulator_uclass_plat *uc_pdata; + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); switch (pdata->unit) { case TPS65910_UNIT_VDD1: @@ -336,7 +336,7 @@ static int buck_set_vdd1_vdd2_value(struct udevice *dev, int uV) default: return -EINVAL; } - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); /* check setpoint is within limits */ if (uV < uc_pdata->min_uV) { @@ -369,7 +369,7 @@ static int buck_set_vdd1_vdd2_value(struct udevice *dev, int uV) static int tps65910_buck_set_value(struct udevice *dev, int uV) { - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); if (pdata->unit == TPS65910_UNIT_VIO) return tps65910_regulator_set_value(dev, &smps_props_vio, uV); @@ -380,18 +380,18 @@ static int tps65910_buck_set_value(struct udevice *dev, int uV) static int tps65910_boost_get_value(struct udevice *dev) { int vout; - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); vout = (pdata->supply >= 3000000) ? 5000000 : 0; return vout; } -static int tps65910_regulator_ofdata_to_platdata(struct udevice *dev) +static int tps65910_regulator_of_to_plat(struct udevice *dev) { struct udevice *supply; int ret; const char *supply_name; - struct tps65910_regulator_pdata *pdata = dev_get_platdata(dev); + struct tps65910_regulator_pdata *pdata = dev_get_plat(dev); pdata->unit = dev_get_driver_data(dev); if (pdata->unit > TPS65910_UNIT_VMMC) @@ -424,8 +424,8 @@ U_BOOT_DRIVER(tps65910_boost) = { .name = TPS65910_BOOST_DRIVER, .id = UCLASS_REGULATOR, .ops = &tps65910_boost_ops, - .platdata_auto_alloc_size = sizeof(struct tps65910_regulator_pdata), - .ofdata_to_platdata = tps65910_regulator_ofdata_to_platdata, + .plat_auto = sizeof(struct tps65910_regulator_pdata), + .of_to_plat = tps65910_regulator_of_to_plat, }; static const struct dm_regulator_ops tps65910_buck_ops = { @@ -439,8 +439,8 @@ U_BOOT_DRIVER(tps65910_buck) = { .name = TPS65910_BUCK_DRIVER, .id = UCLASS_REGULATOR, .ops = &tps65910_buck_ops, - .platdata_auto_alloc_size = sizeof(struct tps65910_regulator_pdata), - .ofdata_to_platdata = tps65910_regulator_ofdata_to_platdata, + .plat_auto = sizeof(struct tps65910_regulator_pdata), + .of_to_plat = tps65910_regulator_of_to_plat, }; static const struct dm_regulator_ops tps65910_ldo_ops = { @@ -454,6 +454,6 @@ U_BOOT_DRIVER(tps65910_ldo) = { .name = TPS65910_LDO_DRIVER, .id = UCLASS_REGULATOR, .ops = &tps65910_ldo_ops, - .platdata_auto_alloc_size = sizeof(struct tps65910_regulator_pdata), - .ofdata_to_platdata = tps65910_regulator_ofdata_to_platdata, + .plat_auto = sizeof(struct tps65910_regulator_pdata), + .of_to_plat = tps65910_regulator_of_to_plat, }; diff --git a/drivers/power/regulator/tps65941_regulator.c b/drivers/power/regulator/tps65941_regulator.c index 150c72d7ec..d73f832483 100644 --- a/drivers/power/regulator/tps65941_regulator.c +++ b/drivers/power/regulator/tps65941_regulator.c @@ -30,9 +30,9 @@ static int tps65941_buck_enable(struct udevice *dev, int op, bool *enable) { int ret; unsigned int adr; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->ctrl_reg; ret = pmic_reg_read(dev->parent, adr); @@ -121,9 +121,9 @@ static int tps65941_buck_val(struct udevice *dev, int op, int *uV) { unsigned int hex, adr; int ret, delta, uwait, slew; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (op == PMIC_OP_GET) *uV = 0; @@ -182,9 +182,9 @@ static int tps65941_ldo_enable(struct udevice *dev, int op, bool *enable) { int ret; unsigned int adr; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); adr = uc_pdata->ctrl_reg; ret = pmic_reg_read(dev->parent, adr); @@ -227,9 +227,9 @@ static int tps65941_ldo_val(struct udevice *dev, int op, int *uV) { unsigned int hex, adr; int ret; - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (op == PMIC_OP_GET) *uV = 0; @@ -264,10 +264,10 @@ static int tps65941_ldo_val(struct udevice *dev, int op, int *uV) static int tps65941_ldo_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int idx; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_LDO; idx = dev->driver_data; @@ -286,10 +286,10 @@ static int tps65941_ldo_probe(struct udevice *dev) static int tps65941_buck_probe(struct udevice *dev) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; int idx; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); uc_pdata->type = REGULATOR_TYPE_BUCK; idx = dev->driver_data; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index b3bd5c6bb7..ccf81abbe9 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -75,3 +75,10 @@ config PWM_SUNXI help This PWM is found on H3, A64 and other Allwinner SoCs. It supports a programmable period and duty cycle. A 16-bit counter is used. + +config PWM_TI_EHRPWM + bool "Enable support for EHRPWM PWM" + depends on DM_PWM && ARCH_OMAP2PLUS + default y + help + PWM driver support for the EHRPWM controller found on TI SOCs. diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index f21ae7d76e..0b9d2698a3 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -19,3 +19,4 @@ obj-$(CONFIG_PWM_SANDBOX) += sandbox_pwm.o obj-$(CONFIG_PWM_SIFIVE) += pwm-sifive.o obj-$(CONFIG_PWM_TEGRA) += tegra_pwm.o obj-$(CONFIG_PWM_SUNXI) += sunxi_pwm.o +obj-$(CONFIG_PWM_TI_EHRPWM) += pwm-ti-ehrpwm.o diff --git a/drivers/pwm/exynos_pwm.c b/drivers/pwm/exynos_pwm.c index e55fcceafd..1afaf784da 100644 --- a/drivers/pwm/exynos_pwm.c +++ b/drivers/pwm/exynos_pwm.c @@ -88,7 +88,7 @@ static int exynos_pwm_probe(struct udevice *dev) return 0; } -static int exynos_pwm_ofdata_to_platdata(struct udevice *dev) +static int exynos_pwm_of_to_plat(struct udevice *dev) { struct exynos_pwm_priv *priv = dev_get_priv(dev); @@ -113,6 +113,6 @@ U_BOOT_DRIVER(exynos_pwm) = { .of_match = exynos_channels, .ops = &exynos_pwm_ops, .probe = exynos_pwm_probe, - .ofdata_to_platdata = exynos_pwm_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct exynos_pwm_priv), + .of_to_plat = exynos_pwm_of_to_plat, + .priv_auto = sizeof(struct exynos_pwm_priv), }; diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index 77a1907fd3..2008c1520e 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -126,7 +126,7 @@ static int imx_pwm_set_enable(struct udevice *dev, uint channel, bool enable) return 0; }; -static int imx_pwm_ofdata_to_platdata(struct udevice *dev) +static int imx_pwm_of_to_plat(struct udevice *dev) { struct imx_pwm_priv *priv = dev_get_priv(dev); @@ -156,8 +156,8 @@ U_BOOT_DRIVER(imx_pwm) = { .id = UCLASS_PWM, .of_match = imx_pwm_ids, .ops = &imx_pwm_ops, - .ofdata_to_platdata = imx_pwm_ofdata_to_platdata, + .of_to_plat = imx_pwm_of_to_plat, .probe = imx_pwm_probe, - .priv_auto_alloc_size = sizeof(struct imx_pwm_priv), + .priv_auto = sizeof(struct imx_pwm_priv), }; #endif diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index cafb571f16..03eeacc286 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -249,7 +249,7 @@ static int meson_pwm_set_invert(struct udevice *dev, uint channeln, bool polarit return meson_pwm_set_config(dev, channeln, channel->period_ns, channel->duty_ns); } -static int meson_pwm_ofdata_to_platdata(struct udevice *dev) +static int meson_pwm_of_to_plat(struct udevice *dev) { struct meson_pwm *priv = dev_get_priv(dev); @@ -304,13 +304,14 @@ static int meson_pwm_probe(struct udevice *dev) if (strcmp(cdev->driver->name, "fixed_rate_clock")) continue; - str = ofnode_read_string(cdev->node, "clock-output-names"); + str = ofnode_read_string(dev_ofnode(cdev), + "clock-output-names"); if (!str) continue; if (!strcmp(str, "xtal")) { err = uclass_get_device_by_ofnode(UCLASS_CLK, - cdev->node, + dev_ofnode(cdev), &cdev); if (err) { printf("%s%d: Failed to get xtal clk\n", __func__, i); @@ -345,7 +346,9 @@ static int meson_pwm_probe(struct udevice *dev) return -EINVAL; } - err = uclass_get_device_by_ofnode(UCLASS_CLK, cdev->node, &cdev); + err = uclass_get_device_by_ofnode(UCLASS_CLK, + dev_ofnode(cdev), + &cdev); if (err) { printf("%s%d: Failed to get clk controller\n", __func__, i); return err; @@ -522,7 +525,7 @@ U_BOOT_DRIVER(meson_pwm) = { .id = UCLASS_PWM, .of_match = meson_pwm_ids, .ops = &meson_pwm_ops, - .ofdata_to_platdata = meson_pwm_ofdata_to_platdata, + .of_to_plat = meson_pwm_of_to_plat, .probe = meson_pwm_probe, - .priv_auto_alloc_size = sizeof(struct meson_pwm), + .priv_auto = sizeof(struct meson_pwm), }; diff --git a/drivers/pwm/pwm-mtk.c b/drivers/pwm/pwm-mtk.c index 7bd82518d6..aee1d825a0 100644 --- a/drivers/pwm/pwm-mtk.c +++ b/drivers/pwm/pwm-mtk.c @@ -184,5 +184,5 @@ U_BOOT_DRIVER(mtk_pwm) = { .of_match = mtk_pwm_ids, .ops = &mtk_pwm_ops, .probe = mtk_pwm_probe, - .priv_auto_alloc_size = sizeof(struct mtk_pwm_priv), + .priv_auto = sizeof(struct mtk_pwm_priv), }; diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index 77bc659fef..30c30430be 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -115,7 +115,7 @@ static int pwm_sifive_set_enable(struct udevice *dev, uint channel, bool enable) return 0; } -static int pwm_sifive_ofdata_to_platdata(struct udevice *dev) +static int pwm_sifive_of_to_plat(struct udevice *dev) { struct pwm_sifive_priv *priv = dev_get_priv(dev); @@ -166,7 +166,7 @@ U_BOOT_DRIVER(pwm_sifive) = { .id = UCLASS_PWM, .of_match = pwm_sifive_ids, .ops = &pwm_sifive_ops, - .ofdata_to_platdata = pwm_sifive_ofdata_to_platdata, + .of_to_plat = pwm_sifive_of_to_plat, .probe = pwm_sifive_probe, - .priv_auto_alloc_size = sizeof(struct pwm_sifive_priv), + .priv_auto = sizeof(struct pwm_sifive_priv), }; diff --git a/drivers/pwm/pwm-ti-ehrpwm.c b/drivers/pwm/pwm-ti-ehrpwm.c new file mode 100644 index 0000000000..ac3d731d22 --- /dev/null +++ b/drivers/pwm/pwm-ti-ehrpwm.c @@ -0,0 +1,468 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EHRPWM PWM driver + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + * + * Based on Linux kernel drivers/pwm/pwm-tiehrpwm.c + */ + +#include <common.h> +#include <clk.h> +#include <div64.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <pwm.h> +#include <asm/io.h> + +#define NSEC_PER_SEC 1000000000L + +/* Time base module registers */ +#define TI_EHRPWM_TBCTL 0x00 +#define TI_EHRPWM_TBPRD 0x0A + +#define TI_EHRPWM_TBCTL_PRDLD_MASK BIT(3) +#define TI_EHRPWM_TBCTL_PRDLD_SHDW 0 +#define TI_EHRPWM_TBCTL_PRDLD_IMDT BIT(3) +#define TI_EHRPWM_TBCTL_CLKDIV_MASK GENMASK(12, 7) +#define TI_EHRPWM_TBCTL_CTRMODE_MASK GENMASK(1, 0) +#define TI_EHRPWM_TBCTL_CTRMODE_UP 0 +#define TI_EHRPWM_TBCTL_CTRMODE_DOWN BIT(0) +#define TI_EHRPWM_TBCTL_CTRMODE_UPDOWN BIT(1) +#define TI_EHRPWM_TBCTL_CTRMODE_FREEZE GENMASK(1, 0) + +#define TI_EHRPWM_TBCTL_HSPCLKDIV_SHIFT 7 +#define TI_EHRPWM_TBCTL_CLKDIV_SHIFT 10 + +#define TI_EHRPWM_CLKDIV_MAX 7 +#define TI_EHRPWM_HSPCLKDIV_MAX 7 +#define TI_EHRPWM_PERIOD_MAX 0xFFFF + +/* Counter compare module registers */ +#define TI_EHRPWM_CMPA 0x12 +#define TI_EHRPWM_CMPB 0x14 + +/* Action qualifier module registers */ +#define TI_EHRPWM_AQCTLA 0x16 +#define TI_EHRPWM_AQCTLB 0x18 +#define TI_EHRPWM_AQSFRC 0x1A +#define TI_EHRPWM_AQCSFRC 0x1C + +#define TI_EHRPWM_AQCTL_CBU_MASK GENMASK(9, 8) +#define TI_EHRPWM_AQCTL_CBU_FRCLOW BIT(8) +#define TI_EHRPWM_AQCTL_CBU_FRCHIGH BIT(9) +#define TI_EHRPWM_AQCTL_CBU_FRCTOGGLE GENMASK(9, 8) +#define TI_EHRPWM_AQCTL_CAU_MASK GENMASK(5, 4) +#define TI_EHRPWM_AQCTL_CAU_FRCLOW BIT(4) +#define TI_EHRPWM_AQCTL_CAU_FRCHIGH BIT(5) +#define TI_EHRPWM_AQCTL_CAU_FRCTOGGLE GENMASK(5, 4) +#define TI_EHRPWM_AQCTL_PRD_MASK GENMASK(3, 2) +#define TI_EHRPWM_AQCTL_PRD_FRCLOW BIT(2) +#define TI_EHRPWM_AQCTL_PRD_FRCHIGH BIT(3) +#define TI_EHRPWM_AQCTL_PRD_FRCTOGGLE GENMASK(3, 2) +#define TI_EHRPWM_AQCTL_ZRO_MASK GENMASK(1, 0) +#define TI_EHRPWM_AQCTL_ZRO_FRCLOW BIT(0) +#define TI_EHRPWM_AQCTL_ZRO_FRCHIGH BIT(1) +#define TI_EHRPWM_AQCTL_ZRO_FRCTOGGLE GENMASK(1, 0) + +#define TI_EHRPWM_AQCTL_CHANA_POLNORMAL (TI_EHRPWM_AQCTL_CAU_FRCLOW | \ + TI_EHRPWM_AQCTL_PRD_FRCHIGH | \ + TI_EHRPWM_AQCTL_ZRO_FRCHIGH) +#define TI_EHRPWM_AQCTL_CHANA_POLINVERSED (TI_EHRPWM_AQCTL_CAU_FRCHIGH | \ + TI_EHRPWM_AQCTL_PRD_FRCLOW | \ + TI_EHRPWM_AQCTL_ZRO_FRCLOW) +#define TI_EHRPWM_AQCTL_CHANB_POLNORMAL (TI_EHRPWM_AQCTL_CBU_FRCLOW | \ + TI_EHRPWM_AQCTL_PRD_FRCHIGH | \ + TI_EHRPWM_AQCTL_ZRO_FRCHIGH) +#define TI_EHRPWM_AQCTL_CHANB_POLINVERSED (TI_EHRPWM_AQCTL_CBU_FRCHIGH | \ + TI_EHRPWM_AQCTL_PRD_FRCLOW | \ + TI_EHRPWM_AQCTL_ZRO_FRCLOW) + +#define TI_EHRPWM_AQSFRC_RLDCSF_MASK GENMASK(7, 6) +#define TI_EHRPWM_AQSFRC_RLDCSF_ZRO 0 +#define TI_EHRPWM_AQSFRC_RLDCSF_PRD BIT(6) +#define TI_EHRPWM_AQSFRC_RLDCSF_ZROPRD BIT(7) +#define TI_EHRPWM_AQSFRC_RLDCSF_IMDT GENMASK(7, 6) + +#define TI_EHRPWM_AQCSFRC_CSFB_MASK GENMASK(3, 2) +#define TI_EHRPWM_AQCSFRC_CSFB_FRCDIS 0 +#define TI_EHRPWM_AQCSFRC_CSFB_FRCLOW BIT(2) +#define TI_EHRPWM_AQCSFRC_CSFB_FRCHIGH BIT(3) +#define TI_EHRPWM_AQCSFRC_CSFB_DISSWFRC GENMASK(3, 2) +#define TI_EHRPWM_AQCSFRC_CSFA_MASK GENMASK(1, 0) +#define TI_EHRPWM_AQCSFRC_CSFA_FRCDIS 0 +#define TI_EHRPWM_AQCSFRC_CSFA_FRCLOW BIT(0) +#define TI_EHRPWM_AQCSFRC_CSFA_FRCHIGH BIT(1) +#define TI_EHRPWM_AQCSFRC_CSFA_DISSWFRC GENMASK(1, 0) + +#define TI_EHRPWM_NUM_CHANNELS 2 + +struct ti_ehrpwm_priv { + fdt_addr_t regs; + u32 clk_rate; + struct clk tbclk; + unsigned long period_cycles[TI_EHRPWM_NUM_CHANNELS]; + bool polarity_reversed[TI_EHRPWM_NUM_CHANNELS]; +}; + +static void ti_ehrpwm_modify(u16 val, u16 mask, fdt_addr_t reg) +{ + unsigned short v; + + v = readw(reg); + v &= ~mask; + v |= val & mask; + writew(v, reg); +} + +static int ti_ehrpwm_set_invert(struct udevice *dev, uint channel, + bool polarity) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + + if (channel >= TI_EHRPWM_NUM_CHANNELS) + return -ENOSPC; + + /* Configuration of polarity in hardware delayed, do at enable */ + priv->polarity_reversed[channel] = polarity; + return 0; +} + +/** + * set_prescale_div - Set up the prescaler divider function + * @rqst_prescaler: prescaler value min + * @prescale_div: prescaler value set + * @tb_clk_div: Time Base Control prescaler bits + */ +static int set_prescale_div(unsigned long rqst_prescaler, u16 *prescale_div, + u16 *tb_clk_div) +{ + unsigned int clkdiv, hspclkdiv; + + for (clkdiv = 0; clkdiv <= TI_EHRPWM_CLKDIV_MAX; clkdiv++) { + for (hspclkdiv = 0; hspclkdiv <= TI_EHRPWM_HSPCLKDIV_MAX; + hspclkdiv++) { + /* + * calculations for prescaler value : + * prescale_div = HSPCLKDIVIDER * CLKDIVIDER. + * HSPCLKDIVIDER = 2 ** hspclkdiv + * CLKDIVIDER = (1), if clkdiv == 0 *OR* + * (2 * clkdiv), if clkdiv != 0 + * + * Configure prescale_div value such that period + * register value is less than 65535. + */ + + *prescale_div = (1 << clkdiv) * + (hspclkdiv ? (hspclkdiv * 2) : 1); + if (*prescale_div > rqst_prescaler) { + *tb_clk_div = + (clkdiv << TI_EHRPWM_TBCTL_CLKDIV_SHIFT) | + (hspclkdiv << + TI_EHRPWM_TBCTL_HSPCLKDIV_SHIFT); + return 0; + } + } + } + + return 1; +} + +static void ti_ehrpwm_configure_polarity(struct udevice *dev, uint channel) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + u16 aqctl_val, aqctl_mask; + unsigned int aqctl_reg; + + /* + * Configure PWM output to HIGH/LOW level on counter + * reaches compare register value and LOW/HIGH level + * on counter value reaches period register value and + * zero value on counter + */ + if (channel == 1) { + aqctl_reg = TI_EHRPWM_AQCTLB; + aqctl_mask = TI_EHRPWM_AQCTL_CBU_MASK; + + if (priv->polarity_reversed[channel]) + aqctl_val = TI_EHRPWM_AQCTL_CHANB_POLINVERSED; + else + aqctl_val = TI_EHRPWM_AQCTL_CHANB_POLNORMAL; + } else { + aqctl_reg = TI_EHRPWM_AQCTLA; + aqctl_mask = TI_EHRPWM_AQCTL_CAU_MASK; + + if (priv->polarity_reversed[channel]) + aqctl_val = TI_EHRPWM_AQCTL_CHANA_POLINVERSED; + else + aqctl_val = TI_EHRPWM_AQCTL_CHANA_POLNORMAL; + } + + aqctl_mask |= TI_EHRPWM_AQCTL_PRD_MASK | TI_EHRPWM_AQCTL_ZRO_MASK; + ti_ehrpwm_modify(aqctl_val, aqctl_mask, priv->regs + aqctl_reg); +} + +/* + * period_ns = 10^9 * (ps_divval * period_cycles) / PWM_CLK_RATE + * duty_ns = 10^9 * (ps_divval * duty_cycles) / PWM_CLK_RATE + */ +static int ti_ehrpwm_set_config(struct udevice *dev, uint channel, + uint period_ns, uint duty_ns) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + u32 period_cycles, duty_cycles; + u16 ps_divval, tb_divval; + unsigned int i, cmp_reg; + unsigned long long c; + + if (channel >= TI_EHRPWM_NUM_CHANNELS) + return -ENOSPC; + + if (period_ns > NSEC_PER_SEC) + return -ERANGE; + + c = priv->clk_rate; + c = c * period_ns; + do_div(c, NSEC_PER_SEC); + period_cycles = (unsigned long)c; + + if (period_cycles < 1) { + period_cycles = 1; + duty_cycles = 1; + } else { + c = priv->clk_rate; + c = c * duty_ns; + do_div(c, NSEC_PER_SEC); + duty_cycles = (unsigned long)c; + } + + dev_dbg(dev, "channel=%d, period_ns=%d, duty_ns=%d\n", + channel, period_ns, duty_ns); + + /* + * Period values should be same for multiple PWM channels as IP uses + * same period register for multiple channels. + */ + for (i = 0; i < TI_EHRPWM_NUM_CHANNELS; i++) { + if (priv->period_cycles[i] && + priv->period_cycles[i] != period_cycles) { + /* + * Allow channel to reconfigure period if no other + * channels being configured. + */ + if (i == channel) + continue; + + dev_err(dev, "period value conflicts with channel %u\n", + i); + return -EINVAL; + } + } + + priv->period_cycles[channel] = period_cycles; + + /* Configure clock prescaler to support Low frequency PWM wave */ + if (set_prescale_div(period_cycles / TI_EHRPWM_PERIOD_MAX, &ps_divval, + &tb_divval)) { + dev_err(dev, "unsupported values\n"); + return -EINVAL; + } + + /* Update clock prescaler values */ + ti_ehrpwm_modify(tb_divval, TI_EHRPWM_TBCTL_CLKDIV_MASK, + priv->regs + TI_EHRPWM_TBCTL); + + /* Update period & duty cycle with presacler division */ + period_cycles = period_cycles / ps_divval; + duty_cycles = duty_cycles / ps_divval; + + /* Configure shadow loading on Period register */ + ti_ehrpwm_modify(TI_EHRPWM_TBCTL_PRDLD_SHDW, TI_EHRPWM_TBCTL_PRDLD_MASK, + priv->regs + TI_EHRPWM_TBCTL); + + writew(period_cycles, priv->regs + TI_EHRPWM_TBPRD); + + /* Configure ehrpwm counter for up-count mode */ + ti_ehrpwm_modify(TI_EHRPWM_TBCTL_CTRMODE_UP, + TI_EHRPWM_TBCTL_CTRMODE_MASK, + priv->regs + TI_EHRPWM_TBCTL); + + if (channel == 1) + /* Channel 1 configured with compare B register */ + cmp_reg = TI_EHRPWM_CMPB; + else + /* Channel 0 configured with compare A register */ + cmp_reg = TI_EHRPWM_CMPA; + + writew(duty_cycles, priv->regs + cmp_reg); + return 0; +} + +static int ti_ehrpwm_disable(struct udevice *dev, uint channel) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + u16 aqcsfrc_val, aqcsfrc_mask; + int err; + + if (channel >= TI_EHRPWM_NUM_CHANNELS) + return -ENOSPC; + + /* Action Qualifier puts PWM output low forcefully */ + if (channel) { + aqcsfrc_val = TI_EHRPWM_AQCSFRC_CSFB_FRCLOW; + aqcsfrc_mask = TI_EHRPWM_AQCSFRC_CSFB_MASK; + } else { + aqcsfrc_val = TI_EHRPWM_AQCSFRC_CSFA_FRCLOW; + aqcsfrc_mask = TI_EHRPWM_AQCSFRC_CSFA_MASK; + } + + /* Update shadow register first before modifying active register */ + ti_ehrpwm_modify(TI_EHRPWM_AQSFRC_RLDCSF_ZRO, + TI_EHRPWM_AQSFRC_RLDCSF_MASK, + priv->regs + TI_EHRPWM_AQSFRC); + + ti_ehrpwm_modify(aqcsfrc_val, aqcsfrc_mask, + priv->regs + TI_EHRPWM_AQCSFRC); + + /* + * Changes to immediate action on Action Qualifier. This puts + * Action Qualifier control on PWM output from next TBCLK + */ + ti_ehrpwm_modify(TI_EHRPWM_AQSFRC_RLDCSF_IMDT, + TI_EHRPWM_AQSFRC_RLDCSF_MASK, + priv->regs + TI_EHRPWM_AQSFRC); + + ti_ehrpwm_modify(aqcsfrc_val, aqcsfrc_mask, + priv->regs + TI_EHRPWM_AQCSFRC); + + /* Disabling TBCLK on PWM disable */ + err = clk_disable(&priv->tbclk); + if (err) { + dev_err(dev, "failed to disable tbclk\n"); + return err; + } + + return 0; +} + +static int ti_ehrpwm_enable(struct udevice *dev, uint channel) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + u16 aqcsfrc_val, aqcsfrc_mask; + int err; + + if (channel >= TI_EHRPWM_NUM_CHANNELS) + return -ENOSPC; + + /* Disabling Action Qualifier on PWM output */ + if (channel) { + aqcsfrc_val = TI_EHRPWM_AQCSFRC_CSFB_FRCDIS; + aqcsfrc_mask = TI_EHRPWM_AQCSFRC_CSFB_MASK; + } else { + aqcsfrc_val = TI_EHRPWM_AQCSFRC_CSFA_FRCDIS; + aqcsfrc_mask = TI_EHRPWM_AQCSFRC_CSFA_MASK; + } + + /* Changes to shadow mode */ + ti_ehrpwm_modify(TI_EHRPWM_AQSFRC_RLDCSF_ZRO, + TI_EHRPWM_AQSFRC_RLDCSF_MASK, + priv->regs + TI_EHRPWM_AQSFRC); + + ti_ehrpwm_modify(aqcsfrc_val, aqcsfrc_mask, + priv->regs + TI_EHRPWM_AQCSFRC); + + /* Channels polarity can be configured from action qualifier module */ + ti_ehrpwm_configure_polarity(dev, channel); + + err = clk_enable(&priv->tbclk); + if (err) { + dev_err(dev, "failed to enable tbclk\n"); + return err; + } + + return 0; +} + +static int ti_ehrpwm_set_enable(struct udevice *dev, uint channel, bool enable) +{ + if (enable) + return ti_ehrpwm_enable(dev, channel); + + return ti_ehrpwm_disable(dev, channel); +} + +static int ti_ehrpwm_of_to_plat(struct udevice *dev) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + + priv->regs = dev_read_addr(dev); + if (priv->regs == FDT_ADDR_T_NONE) { + dev_err(dev, "invalid address\n"); + return -EINVAL; + } + + dev_dbg(dev, "regs=0x%08lx\n", priv->regs); + return 0; +} + +static int ti_ehrpwm_remove(struct udevice *dev) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + + clk_release_all(&priv->tbclk, 1); + return 0; +} + +static int ti_ehrpwm_probe(struct udevice *dev) +{ + struct ti_ehrpwm_priv *priv = dev_get_priv(dev); + struct clk clk; + int err; + + err = clk_get_by_name(dev, "fck", &clk); + if (err) { + dev_err(dev, "failed to get clock\n"); + return err; + } + + priv->clk_rate = clk_get_rate(&clk); + if (IS_ERR_VALUE(priv->clk_rate) || !priv->clk_rate) { + dev_err(dev, "failed to get clock rate\n"); + if (IS_ERR_VALUE(priv->clk_rate)) + return priv->clk_rate; + + return -EINVAL; + } + + /* Acquire tbclk for Time Base EHRPWM submodule */ + err = clk_get_by_name(dev, "tbclk", &priv->tbclk); + if (err) { + dev_err(dev, "failed to get tbclk clock\n"); + return err; + } + + return 0; +} + +static const struct pwm_ops ti_ehrpwm_ops = { + .set_config = ti_ehrpwm_set_config, + .set_enable = ti_ehrpwm_set_enable, + .set_invert = ti_ehrpwm_set_invert, +}; + +static const struct udevice_id ti_ehrpwm_ids[] = { + {.compatible = "ti,am3352-ehrpwm"}, + {.compatible = "ti,am33xx-ehrpwm"}, + {} +}; + +U_BOOT_DRIVER(ti_ehrpwm) = { + .name = "ti_ehrpwm", + .id = UCLASS_PWM, + .of_match = ti_ehrpwm_ids, + .ops = &ti_ehrpwm_ops, + .ofdata_to_platdata = ti_ehrpwm_of_to_plat, + .probe = ti_ehrpwm_probe, + .remove = ti_ehrpwm_remove, + .priv_auto = sizeof(struct ti_ehrpwm_priv), +}; diff --git a/drivers/pwm/rk_pwm.c b/drivers/pwm/rk_pwm.c index 911da1d426..a64fc4a052 100644 --- a/drivers/pwm/rk_pwm.c +++ b/drivers/pwm/rk_pwm.c @@ -121,7 +121,7 @@ static int rk_pwm_set_enable(struct udevice *dev, uint channel, bool enable) return 0; } -static int rk_pwm_ofdata_to_platdata(struct udevice *dev) +static int rk_pwm_of_to_plat(struct udevice *dev) { struct rk_pwm_priv *priv = dev_get_priv(dev); @@ -213,7 +213,7 @@ U_BOOT_DRIVER(rk_pwm) = { .id = UCLASS_PWM, .of_match = rk_pwm_ids, .ops = &rk_pwm_ops, - .ofdata_to_platdata = rk_pwm_ofdata_to_platdata, + .of_to_plat = rk_pwm_of_to_plat, .probe = rk_pwm_probe, - .priv_auto_alloc_size = sizeof(struct rk_pwm_priv), + .priv_auto = sizeof(struct rk_pwm_priv), }; diff --git a/drivers/pwm/sandbox_pwm.c b/drivers/pwm/sandbox_pwm.c index 28988187e0..318dce7c14 100644 --- a/drivers/pwm/sandbox_pwm.c +++ b/drivers/pwm/sandbox_pwm.c @@ -109,5 +109,5 @@ U_BOOT_DRIVER(warm_pwm_sandbox) = { .id = UCLASS_PWM, .of_match = sandbox_pwm_ids, .ops = &sandbox_pwm_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_pwm_priv), + .priv_auto = sizeof(struct sandbox_pwm_priv), }; diff --git a/drivers/pwm/sunxi_pwm.c b/drivers/pwm/sunxi_pwm.c index e2ae1a8009..614635526f 100644 --- a/drivers/pwm/sunxi_pwm.c +++ b/drivers/pwm/sunxi_pwm.c @@ -148,7 +148,7 @@ static int sunxi_pwm_set_enable(struct udevice *dev, uint channel, bool enable) return 0; } -static int sunxi_pwm_ofdata_to_platdata(struct udevice *dev) +static int sunxi_pwm_of_to_plat(struct udevice *dev) { struct sunxi_pwm_priv *priv = dev_get_priv(dev); @@ -179,7 +179,7 @@ U_BOOT_DRIVER(sunxi_pwm) = { .id = UCLASS_PWM, .of_match = sunxi_pwm_ids, .ops = &sunxi_pwm_ops, - .ofdata_to_platdata = sunxi_pwm_ofdata_to_platdata, + .of_to_plat = sunxi_pwm_of_to_plat, .probe = sunxi_pwm_probe, - .priv_auto_alloc_size = sizeof(struct sunxi_pwm_priv), + .priv_auto = sizeof(struct sunxi_pwm_priv), }; diff --git a/drivers/pwm/tegra_pwm.c b/drivers/pwm/tegra_pwm.c index 5e98d0fc2c..36c35c608b 100644 --- a/drivers/pwm/tegra_pwm.c +++ b/drivers/pwm/tegra_pwm.c @@ -53,7 +53,7 @@ static int tegra_pwm_set_enable(struct udevice *dev, uint channel, bool enable) return 0; } -static int tegra_pwm_ofdata_to_platdata(struct udevice *dev) +static int tegra_pwm_of_to_plat(struct udevice *dev) { struct tegra_pwm_priv *priv = dev_get_priv(dev); @@ -78,6 +78,6 @@ U_BOOT_DRIVER(tegra_pwm) = { .id = UCLASS_PWM, .of_match = tegra_pwm_ids, .ops = &tegra_pwm_ops, - .ofdata_to_platdata = tegra_pwm_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct tegra_pwm_priv), + .of_to_plat = tegra_pwm_of_to_plat, + .priv_auto = sizeof(struct tegra_pwm_priv), }; diff --git a/drivers/ram/aspeed/sdram_ast2500.c b/drivers/ram/aspeed/sdram_ast2500.c index 9f4304cb66..905ef304e2 100644 --- a/drivers/ram/aspeed/sdram_ast2500.c +++ b/drivers/ram/aspeed/sdram_ast2500.c @@ -386,7 +386,7 @@ static int ast2500_sdrammc_probe(struct udevice *dev) return 0; } -static int ast2500_sdrammc_ofdata_to_platdata(struct udevice *dev) +static int ast2500_sdrammc_of_to_plat(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); struct regmap *map; @@ -433,7 +433,7 @@ U_BOOT_DRIVER(sdrammc_ast2500) = { .id = UCLASS_RAM, .of_match = ast2500_sdrammc_ids, .ops = &ast2500_sdrammc_ops, - .ofdata_to_platdata = ast2500_sdrammc_ofdata_to_platdata, + .of_to_plat = ast2500_sdrammc_of_to_plat, .probe = ast2500_sdrammc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), }; diff --git a/drivers/ram/bmips_ram.c b/drivers/ram/bmips_ram.c index 8f953e79af..98045248ec 100644 --- a/drivers/ram/bmips_ram.c +++ b/drivers/ram/bmips_ram.c @@ -172,6 +172,6 @@ U_BOOT_DRIVER(bmips_ram) = { .id = UCLASS_RAM, .of_match = bmips_ram_ids, .probe = bmips_ram_probe, - .priv_auto_alloc_size = sizeof(struct bmips_ram_priv), + .priv_auto = sizeof(struct bmips_ram_priv), .ops = &bmips_ram_ops, }; diff --git a/drivers/ram/imxrt_sdram.c b/drivers/ram/imxrt_sdram.c index b6ee02d227..ca2eec767d 100644 --- a/drivers/ram/imxrt_sdram.c +++ b/drivers/ram/imxrt_sdram.c @@ -224,7 +224,7 @@ static int imxrt_sdram_ipcmd(struct imxrt_semc_regs *regs, u32 mem_addr, int imxrt_sdram_init(struct udevice *dev) { - struct imxrt_sdram_params *params = dev_get_platdata(dev); + struct imxrt_sdram_params *params = dev_get_plat(dev); struct imxrt_sdram_mux *mux = params->sdram_mux; struct imxrt_sdram_control *ctrl = params->sdram_control; struct imxrt_sdram_timing *time = params->sdram_timing; @@ -302,9 +302,9 @@ int imxrt_sdram_init(struct udevice *dev) return 0; } -static int imxrt_semc_ofdata_to_platdata(struct udevice *dev) +static int imxrt_semc_of_to_plat(struct udevice *dev) { - struct imxrt_sdram_params *params = dev_get_platdata(dev); + struct imxrt_sdram_params *params = dev_get_plat(dev); ofnode bank_node; u8 bank = 0; @@ -389,7 +389,7 @@ static int imxrt_semc_ofdata_to_platdata(struct udevice *dev) static int imxrt_semc_probe(struct udevice *dev) { - struct imxrt_sdram_params *params = dev_get_platdata(dev); + struct imxrt_sdram_params *params = dev_get_plat(dev); int ret; fdt_addr_t addr; @@ -439,7 +439,7 @@ U_BOOT_DRIVER(imxrt_semc) = { .id = UCLASS_RAM, .of_match = imxrt_semc_ids, .ops = &imxrt_semc_ops, - .ofdata_to_platdata = imxrt_semc_ofdata_to_platdata, + .of_to_plat = imxrt_semc_of_to_plat, .probe = imxrt_semc_probe, - .platdata_auto_alloc_size = sizeof(struct imxrt_sdram_params), + .plat_auto = sizeof(struct imxrt_sdram_params), }; diff --git a/drivers/ram/k3-am654-ddrss.c b/drivers/ram/k3-am654-ddrss.c index 21e5a65529..4ec12bf42e 100644 --- a/drivers/ram/k3-am654-ddrss.c +++ b/drivers/ram/k3-am654-ddrss.c @@ -1082,5 +1082,5 @@ U_BOOT_DRIVER(am654_ddrss) = { .of_match = am654_ddrss_ids, .ops = &am654_ddrss_ops, .probe = am654_ddrss_probe, - .priv_auto_alloc_size = sizeof(struct am654_ddrss_desc), + .priv_auto = sizeof(struct am654_ddrss_desc), }; diff --git a/drivers/ram/k3-j721e/k3-j721e-ddrss.c b/drivers/ram/k3-j721e/k3-j721e-ddrss.c index d647a8a209..9fb1eeea45 100644 --- a/drivers/ram/k3-j721e/k3-j721e-ddrss.c +++ b/drivers/ram/k3-j721e/k3-j721e-ddrss.c @@ -371,5 +371,5 @@ U_BOOT_DRIVER(j721e_ddrss) = { .of_match = j721e_ddrss_ids, .ops = &j721e_ddrss_ops, .probe = j721e_ddrss_probe, - .priv_auto_alloc_size = sizeof(struct j721e_ddrss_desc), + .priv_auto = sizeof(struct j721e_ddrss_desc), }; diff --git a/drivers/ram/mediatek/ddr3-mt7629.c b/drivers/ram/mediatek/ddr3-mt7629.c index b3a68cb078..d12a3b4f43 100644 --- a/drivers/ram/mediatek/ddr3-mt7629.c +++ b/drivers/ram/mediatek/ddr3-mt7629.c @@ -764,5 +764,5 @@ U_BOOT_DRIVER(mediatek_ddr3) = { .of_match = mtk_ddr3_ids, .ops = &mtk_ddr3_ops, .probe = mtk_ddr3_probe, - .priv_auto_alloc_size = sizeof(struct mtk_ddr3_priv), + .priv_auto = sizeof(struct mtk_ddr3_priv), }; diff --git a/drivers/ram/mpc83xx_sdram.c b/drivers/ram/mpc83xx_sdram.c index a226bac2cc..783834c9f5 100644 --- a/drivers/ram/mpc83xx_sdram.c +++ b/drivers/ram/mpc83xx_sdram.c @@ -305,7 +305,7 @@ static int mpc83xx_sdram_spd_init(ofnode node, u32 cs, u32 mapaddr, u32 size) return 0; } -static int mpc83xx_sdram_ofdata_to_platdata(struct udevice *dev) +static int mpc83xx_sdram_of_to_plat(struct udevice *dev) { return 0; } @@ -1093,7 +1093,7 @@ U_BOOT_DRIVER(mpc83xx_sdram) = { .id = UCLASS_RAM, .of_match = mpc83xx_sdram_ids, .ops = &mpc83xx_sdram_ops, - .ofdata_to_platdata = mpc83xx_sdram_ofdata_to_platdata, + .of_to_plat = mpc83xx_sdram_of_to_plat, .probe = mpc83xx_sdram_probe, - .priv_auto_alloc_size = sizeof(struct mpc83xx_sdram_priv), + .priv_auto = sizeof(struct mpc83xx_sdram_priv), }; diff --git a/drivers/ram/octeon/octeon_ddr.c b/drivers/ram/octeon/octeon_ddr.c index aaff9c3687..6bec68d1da 100644 --- a/drivers/ram/octeon/octeon_ddr.c +++ b/drivers/ram/octeon/octeon_ddr.c @@ -2724,5 +2724,5 @@ U_BOOT_DRIVER(octeon_ddr) = { .of_match = octeon_ids, .ops = &octeon_ops, .probe = octeon_ddr_probe, - .priv_auto_alloc_size = sizeof(struct ddr_priv), + .plat_auto = sizeof(struct ddr_priv), }; diff --git a/drivers/ram/rockchip/dmc-rk3368.c b/drivers/ram/rockchip/dmc-rk3368.c index 4fa632152f..a9d051852a 100644 --- a/drivers/ram/rockchip/dmc-rk3368.c +++ b/drivers/ram/rockchip/dmc-rk3368.c @@ -604,7 +604,7 @@ static int ddrphy_data_training(struct rk3368_ddr_pctl *pctl, static int sdram_col_row_detect(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); - struct rk3368_sdram_params *params = dev_get_platdata(dev); + struct rk3368_sdram_params *params = dev_get_plat(dev); struct rk3368_ddr_pctl *pctl = priv->pctl; struct rk3368_msch *msch = priv->msch; const u32 test_pattern = 0x5aa5f00f; @@ -774,7 +774,7 @@ static void dram_all_config(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); struct rk3368_pmu_grf *pmugrf = priv->pmugrf; - struct rk3368_sdram_params *params = dev_get_platdata(dev); + struct rk3368_sdram_params *params = dev_get_plat(dev); const struct rk3288_sdram_channel *info = ¶ms->chan; u32 sys_reg = 0; const int chan = 0; @@ -798,7 +798,7 @@ static void dram_all_config(struct udevice *dev) static int setup_sdram(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); - struct rk3368_sdram_params *params = dev_get_platdata(dev); + struct rk3368_sdram_params *params = dev_get_plat(dev); struct rk3368_ddr_pctl *pctl = priv->pctl; struct rk3368_ddrphy *ddrphy = priv->phy; @@ -879,12 +879,12 @@ error: } #endif -static int rk3368_dmc_ofdata_to_platdata(struct udevice *dev) +static int rk3368_dmc_of_to_plat(struct udevice *dev) { int ret = 0; #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3368_sdram_params *plat = dev_get_platdata(dev); + struct rk3368_sdram_params *plat = dev_get_plat(dev); ret = regmap_init_mem(dev_ofnode(dev), &plat->map); if (ret) @@ -895,9 +895,9 @@ static int rk3368_dmc_ofdata_to_platdata(struct udevice *dev) } #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int conv_of_platdata(struct udevice *dev) +static int conv_of_plat(struct udevice *dev) { - struct rk3368_sdram_params *plat = dev_get_platdata(dev); + struct rk3368_sdram_params *plat = dev_get_plat(dev); struct dtd_rockchip_rk3368_dmc *of_plat = &plat->of_plat; plat->ddr_freq = of_plat->rockchip_ddr_frequency; @@ -911,7 +911,7 @@ static int conv_of_platdata(struct udevice *dev) static int rk3368_dmc_probe(struct udevice *dev) { #ifdef CONFIG_TPL_BUILD - struct rk3368_sdram_params *plat = dev_get_platdata(dev); + struct rk3368_sdram_params *plat = dev_get_plat(dev); struct rk3368_ddr_pctl *pctl; struct rk3368_ddrphy *ddrphy; struct rk3368_cru *cru; @@ -923,7 +923,7 @@ static int rk3368_dmc_probe(struct udevice *dev) struct dram_info *priv = dev_get_priv(dev); #if CONFIG_IS_ENABLED(OF_PLATDATA) - ret = conv_of_platdata(dev); + ret = conv_of_plat(dev); if (ret) return ret; #endif @@ -998,9 +998,9 @@ U_BOOT_DRIVER(rockchip_rk3368_dmc) = { .of_match = rk3368_dmc_ids, .ops = &rk3368_dmc_ops, .probe = rk3368_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), - .ofdata_to_platdata = rk3368_dmc_ofdata_to_platdata, + .priv_auto = sizeof(struct dram_info), + .of_to_plat = rk3368_dmc_of_to_plat, .probe = rk3368_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), - .platdata_auto_alloc_size = sizeof(struct rk3368_sdram_params), + .priv_auto = sizeof(struct dram_info), + .plat_auto = sizeof(struct rk3368_sdram_params), }; diff --git a/drivers/ram/rockchip/sdram_px30.c b/drivers/ram/rockchip/sdram_px30.c index 2f1f6e9c0c..c024a0cd63 100644 --- a/drivers/ram/rockchip/sdram_px30.c +++ b/drivers/ram/rockchip/sdram_px30.c @@ -757,6 +757,6 @@ U_BOOT_DRIVER(dmc_px30) = { .of_match = px30_dmc_ids, .ops = &px30_dmc_ops, .probe = px30_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), }; #endif /* CONFIG_TPL_BUILD */ diff --git a/drivers/ram/rockchip/sdram_rk3128.c b/drivers/ram/rockchip/sdram_rk3128.c index 0162955aae..16cfbf947b 100644 --- a/drivers/ram/rockchip/sdram_rk3128.c +++ b/drivers/ram/rockchip/sdram_rk3128.c @@ -54,5 +54,5 @@ U_BOOT_DRIVER(dmc_rk3128) = { .of_match = rk3128_dmc_ids, .ops = &rk3128_dmc_ops, .probe = rk3128_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), }; diff --git a/drivers/ram/rockchip/sdram_rk3188.c b/drivers/ram/rockchip/sdram_rk3188.c index 06f9eba1a5..25ae69e9ac 100644 --- a/drivers/ram/rockchip/sdram_rk3188.c +++ b/drivers/ram/rockchip/sdram_rk3188.c @@ -809,15 +809,15 @@ error: static int setup_sdram(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); - struct rk3188_sdram_params *params = dev_get_platdata(dev); + struct rk3188_sdram_params *params = dev_get_plat(dev); return sdram_init(priv, params); } -static int rk3188_dmc_ofdata_to_platdata(struct udevice *dev) +static int rk3188_dmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3188_sdram_params *params = dev_get_platdata(dev); + struct rk3188_sdram_params *params = dev_get_plat(dev); int ret; /* rk3188 supports only one-channel */ @@ -853,9 +853,9 @@ static int rk3188_dmc_ofdata_to_platdata(struct udevice *dev) #endif /* CONFIG_SPL_BUILD */ #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int conv_of_platdata(struct udevice *dev) +static int conv_of_plat(struct udevice *dev) { - struct rk3188_sdram_params *plat = dev_get_platdata(dev); + struct rk3188_sdram_params *plat = dev_get_plat(dev); struct dtd_rockchip_rk3188_dmc *of_plat = &plat->of_plat; int ret; @@ -866,9 +866,8 @@ static int conv_of_platdata(struct udevice *dev) memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base)); /* rk3188 supports dual-channel, set default channel num to 2 */ plat->num_channels = 1; - ret = regmap_init_mem_platdata(dev, of_plat->reg, - ARRAY_SIZE(of_plat->reg) / 2, - &plat->map); + ret = regmap_init_mem_plat(dev, of_plat->reg, + ARRAY_SIZE(of_plat->reg) / 2, &plat->map); if (ret) return ret; @@ -879,7 +878,7 @@ static int conv_of_platdata(struct udevice *dev) static int rk3188_dmc_probe(struct udevice *dev) { #ifdef CONFIG_SPL_BUILD - struct rk3188_sdram_params *plat = dev_get_platdata(dev); + struct rk3188_sdram_params *plat = dev_get_plat(dev); struct regmap *map; struct udevice *dev_clk; int ret; @@ -890,7 +889,7 @@ static int rk3188_dmc_probe(struct udevice *dev) #ifdef CONFIG_SPL_BUILD #if CONFIG_IS_ENABLED(OF_PLATDATA) - ret = conv_of_platdata(dev); + ret = conv_of_plat(dev); if (ret) return ret; #endif @@ -951,11 +950,11 @@ U_BOOT_DRIVER(rockchip_rk3188_dmc) = { .of_match = rk3188_dmc_ids, .ops = &rk3188_dmc_ops, #ifdef CONFIG_SPL_BUILD - .ofdata_to_platdata = rk3188_dmc_ofdata_to_platdata, + .of_to_plat = rk3188_dmc_of_to_plat, #endif .probe = rk3188_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), #ifdef CONFIG_SPL_BUILD - .platdata_auto_alloc_size = sizeof(struct rk3188_sdram_params), + .plat_auto = sizeof(struct rk3188_sdram_params), #endif }; diff --git a/drivers/ram/rockchip/sdram_rk322x.c b/drivers/ram/rockchip/sdram_rk322x.c index 094693ce24..66235bd420 100644 --- a/drivers/ram/rockchip/sdram_rk322x.c +++ b/drivers/ram/rockchip/sdram_rk322x.c @@ -713,10 +713,10 @@ out: return ret; } -static int rk322x_dmc_ofdata_to_platdata(struct udevice *dev) +static int rk322x_dmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk322x_sdram_params *params = dev_get_platdata(dev); + struct rk322x_sdram_params *params = dev_get_plat(dev); const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); int ret; @@ -754,9 +754,9 @@ static int rk322x_dmc_ofdata_to_platdata(struct udevice *dev) #endif /* CONFIG_TPL_BUILD */ #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int conv_of_platdata(struct udevice *dev) +static int conv_of_plat(struct udevice *dev) { - struct rk322x_sdram_params *plat = dev_get_platdata(dev); + struct rk322x_sdram_params *plat = dev_get_plat(dev); struct dtd_rockchip_rk322x_dmc *of_plat = &plat->of_plat; int ret; @@ -767,9 +767,8 @@ static int conv_of_platdata(struct udevice *dev) memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base)); plat->num_channels = 1; - ret = regmap_init_mem_platdata(dev, of_plat->reg, - ARRAY_SIZE(of_plat->reg) / 2, - &plat->map); + ret = regmap_init_mem_plat(dev, of_plat->reg, + ARRAY_SIZE(of_plat->reg) / 2, &plat->map); if (ret) return ret; @@ -780,7 +779,7 @@ static int conv_of_platdata(struct udevice *dev) static int rk322x_dmc_probe(struct udevice *dev) { #ifdef CONFIG_TPL_BUILD - struct rk322x_sdram_params *plat = dev_get_platdata(dev); + struct rk322x_sdram_params *plat = dev_get_plat(dev); int ret; struct udevice *dev_clk; #endif @@ -789,7 +788,7 @@ static int rk322x_dmc_probe(struct udevice *dev) priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); #ifdef CONFIG_TPL_BUILD #if CONFIG_IS_ENABLED(OF_PLATDATA) - ret = conv_of_platdata(dev); + ret = conv_of_plat(dev); if (ret) return ret; #endif @@ -844,12 +843,12 @@ U_BOOT_DRIVER(dmc_rk322x) = { .of_match = rk322x_dmc_ids, .ops = &rk322x_dmc_ops, #ifdef CONFIG_TPL_BUILD - .ofdata_to_platdata = rk322x_dmc_ofdata_to_platdata, + .of_to_plat = rk322x_dmc_of_to_plat, #endif .probe = rk322x_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), #ifdef CONFIG_TPL_BUILD - .platdata_auto_alloc_size = sizeof(struct rk322x_sdram_params), + .plat_auto = sizeof(struct rk322x_sdram_params), #endif }; diff --git a/drivers/ram/rockchip/sdram_rk3288.c b/drivers/ram/rockchip/sdram_rk3288.c index 26e8d059b5..a933abf0d4 100644 --- a/drivers/ram/rockchip/sdram_rk3288.c +++ b/drivers/ram/rockchip/sdram_rk3288.c @@ -956,7 +956,7 @@ static int veyron_init(struct dram_info *priv) static int setup_sdram(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); - struct rk3288_sdram_params *params = dev_get_platdata(dev); + struct rk3288_sdram_params *params = dev_get_plat(dev); # ifdef CONFIG_ROCKCHIP_FAST_SPL if (priv->is_veyron) { @@ -971,10 +971,10 @@ static int setup_sdram(struct udevice *dev) return sdram_init(priv, params); } -static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev) +static int rk3288_dmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct rk3288_sdram_params *params = dev_get_platdata(dev); + struct rk3288_sdram_params *params = dev_get_plat(dev); int ret; /* Rk3288 supports dual-channel, set default channel num to 2 */ @@ -1015,9 +1015,9 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev) #endif /* CONFIG_SPL_BUILD */ #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int conv_of_platdata(struct udevice *dev) +static int conv_of_plat(struct udevice *dev) { - struct rk3288_sdram_params *plat = dev_get_platdata(dev); + struct rk3288_sdram_params *plat = dev_get_plat(dev); struct dtd_rockchip_rk3288_dmc *of_plat = &plat->of_plat; int ret; @@ -1028,9 +1028,8 @@ static int conv_of_platdata(struct udevice *dev) memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base)); /* Rk3288 supports dual-channel, set default channel num to 2 */ plat->num_channels = 2; - ret = regmap_init_mem_platdata(dev, of_plat->reg, - ARRAY_SIZE(of_plat->reg) / 2, - &plat->map); + ret = regmap_init_mem_plat(dev, of_plat->reg, + ARRAY_SIZE(of_plat->reg) / 2, &plat->map); if (ret) return ret; @@ -1042,7 +1041,7 @@ static int rk3288_dmc_probe(struct udevice *dev) { #if defined(CONFIG_TPL_BUILD) || \ (!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)) - struct rk3288_sdram_params *plat = dev_get_platdata(dev); + struct rk3288_sdram_params *plat = dev_get_plat(dev); struct udevice *dev_clk; struct regmap *map; int ret; @@ -1053,7 +1052,7 @@ static int rk3288_dmc_probe(struct udevice *dev) #if defined(CONFIG_TPL_BUILD) || \ (!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)) #if CONFIG_IS_ENABLED(OF_PLATDATA) - ret = conv_of_platdata(dev); + ret = conv_of_plat(dev); if (ret) return ret; #endif @@ -1120,12 +1119,12 @@ U_BOOT_DRIVER(rockchip_rk3288_dmc) = { .ops = &rk3288_dmc_ops, #if defined(CONFIG_TPL_BUILD) || \ (!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)) - .ofdata_to_platdata = rk3288_dmc_ofdata_to_platdata, + .of_to_plat = rk3288_dmc_of_to_plat, #endif .probe = rk3288_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), #if defined(CONFIG_TPL_BUILD) || \ (!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)) - .platdata_auto_alloc_size = sizeof(struct rk3288_sdram_params), + .plat_auto = sizeof(struct rk3288_sdram_params), #endif }; diff --git a/drivers/ram/rockchip/sdram_rk3308.c b/drivers/ram/rockchip/sdram_rk3308.c index 310df79123..44d7d8a0d9 100644 --- a/drivers/ram/rockchip/sdram_rk3308.c +++ b/drivers/ram/rockchip/sdram_rk3308.c @@ -51,5 +51,5 @@ U_BOOT_DRIVER(dmc_rk3308) = { .of_match = rk3308_dmc_ids, .ops = &rk3308_dmc_ops, .probe = rk3308_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), }; diff --git a/drivers/ram/rockchip/sdram_rk3328.c b/drivers/ram/rockchip/sdram_rk3328.c index 98c7feb6cf..9af4c372d5 100644 --- a/drivers/ram/rockchip/sdram_rk3328.c +++ b/drivers/ram/rockchip/sdram_rk3328.c @@ -48,15 +48,14 @@ struct rockchip_dmc_plat { }; #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int conv_of_platdata(struct udevice *dev) +static int conv_of_plat(struct udevice *dev) { - struct rockchip_dmc_plat *plat = dev_get_platdata(dev); + struct rockchip_dmc_plat *plat = dev_get_plat(dev); struct dtd_rockchip_rk3328_dmc *dtplat = &plat->dtplat; int ret; - ret = regmap_init_mem_platdata(dev, dtplat->reg, - ARRAY_SIZE(dtplat->reg) / 2, - &plat->map); + ret = regmap_init_mem_plat(dev, dtplat->reg, + ARRAY_SIZE(dtplat->reg) / 2, &plat->map); if (ret) return ret; @@ -515,7 +514,7 @@ static int sdram_init_detect(struct dram_info *dram, static int rk3328_dmc_init(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); - struct rockchip_dmc_plat *plat = dev_get_platdata(dev); + struct rockchip_dmc_plat *plat = dev_get_plat(dev); int ret; #if !CONFIG_IS_ENABLED(OF_PLATDATA) @@ -525,7 +524,7 @@ static int rk3328_dmc_init(struct udevice *dev) struct rk3328_sdram_params *params = (void *)dtplat->rockchip_sdram_params; - ret = conv_of_platdata(dev); + ret = conv_of_plat(dev); if (ret) return ret; #endif @@ -548,10 +547,10 @@ static int rk3328_dmc_init(struct udevice *dev) return 0; } -static int rk3328_dmc_ofdata_to_platdata(struct udevice *dev) +static int rk3328_dmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct rockchip_dmc_plat *plat = dev_get_platdata(dev); + struct rockchip_dmc_plat *plat = dev_get_plat(dev); int ret; ret = dev_read_u32_array(dev, "rockchip,sdram-params", @@ -612,11 +611,11 @@ U_BOOT_DRIVER(rockchip_rk3328_dmc) = { .of_match = rk3328_dmc_ids, .ops = &rk3328_dmc_ops, #ifdef CONFIG_TPL_BUILD - .ofdata_to_platdata = rk3328_dmc_ofdata_to_platdata, + .of_to_plat = rk3328_dmc_of_to_plat, #endif .probe = rk3328_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), #ifdef CONFIG_TPL_BUILD - .platdata_auto_alloc_size = sizeof(struct rockchip_dmc_plat), + .plat_auto = sizeof(struct rockchip_dmc_plat), #endif }; diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 530c8a2f40..a83a670b32 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -3011,10 +3011,10 @@ static int sdram_init(struct dram_info *dram, return 0; } -static int rk3399_dmc_ofdata_to_platdata(struct udevice *dev) +static int rk3399_dmc_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct rockchip_dmc_plat *plat = dev_get_platdata(dev); + struct rockchip_dmc_plat *plat = dev_get_plat(dev); int ret; ret = dev_read_u32_array(dev, "rockchip,sdram-params", @@ -3034,15 +3034,14 @@ static int rk3399_dmc_ofdata_to_platdata(struct udevice *dev) } #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int conv_of_platdata(struct udevice *dev) +static int conv_of_plat(struct udevice *dev) { - struct rockchip_dmc_plat *plat = dev_get_platdata(dev); + struct rockchip_dmc_plat *plat = dev_get_plat(dev); struct dtd_rockchip_rk3399_dmc *dtplat = &plat->dtplat; int ret; - ret = regmap_init_mem_platdata(dev, dtplat->reg, - ARRAY_SIZE(dtplat->reg) / 2, - &plat->map); + ret = regmap_init_mem_plat(dev, dtplat->reg, + ARRAY_SIZE(dtplat->reg) / 2, &plat->map); if (ret) return ret; @@ -3067,7 +3066,7 @@ static const struct sdram_rk3399_ops rk3399_ops = { static int rk3399_dmc_init(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); - struct rockchip_dmc_plat *plat = dev_get_platdata(dev); + struct rockchip_dmc_plat *plat = dev_get_plat(dev); int ret; #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rk3399_sdram_params *params = &plat->sdram_params; @@ -3076,7 +3075,7 @@ static int rk3399_dmc_init(struct udevice *dev) struct rk3399_sdram_params *params = (void *)dtplat->rockchip_sdram_params; - ret = conv_of_platdata(dev); + ret = conv_of_plat(dev); if (ret) return ret; #endif @@ -3175,12 +3174,12 @@ U_BOOT_DRIVER(dmc_rk3399) = { .ops = &rk3399_dmc_ops, #if defined(CONFIG_TPL_BUILD) || \ (!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)) - .ofdata_to_platdata = rk3399_dmc_ofdata_to_platdata, + .of_to_plat = rk3399_dmc_of_to_plat, #endif .probe = rk3399_dmc_probe, - .priv_auto_alloc_size = sizeof(struct dram_info), + .priv_auto = sizeof(struct dram_info), #if defined(CONFIG_TPL_BUILD) || \ (!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)) - .platdata_auto_alloc_size = sizeof(struct rockchip_dmc_plat), + .plat_auto = sizeof(struct rockchip_dmc_plat), #endif }; diff --git a/drivers/ram/sifive/fu540_ddr.c b/drivers/ram/sifive/fu540_ddr.c index 60d4945f84..5a7484ce48 100644 --- a/drivers/ram/sifive/fu540_ddr.c +++ b/drivers/ram/sifive/fu540_ddr.c @@ -230,7 +230,7 @@ static u32 fu540_ddr_get_dram_class(volatile u32 *ctl) static int fu540_ddr_setup(struct udevice *dev) { struct fu540_ddr_info *priv = dev_get_priv(dev); - struct sifive_dmc_plat *plat = dev_get_platdata(dev); + struct sifive_dmc_plat *plat = dev_get_plat(dev); struct fu540_ddr_params *params = &plat->ddr_params; volatile u32 *denali_ctl = priv->ctl->denali_ctl; volatile u32 *denali_phy = priv->phy->denali_phy; @@ -402,8 +402,8 @@ U_BOOT_DRIVER(fu540_ddr) = { .of_match = fu540_ddr_ids, .ops = &fu540_ddr_ops, .probe = fu540_ddr_probe, - .priv_auto_alloc_size = sizeof(struct fu540_ddr_info), + .priv_auto = sizeof(struct fu540_ddr_info), #if defined(CONFIG_SPL_BUILD) - .platdata_auto_alloc_size = sizeof(struct sifive_dmc_plat), + .plat_auto = sizeof(struct sifive_dmc_plat), #endif }; diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c index 3fddf4df96..4003db0e50 100644 --- a/drivers/ram/stm32_sdram.c +++ b/drivers/ram/stm32_sdram.c @@ -161,7 +161,7 @@ struct stm32_sdram_params { int stm32_sdram_init(struct udevice *dev) { - struct stm32_sdram_params *params = dev_get_platdata(dev); + struct stm32_sdram_params *params = dev_get_plat(dev); struct stm32_sdram_control *control; struct stm32_sdram_timing *timing; struct stm32_fmc_regs *regs = params->base; @@ -256,9 +256,9 @@ int stm32_sdram_init(struct udevice *dev) return 0; } -static int stm32_fmc_ofdata_to_platdata(struct udevice *dev) +static int stm32_fmc_of_to_plat(struct udevice *dev) { - struct stm32_sdram_params *params = dev_get_platdata(dev); + struct stm32_sdram_params *params = dev_get_plat(dev); struct bank_params *bank_params; struct ofnode_phandle_args args; u32 *syscfg_base; @@ -355,7 +355,7 @@ static int stm32_fmc_ofdata_to_platdata(struct udevice *dev) static int stm32_fmc_probe(struct udevice *dev) { - struct stm32_sdram_params *params = dev_get_platdata(dev); + struct stm32_sdram_params *params = dev_get_plat(dev); int ret; fdt_addr_t addr; @@ -407,7 +407,7 @@ U_BOOT_DRIVER(stm32_fmc) = { .id = UCLASS_RAM, .of_match = stm32_fmc_ids, .ops = &stm32_fmc_ops, - .ofdata_to_platdata = stm32_fmc_ofdata_to_platdata, + .of_to_plat = stm32_fmc_of_to_plat, .probe = stm32_fmc_probe, - .platdata_auto_alloc_size = sizeof(struct stm32_sdram_params), + .plat_auto = sizeof(struct stm32_sdram_params), }; diff --git a/drivers/ram/stm32mp1/stm32mp1_ram.c b/drivers/ram/stm32mp1/stm32mp1_ram.c index 9022679703..0b6d20f566 100644 --- a/drivers/ram/stm32mp1/stm32mp1_ram.c +++ b/drivers/ram/stm32mp1/stm32mp1_ram.c @@ -235,5 +235,5 @@ U_BOOT_DRIVER(ddr_stm32mp1) = { .of_match = stm32mp1_ddr_ids, .ops = &stm32mp1_ddr_ops, .probe = stm32mp1_ddr_probe, - .priv_auto_alloc_size = sizeof(struct ddr_info), + .priv_auto = sizeof(struct ddr_info), }; diff --git a/drivers/remoteproc/k3_system_controller.c b/drivers/remoteproc/k3_system_controller.c index 702d98d1a8..89cb90207d 100644 --- a/drivers/remoteproc/k3_system_controller.c +++ b/drivers/remoteproc/k3_system_controller.c @@ -322,5 +322,5 @@ U_BOOT_DRIVER(k3_sysctrler) = { .id = UCLASS_REMOTEPROC, .ops = &k3_sysctrler_ops, .probe = k3_sysctrler_probe, - .priv_auto_alloc_size = sizeof(struct k3_sysctrler_privdata), + .priv_auto = sizeof(struct k3_sysctrler_privdata), }; diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c index 9640a81e53..c2d6a4e0c1 100644 --- a/drivers/remoteproc/rproc-uclass.c +++ b/drivers/remoteproc/rproc-uclass.c @@ -42,7 +42,7 @@ static int for_each_remoteproc_device(int (*fn) (struct udevice *dev, ret = uclass_find_next_device(&dev)) { if (ret || dev == skip_dev) continue; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = fn(dev, uc_pdata, data); if (ret) return ret; @@ -111,11 +111,11 @@ static int rproc_pre_probe(struct udevice *dev) struct dm_rproc_uclass_pdata *uc_pdata; const struct dm_rproc_ops *ops; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); /* See if we need to populate via fdt */ - if (!dev->platdata) { + if (!dev_get_plat(dev)) { #if CONFIG_IS_ENABLED(OF_CONTROL) int node = dev_of_offset(dev); const void *blob = gd->fdt_blob; @@ -140,7 +140,7 @@ static int rproc_pre_probe(struct udevice *dev) #endif } else { - struct dm_rproc_uclass_pdata *pdata = dev->platdata; + struct dm_rproc_uclass_pdata *pdata = dev_get_plat(dev); debug("'%s': using legacy data\n", dev->name); if (pdata->name) @@ -210,8 +210,7 @@ UCLASS_DRIVER(rproc) = { .flags = DM_UC_FLAG_SEQ_ALIAS, .pre_probe = rproc_pre_probe, .post_probe = rproc_post_probe, - .per_device_platdata_auto_alloc_size = - sizeof(struct dm_rproc_uclass_pdata), + .per_device_plat_auto = sizeof(struct dm_rproc_uclass_pdata), }; /* Remoteproc subsystem access functions */ @@ -248,7 +247,7 @@ static int _rproc_dev_is_probed(struct udevice *dev, struct dm_rproc_uclass_pdata *uc_pdata, const void *data) { - if (dev->flags & DM_FLAG_ACTIVATED) + if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) return 0; return -EAGAIN; @@ -306,7 +305,7 @@ int rproc_load(int id, ulong addr, ulong size) return ret; } - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ops = rproc_get_ops(dev); if (!ops) { @@ -366,7 +365,7 @@ static int _rproc_ops_wrapper(int id, enum rproc_ops op) return ret; } - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ops = rproc_get_ops(dev); if (!ops) { diff --git a/drivers/remoteproc/sandbox_testproc.c b/drivers/remoteproc/sandbox_testproc.c index 2b58b27947..6836eca4c5 100644 --- a/drivers/remoteproc/sandbox_testproc.c +++ b/drivers/remoteproc/sandbox_testproc.c @@ -128,7 +128,7 @@ static int sandbox_testproc_probe(struct udevice *dev) struct sandbox_test_devdata *ddata; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ddata = dev_get_priv(dev); if (!ddata) { debug("%s: platform private data missing\n", uc_pdata->name); @@ -151,7 +151,7 @@ static int sandbox_testproc_init(struct udevice *dev) struct dm_rproc_uclass_pdata *uc_pdata; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = sandbox_dev_move_to_state(dev, sb_init); @@ -173,7 +173,7 @@ static int sandbox_testproc_reset(struct udevice *dev) struct dm_rproc_uclass_pdata *uc_pdata; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = sandbox_dev_move_to_state(dev, sb_reset); @@ -197,7 +197,7 @@ static int sandbox_testproc_load(struct udevice *dev, ulong addr, ulong size) struct dm_rproc_uclass_pdata *uc_pdata; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = sandbox_dev_move_to_state(dev, sb_loaded); @@ -220,7 +220,7 @@ static int sandbox_testproc_start(struct udevice *dev) struct dm_rproc_uclass_pdata *uc_pdata; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = sandbox_dev_move_to_state(dev, sb_running); @@ -242,7 +242,7 @@ static int sandbox_testproc_stop(struct udevice *dev) struct dm_rproc_uclass_pdata *uc_pdata; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ret = sandbox_dev_move_to_state(dev, sb_init); @@ -265,7 +265,7 @@ static int sandbox_testproc_is_running(struct udevice *dev) struct sandbox_test_devdata *ddata; int ret = 1; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ddata = dev_get_priv(dev); if (ddata->current_state == sb_running) @@ -287,7 +287,7 @@ static int sandbox_testproc_ping(struct udevice *dev) struct sandbox_test_devdata *ddata; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ddata = dev_get_priv(dev); if (ddata->current_state == sb_running) @@ -343,7 +343,7 @@ U_BOOT_DRIVER(sandbox_testproc) = { .id = UCLASS_REMOTEPROC, .ops = &sandbox_testproc_ops, .probe = sandbox_testproc_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_test_devdata), + .priv_auto = sizeof(struct sandbox_test_devdata), }; /* TODO(nm@ti.com): Remove this along with non-DT support */ @@ -352,7 +352,7 @@ static struct dm_rproc_uclass_pdata proc_3_test = { .mem_type = RPROC_INTERNAL_MEMORY_MAPPED, }; -U_BOOT_DEVICE(proc_3_demo) = { +U_BOOT_DRVINFO(proc_3_demo) = { .name = "sandbox_test_proc", - .platdata = &proc_3_test, + .plat = &proc_3_test, }; diff --git a/drivers/remoteproc/stm32_copro.c b/drivers/remoteproc/stm32_copro.c index dc87cb794e..ec7694dda9 100644 --- a/drivers/remoteproc/stm32_copro.c +++ b/drivers/remoteproc/stm32_copro.c @@ -222,5 +222,5 @@ U_BOOT_DRIVER(stm32_copro) = { .id = UCLASS_REMOTEPROC, .ops = &stm32_copro_ops, .probe = stm32_copro_probe, - .priv_auto_alloc_size = sizeof(struct stm32_copro_privdata), + .priv_auto = sizeof(struct stm32_copro_privdata), }; diff --git a/drivers/remoteproc/ti_k3_arm64_rproc.c b/drivers/remoteproc/ti_k3_arm64_rproc.c index 28c6ddb691..1f2415dc1a 100644 --- a/drivers/remoteproc/ti_k3_arm64_rproc.c +++ b/drivers/remoteproc/ti_k3_arm64_rproc.c @@ -23,6 +23,7 @@ #define INVALID_ID 0xffff #define GTC_CNTCR_REG 0x0 +#define GTC_CNTFID0_REG 0x20 #define GTC_CNTR_EN 0x3 /** @@ -31,6 +32,7 @@ * @rproc_rst: rproc reset control data * @sci: Pointer to TISCI handle * @tsp: TISCI processor control helper structure + * @gtc_clk: GTC clock description * @gtc_base: Timer base address. */ struct k3_arm64_privdata { @@ -38,6 +40,7 @@ struct k3_arm64_privdata { struct power_domain gtc_pwrdmn; struct reset_ctl rproc_rst; struct ti_sci_proc tsp; + struct clk gtc_clk; void *gtc_base; }; @@ -73,6 +76,7 @@ static int k3_arm64_load(struct udevice *dev, ulong addr, ulong size) static int k3_arm64_start(struct udevice *dev) { struct k3_arm64_privdata *rproc = dev_get_priv(dev); + ulong gtc_rate; int ret; dev_dbg(dev, "%s\n", __func__); @@ -83,6 +87,11 @@ static int k3_arm64_start(struct udevice *dev) return ret; } + gtc_rate = clk_get_rate(&rproc->gtc_clk); + dev_dbg(dev, "GTC RATE= %d\n", (u32) gtc_rate); + /* Store the clock frequency down for GTC users to pick up */ + writel((u32)gtc_rate, rproc->gtc_base + GTC_CNTFID0_REG); + /* Enable the timer before starting remote core */ writel(GTC_CNTR_EN, rproc->gtc_base + GTC_CNTCR_REG); @@ -169,6 +178,12 @@ static int k3_arm64_of_to_priv(struct udevice *dev, return ret; } + ret = clk_get_by_index(dev, 0, &rproc->gtc_clk); + if (ret) { + dev_err(dev, "clk_get failed: %d\n", ret); + return ret; + } + ret = reset_get_by_index(dev, 0, &rproc->rproc_rst); if (ret) { dev_err(dev, "reset_get() failed: %d\n", ret); @@ -226,6 +241,6 @@ U_BOOT_DRIVER(k3_arm64) = { .id = UCLASS_REMOTEPROC, .ops = &k3_arm64_ops, .probe = k3_arm64_probe, - .priv_auto_alloc_size = sizeof(struct k3_arm64_privdata), + .priv_auto = sizeof(struct k3_arm64_privdata), .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, }; diff --git a/drivers/remoteproc/ti_k3_dsp_rproc.c b/drivers/remoteproc/ti_k3_dsp_rproc.c index 3361555c53..1a2e9dd1f5 100644 --- a/drivers/remoteproc/ti_k3_dsp_rproc.c +++ b/drivers/remoteproc/ti_k3_dsp_rproc.c @@ -456,5 +456,5 @@ U_BOOT_DRIVER(k3_dsp) = { .ops = &k3_dsp_ops, .probe = k3_dsp_probe, .remove = k3_dsp_remove, - .priv_auto_alloc_size = sizeof(struct k3_dsp_privdata), + .priv_auto = sizeof(struct k3_dsp_privdata), }; diff --git a/drivers/remoteproc/ti_k3_r5f_rproc.c b/drivers/remoteproc/ti_k3_r5f_rproc.c index 9332a63d21..10bc4e99f0 100644 --- a/drivers/remoteproc/ti_k3_r5f_rproc.c +++ b/drivers/remoteproc/ti_k3_r5f_rproc.c @@ -866,7 +866,7 @@ U_BOOT_DRIVER(k3_r5f_rproc) = { .ops = &k3_r5f_rproc_ops, .probe = k3_r5f_probe, .remove = k3_r5f_remove, - .priv_auto_alloc_size = sizeof(struct k3_r5f_core), + .priv_auto = sizeof(struct k3_r5f_core), }; static int k3_r5f_cluster_probe(struct udevice *dev) @@ -901,6 +901,6 @@ U_BOOT_DRIVER(k3_r5fss) = { .of_match = k3_r5fss_ids, .id = UCLASS_MISC, .probe = k3_r5f_cluster_probe, - .priv_auto_alloc_size = sizeof(struct k3_r5f_cluster), + .priv_auto = sizeof(struct k3_r5f_cluster), .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, }; diff --git a/drivers/remoteproc/ti_power_proc.c b/drivers/remoteproc/ti_power_proc.c index 350450d1fb..9dbbb44e95 100644 --- a/drivers/remoteproc/ti_power_proc.c +++ b/drivers/remoteproc/ti_power_proc.c @@ -71,7 +71,7 @@ static int ti_powerproc_probe(struct udevice *dev) struct ti_powerproc_privdata *priv; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); priv = dev_get_priv(dev); ret = ti_of_to_priv(dev, priv); @@ -96,7 +96,7 @@ static int ti_powerproc_load(struct udevice *dev, ulong addr, ulong size) struct ti_powerproc_privdata *priv; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) { debug("%s: no uc pdata!\n", dev->name); return -EINVAL; @@ -131,7 +131,7 @@ static int ti_powerproc_start(struct udevice *dev) struct ti_powerproc_privdata *priv; int ret; - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); if (!uc_pdata) { debug("%s: no uc pdata!\n", dev->name); return -EINVAL; @@ -177,5 +177,5 @@ U_BOOT_DRIVER(ti_powerproc) = { .id = UCLASS_REMOTEPROC, .ops = &ti_powerproc_ops, .probe = ti_powerproc_probe, - .priv_auto_alloc_size = sizeof(struct ti_powerproc_privdata), + .priv_auto = sizeof(struct ti_powerproc_privdata), }; diff --git a/drivers/reset/reset-ast2500.c b/drivers/reset/reset-ast2500.c index e7b5c7deca..c3d650fc6b 100644 --- a/drivers/reset/reset-ast2500.c +++ b/drivers/reset/reset-ast2500.c @@ -72,7 +72,7 @@ static int ast2500_reset_probe(struct udevice *dev) /* get SCU base from clock device */ rc = uclass_get_device_by_driver(UCLASS_CLK, - DM_GET_DRIVER(aspeed_ast2500_scu), &scu_dev); + DM_DRIVER_GET(aspeed_ast2500_scu), &scu_dev); if (rc) { debug("%s: clock device not found, rc=%d\n", __func__, rc); return rc; @@ -105,5 +105,5 @@ U_BOOT_DRIVER(ast2500_reset) = { .of_match = ast2500_reset_ids, .probe = ast2500_reset_probe, .ops = &ast2500_reset_ops, - .priv_auto_alloc_size = sizeof(struct ast2500_reset_priv), + .priv_auto = sizeof(struct ast2500_reset_priv), }; diff --git a/drivers/reset/reset-bcm6345.c b/drivers/reset/reset-bcm6345.c index 156703e084..f69189822b 100644 --- a/drivers/reset/reset-bcm6345.c +++ b/drivers/reset/reset-bcm6345.c @@ -84,5 +84,5 @@ U_BOOT_DRIVER(bcm6345_reset) = { .of_match = bcm6345_reset_ids, .ops = &bcm6345_reset_reset_ops, .probe = bcm6345_reset_probe, - .priv_auto_alloc_size = sizeof(struct bcm6345_reset_priv), + .priv_auto = sizeof(struct bcm6345_reset_priv), }; diff --git a/drivers/reset/reset-hisilicon.c b/drivers/reset/reset-hisilicon.c index 139bc5d73e..3f9da8cc8d 100644 --- a/drivers/reset/reset-hisilicon.c +++ b/drivers/reset/reset-hisilicon.c @@ -102,5 +102,5 @@ U_BOOT_DRIVER(hisi_reset) = { .of_match = hisi_reset_ids, .ops = &hisi_reset_reset_ops, .probe = hisi_reset_probe, - .priv_auto_alloc_size = sizeof(struct hisi_reset_priv), + .priv_auto = sizeof(struct hisi_reset_priv), }; diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c index 0c8f276293..8318d0a20b 100644 --- a/drivers/reset/reset-hsdk.c +++ b/drivers/reset/reset-hsdk.c @@ -114,5 +114,5 @@ U_BOOT_DRIVER(hsdk_reset) = { .of_match = hsdk_reset_dt_match, .ops = &hsdk_reset_ops, .probe = hsdk_reset_probe, - .priv_auto_alloc_size = sizeof(struct hsdk_rst), + .priv_auto = sizeof(struct hsdk_rst), }; diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c index 96916b644a..e5085ae17c 100644 --- a/drivers/reset/reset-imx7.c +++ b/drivers/reset/reset-imx7.c @@ -312,5 +312,5 @@ U_BOOT_DRIVER(imx7_reset) = { .of_match = imx7_reset_ids, .ops = &imx7_reset_reset_ops, .probe = imx7_reset_probe, - .priv_auto_alloc_size = sizeof(struct imx7_reset_priv), + .priv_auto = sizeof(struct imx7_reset_priv), }; diff --git a/drivers/reset/reset-ipq4019.c b/drivers/reset/reset-ipq4019.c index f216db4ce5..15858f3cb1 100644 --- a/drivers/reset/reset-ipq4019.c +++ b/drivers/reset/reset-ipq4019.c @@ -169,5 +169,5 @@ U_BOOT_DRIVER(ipq4019_reset) = { .of_match = ipq4019_reset_ids, .ops = &ipq4019_reset_ops, .probe = ipq4019_reset_probe, - .priv_auto_alloc_size = sizeof(struct ipq4019_reset_priv), + .priv_auto = sizeof(struct ipq4019_reset_priv), }; diff --git a/drivers/reset/reset-mediatek.c b/drivers/reset/reset-mediatek.c index 97d3d57592..7427013ab6 100644 --- a/drivers/reset/reset-mediatek.c +++ b/drivers/reset/reset-mediatek.c @@ -14,6 +14,7 @@ #include <regmap.h> #include <reset-uclass.h> #include <syscon.h> +#include <dm/device-internal.h> #include <linux/bitops.h> #include <linux/err.h> @@ -92,7 +93,7 @@ int mediatek_reset_bind(struct udevice *pdev, u32 regofs, u32 num_regs) priv = malloc(sizeof(struct mediatek_reset_priv)); priv->regofs = regofs; priv->nr_resets = num_regs * 32; - rst_dev->priv = priv; + dev_set_priv(rst_dev, priv); return 0; } @@ -102,5 +103,5 @@ U_BOOT_DRIVER(mediatek_reset) = { .id = UCLASS_RESET, .probe = mediatek_reset_probe, .ops = &mediatek_reset_ops, - .priv_auto_alloc_size = sizeof(struct mediatek_reset_priv), + .priv_auto = sizeof(struct mediatek_reset_priv), }; diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 4e3327898e..d4e0745d0e 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -89,5 +89,5 @@ U_BOOT_DRIVER(meson_reset) = { .of_match = meson_reset_ids, .probe = meson_reset_probe, .ops = &meson_reset_ops, - .priv_auto_alloc_size = sizeof(struct meson_reset_priv), + .priv_auto = sizeof(struct meson_reset_priv), }; diff --git a/drivers/reset/reset-mtmips.c b/drivers/reset/reset-mtmips.c index bc20e3335c..848425afbc 100644 --- a/drivers/reset/reset-mtmips.c +++ b/drivers/reset/reset-mtmips.c @@ -58,7 +58,7 @@ static int mtmips_reset_probe(struct udevice *dev) return 0; } -static int mtmips_reset_ofdata_to_platdata(struct udevice *dev) +static int mtmips_reset_of_to_plat(struct udevice *dev) { struct mtmips_reset_priv *priv = dev_get_priv(dev); @@ -78,8 +78,8 @@ U_BOOT_DRIVER(mtmips_reset) = { .name = "mtmips-reset", .id = UCLASS_RESET, .of_match = mtmips_reset_ids, - .ofdata_to_platdata = mtmips_reset_ofdata_to_platdata, + .of_to_plat = mtmips_reset_of_to_plat, .probe = mtmips_reset_probe, - .priv_auto_alloc_size = sizeof(struct mtmips_reset_priv), + .priv_auto = sizeof(struct mtmips_reset_priv), .ops = &mtmips_reset_ops, }; diff --git a/drivers/reset/reset-rockchip.c b/drivers/reset/reset-rockchip.c index 8092555650..eeb3d2eea7 100644 --- a/drivers/reset/reset-rockchip.c +++ b/drivers/reset/reset-rockchip.c @@ -11,6 +11,7 @@ #include <linux/bitops.h> #include <linux/io.h> #include <asm/arch-rockchip/hardware.h> +#include <dm/device-internal.h> #include <dm/lists.h> /* * Each reg has 16 bits reset signal for devices @@ -121,7 +122,7 @@ int rockchip_reset_bind(struct udevice *pdev, u32 reg_offset, u32 reg_number) priv = malloc(sizeof(struct rockchip_reset_priv)); priv->reset_reg_offset = reg_offset; priv->reset_reg_num = reg_number; - rst_dev->priv = priv; + dev_set_priv(rst_dev, priv); return 0; } @@ -131,5 +132,5 @@ U_BOOT_DRIVER(rockchip_reset) = { .id = UCLASS_RESET, .probe = rockchip_reset_probe, .ops = &rockchip_reset_ops, - .priv_auto_alloc_size = sizeof(struct rockchip_reset_priv), + .priv_auto = sizeof(struct rockchip_reset_priv), }; diff --git a/drivers/reset/reset-sifive.c b/drivers/reset/reset-sifive.c index 527757f853..eec840d677 100644 --- a/drivers/reset/reset-sifive.c +++ b/drivers/reset/reset-sifive.c @@ -9,6 +9,7 @@ #include <reset-uclass.h> #include <asm/io.h> #include <dm/device_compat.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <linux/bitops.h> @@ -97,7 +98,7 @@ int sifive_reset_bind(struct udevice *dev, ulong count) } priv = malloc(sizeof(struct sifive_reset_priv)); priv->nr_reset = count; - rst_dev->priv = priv; + dev_set_priv(rst_dev, priv); return 0; } @@ -114,5 +115,5 @@ U_BOOT_DRIVER(sifive_reset) = { .id = UCLASS_RESET, .ops = &sifive_reset_ops, .probe = sifive_reset_probe, - .priv_auto_alloc_size = sizeof(struct sifive_reset_priv), + .priv_auto = sizeof(struct sifive_reset_priv), }; diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c index 1849db4da9..98450db94b 100644 --- a/drivers/reset/reset-socfpga.c +++ b/drivers/reset/reset-socfpga.c @@ -148,7 +148,7 @@ static int socfpga_reset_bind(struct udevice *dev) * Bind it to the node, too, so that it can get its base address. */ ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset", - dev->node, &sys_child); + dev_ofnode(dev), &sys_child); if (ret) debug("Warning: No sysreset driver: ret=%d\n", ret); @@ -166,7 +166,7 @@ U_BOOT_DRIVER(socfpga_reset) = { .of_match = socfpga_reset_match, .bind = socfpga_reset_bind, .probe = socfpga_reset_probe, - .priv_auto_alloc_size = sizeof(struct socfpga_reset_data), + .priv_auto = sizeof(struct socfpga_reset_data), .ops = &socfpga_reset_ops, .remove = socfpga_reset_remove, .flags = DM_FLAG_OS_PREPARE, diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index 05f7f599ce..264337ed80 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c @@ -11,6 +11,7 @@ #include <malloc.h> #include <reset-uclass.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <linux/bitops.h> #include <linux/log2.h> @@ -113,7 +114,7 @@ int sunxi_reset_bind(struct udevice *dev, ulong count) priv = malloc(sizeof(struct sunxi_reset_priv)); priv->count = count; priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev); - rst_dev->priv = priv; + dev_set_priv(rst_dev, priv); return 0; } @@ -123,5 +124,5 @@ U_BOOT_DRIVER(sunxi_reset) = { .id = UCLASS_RESET, .ops = &sunxi_reset_ops, .probe = sunxi_reset_probe, - .priv_auto_alloc_size = sizeof(struct sunxi_reset_priv), + .priv_auto = sizeof(struct sunxi_reset_priv), }; diff --git a/drivers/reset/reset-syscon.c b/drivers/reset/reset-syscon.c index 8520227d55..ff387ab6b2 100644 --- a/drivers/reset/reset-syscon.c +++ b/drivers/reset/reset-syscon.c @@ -76,6 +76,6 @@ U_BOOT_DRIVER(syscon_reset) = { .id = UCLASS_RESET, .of_match = syscon_reset_ids, .probe = syscon_reset_probe, - .priv_auto_alloc_size = sizeof(struct syscon_reset_priv), + .priv_auto = sizeof(struct syscon_reset_priv), .ops = &syscon_reset_ops, }; diff --git a/drivers/reset/reset-ti-sci.c b/drivers/reset/reset-ti-sci.c index 95cd388587..d8510a4abb 100644 --- a/drivers/reset/reset-ti-sci.c +++ b/drivers/reset/reset-ti-sci.c @@ -205,6 +205,6 @@ U_BOOT_DRIVER(ti_sci_reset) = { .id = UCLASS_RESET, .of_match = ti_sci_reset_of_match, .probe = ti_sci_reset_probe, - .priv_auto_alloc_size = sizeof(struct ti_sci_reset_data), + .priv_auto = sizeof(struct ti_sci_reset_data), .ops = &ti_sci_reset_ops, }; diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c index fe1bd5541b..2694d130b6 100644 --- a/drivers/reset/reset-uniphier.c +++ b/drivers/reset/reset-uniphier.c @@ -372,6 +372,6 @@ U_BOOT_DRIVER(uniphier_reset) = { .id = UCLASS_RESET, .of_match = uniphier_reset_match, .probe = uniphier_reset_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_reset_priv), + .priv_auto = sizeof(struct uniphier_reset_priv), .ops = &uniphier_reset_ops, }; diff --git a/drivers/reset/sandbox-reset-test.c b/drivers/reset/sandbox-reset-test.c index 10e02f1036..51b79810c8 100644 --- a/drivers/reset/sandbox-reset-test.c +++ b/drivers/reset/sandbox-reset-test.c @@ -120,5 +120,5 @@ U_BOOT_DRIVER(sandbox_reset_test) = { .name = "sandbox_reset_test", .id = UCLASS_MISC, .of_match = sandbox_reset_test_ids, - .priv_auto_alloc_size = sizeof(struct sandbox_reset_test), + .priv_auto = sizeof(struct sandbox_reset_test), }; diff --git a/drivers/reset/sandbox-reset.c b/drivers/reset/sandbox-reset.c index 08008d875a..97b1b92e4a 100644 --- a/drivers/reset/sandbox-reset.c +++ b/drivers/reset/sandbox-reset.c @@ -99,7 +99,7 @@ U_BOOT_DRIVER(sandbox_reset) = { .of_match = sandbox_reset_ids, .bind = sandbox_reset_bind, .probe = sandbox_reset_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_reset), + .priv_auto = sizeof(struct sandbox_reset), .ops = &sandbox_reset_reset_ops, }; diff --git a/drivers/reset/sti-reset.c b/drivers/reset/sti-reset.c index 2cca67dc52..8041490630 100644 --- a/drivers/reset/sti-reset.c +++ b/drivers/reset/sti-reset.c @@ -336,6 +336,6 @@ U_BOOT_DRIVER(sti_reset) = { .id = UCLASS_RESET, .of_match = sti_reset_ids, .probe = sti_reset_probe, - .priv_auto_alloc_size = sizeof(struct sti_reset), + .priv_auto = sizeof(struct sti_reset), .ops = &sti_reset_ops, }; diff --git a/drivers/reset/stm32-reset.c b/drivers/reset/stm32-reset.c index d8902e9d9c..b84c9daec7 100644 --- a/drivers/reset/stm32-reset.c +++ b/drivers/reset/stm32-reset.c @@ -100,6 +100,6 @@ U_BOOT_DRIVER(stm32_rcc_reset) = { .name = "stm32_rcc_reset", .id = UCLASS_RESET, .probe = stm32_reset_probe, - .priv_auto_alloc_size = sizeof(struct stm32_reset_priv), + .priv_auto = sizeof(struct stm32_reset_priv), .ops = &stm32_reset_ops, }; diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c index 57a5a702a2..5a4f45ad5a 100644 --- a/drivers/rng/meson-rng.c +++ b/drivers/rng/meson-rng.c @@ -11,7 +11,7 @@ #include <rng.h> #include <asm/io.h> -struct meson_rng_platdata { +struct meson_rng_plat { fdt_addr_t base; struct clk clk; }; @@ -26,7 +26,7 @@ struct meson_rng_platdata { */ static int meson_rng_read(struct udevice *dev, void *data, size_t len) { - struct meson_rng_platdata *pdata = dev_get_platdata(dev); + struct meson_rng_plat *pdata = dev_get_plat(dev); char *buffer = (char *)data; while (len) { @@ -52,7 +52,7 @@ static int meson_rng_read(struct udevice *dev, void *data, size_t len) */ static int meson_rng_probe(struct udevice *dev) { - struct meson_rng_platdata *pdata = dev_get_platdata(dev); + struct meson_rng_plat *pdata = dev_get_plat(dev); int err; err = clk_enable(&pdata->clk); @@ -70,20 +70,20 @@ static int meson_rng_probe(struct udevice *dev) */ static int meson_rng_remove(struct udevice *dev) { - struct meson_rng_platdata *pdata = dev_get_platdata(dev); + struct meson_rng_plat *pdata = dev_get_plat(dev); return clk_disable(&pdata->clk); } /** - * meson_rng_ofdata_to_platdata() - transfer device tree data to plaform data + * meson_rng_of_to_plat() - transfer device tree data to plaform data * * @dev: device * Return: 0 if ok */ -static int meson_rng_ofdata_to_platdata(struct udevice *dev) +static int meson_rng_of_to_plat(struct udevice *dev) { - struct meson_rng_platdata *pdata = dev_get_platdata(dev); + struct meson_rng_plat *pdata = dev_get_plat(dev); int err; pdata->base = dev_read_addr(dev); @@ -116,6 +116,6 @@ U_BOOT_DRIVER(meson_rng) = { .ops = &meson_rng_ops, .probe = meson_rng_probe, .remove = meson_rng_remove, - .platdata_auto_alloc_size = sizeof(struct meson_rng_platdata), - .ofdata_to_platdata = meson_rng_ofdata_to_platdata, + .plat_auto = sizeof(struct meson_rng_plat), + .of_to_plat = meson_rng_of_to_plat, }; diff --git a/drivers/rng/msm_rng.c b/drivers/rng/msm_rng.c index d51119303a..29e7354ece 100644 --- a/drivers/rng/msm_rng.c +++ b/drivers/rng/msm_rng.c @@ -139,5 +139,5 @@ U_BOOT_DRIVER(msm_rng) = { .ops = &msm_rng_ops, .probe = msm_rng_probe, .remove = msm_rng_remove, - .priv_auto_alloc_size = sizeof(struct msm_rng_priv), + .priv_auto = sizeof(struct msm_rng_priv), }; diff --git a/drivers/rng/rockchip_rng.c b/drivers/rng/rockchip_rng.c index c6a834b67c..800150f114 100644 --- a/drivers/rng/rockchip_rng.c +++ b/drivers/rng/rockchip_rng.c @@ -49,7 +49,7 @@ struct rk_rng_soc_data { int (*rk_rng_read)(struct udevice *dev, void *data, size_t len); }; -struct rk_rng_platdata { +struct rk_rng_plat { fdt_addr_t base; struct rk_rng_soc_data *soc_data; }; @@ -77,7 +77,7 @@ static int rk_rng_read_regs(fdt_addr_t addr, void *buf, size_t size) static int rk_v1_rng_read(struct udevice *dev, void *data, size_t len) { - struct rk_rng_platdata *pdata = dev_get_priv(dev); + struct rk_rng_plat *pdata = dev_get_priv(dev); u32 reg = 0; int retval; @@ -108,7 +108,7 @@ exit: static int rk_v2_rng_read(struct udevice *dev, void *data, size_t len) { - struct rk_rng_platdata *pdata = dev_get_priv(dev); + struct rk_rng_plat *pdata = dev_get_priv(dev); u32 reg = 0; int retval; @@ -146,7 +146,7 @@ static int rockchip_rng_read(struct udevice *dev, void *data, size_t len) unsigned int i; int ret = -EIO; - struct rk_rng_platdata *pdata = dev_get_priv(dev); + struct rk_rng_plat *pdata = dev_get_priv(dev); if (!len) return 0; @@ -168,9 +168,9 @@ exit: return ret; } -static int rockchip_rng_ofdata_to_platdata(struct udevice *dev) +static int rockchip_rng_of_to_plat(struct udevice *dev) { - struct rk_rng_platdata *pdata = dev_get_priv(dev); + struct rk_rng_plat *pdata = dev_get_priv(dev); memset(pdata, 0x00, sizeof(*pdata)); @@ -183,7 +183,7 @@ static int rockchip_rng_ofdata_to_platdata(struct udevice *dev) static int rockchip_rng_probe(struct udevice *dev) { - struct rk_rng_platdata *pdata = dev_get_priv(dev); + struct rk_rng_plat *pdata = dev_get_priv(dev); pdata->soc_data = (struct rk_rng_soc_data *)dev_get_driver_data(dev); @@ -220,6 +220,6 @@ U_BOOT_DRIVER(rockchip_rng) = { .of_match = rockchip_rng_match, .ops = &rockchip_rng_ops, .probe = rockchip_rng_probe, - .ofdata_to_platdata = rockchip_rng_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct rk_rng_platdata), + .of_to_plat = rockchip_rng_of_to_plat, + .priv_auto = sizeof(struct rk_rng_plat), }; diff --git a/drivers/rng/stm32mp1_rng.c b/drivers/rng/stm32mp1_rng.c index c1bae180f7..8ea00e3e89 100644 --- a/drivers/rng/stm32mp1_rng.c +++ b/drivers/rng/stm32mp1_rng.c @@ -30,7 +30,7 @@ #define RNG_DR 0x08 -struct stm32_rng_platdata { +struct stm32_rng_plat { fdt_addr_t base; struct clk clk; struct reset_ctl rst; @@ -41,7 +41,7 @@ static int stm32_rng_read(struct udevice *dev, void *data, size_t len) int retval, i; u32 sr, count, reg; size_t increment; - struct stm32_rng_platdata *pdata = dev_get_platdata(dev); + struct stm32_rng_plat *pdata = dev_get_plat(dev); while (len > 0) { retval = readl_poll_timeout(pdata->base + RNG_SR, sr, @@ -80,7 +80,7 @@ static int stm32_rng_read(struct udevice *dev, void *data, size_t len) return 0; } -static int stm32_rng_init(struct stm32_rng_platdata *pdata) +static int stm32_rng_init(struct stm32_rng_plat *pdata) { int err; @@ -97,7 +97,7 @@ static int stm32_rng_init(struct stm32_rng_platdata *pdata) return 0; } -static int stm32_rng_cleanup(struct stm32_rng_platdata *pdata) +static int stm32_rng_cleanup(struct stm32_rng_plat *pdata) { writel(0, pdata->base + RNG_CR); @@ -106,7 +106,7 @@ static int stm32_rng_cleanup(struct stm32_rng_platdata *pdata) static int stm32_rng_probe(struct udevice *dev) { - struct stm32_rng_platdata *pdata = dev_get_platdata(dev); + struct stm32_rng_plat *pdata = dev_get_plat(dev); reset_assert(&pdata->rst); udelay(20); @@ -117,14 +117,14 @@ static int stm32_rng_probe(struct udevice *dev) static int stm32_rng_remove(struct udevice *dev) { - struct stm32_rng_platdata *pdata = dev_get_platdata(dev); + struct stm32_rng_plat *pdata = dev_get_plat(dev); return stm32_rng_cleanup(pdata); } -static int stm32_rng_ofdata_to_platdata(struct udevice *dev) +static int stm32_rng_of_to_plat(struct udevice *dev) { - struct stm32_rng_platdata *pdata = dev_get_platdata(dev); + struct stm32_rng_plat *pdata = dev_get_plat(dev); int err; pdata->base = dev_read_addr(dev); @@ -160,6 +160,6 @@ U_BOOT_DRIVER(stm32_rng) = { .ops = &stm32_rng_ops, .probe = stm32_rng_probe, .remove = stm32_rng_remove, - .platdata_auto_alloc_size = sizeof(struct stm32_rng_platdata), - .ofdata_to_platdata = stm32_rng_ofdata_to_platdata, + .plat_auto = sizeof(struct stm32_rng_plat), + .of_to_plat = stm32_rng_of_to_plat, }; diff --git a/drivers/rtc/ds3232.c b/drivers/rtc/ds3232.c index 0a30e0eabb..16501cfe5d 100644 --- a/drivers/rtc/ds3232.c +++ b/drivers/rtc/ds3232.c @@ -272,5 +272,5 @@ U_BOOT_DRIVER(rtc_ds3232) = { .probe = ds3232_probe, .of_match = ds3232_rtc_ids, .ops = &ds3232_rtc_ops, - .priv_auto_alloc_size = sizeof(struct ds3232_priv_data), + .priv_auto = sizeof(struct ds3232_priv_data), }; diff --git a/drivers/rtc/emul_rtc.c b/drivers/rtc/emul_rtc.c index 7e522103fd..8f0e1ab5ac 100644 --- a/drivers/rtc/emul_rtc.c +++ b/drivers/rtc/emul_rtc.c @@ -88,9 +88,9 @@ U_BOOT_DRIVER(rtc_emul) = { .id = UCLASS_RTC, .ops = &emul_rtc_ops, .probe = emul_rtc_probe, - .priv_auto_alloc_size = sizeof(struct emul_rtc), + .priv_auto = sizeof(struct emul_rtc), }; -U_BOOT_DEVICE(rtc_emul) = { +U_BOOT_DRVINFO(rtc_emul) = { .name = "rtc_emul", }; diff --git a/drivers/rtc/i2c_rtc_emul.c b/drivers/rtc/i2c_rtc_emul.c index 7f78ff83cb..5a2a154e65 100644 --- a/drivers/rtc/i2c_rtc_emul.c +++ b/drivers/rtc/i2c_rtc_emul.c @@ -50,7 +50,7 @@ struct sandbox_i2c_rtc { long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool use_system_time, int offset) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev); long old_offset; old_offset = plat->offset; @@ -63,7 +63,7 @@ long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool use_system_time, long sandbox_i2c_rtc_get_set_base_time(struct udevice *dev, long base_time) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev); long old_base_time; old_base_time = plat->base_time; @@ -75,7 +75,7 @@ long sandbox_i2c_rtc_get_set_base_time(struct udevice *dev, long base_time) static void reset_time(struct udevice *dev) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev); struct rtc_time now; os_localtime(&now); @@ -86,7 +86,7 @@ static void reset_time(struct udevice *dev) static int sandbox_i2c_rtc_get(struct udevice *dev, struct rtc_time *time) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev); struct rtc_time tm_now; long now; @@ -104,7 +104,7 @@ static int sandbox_i2c_rtc_get(struct udevice *dev, struct rtc_time *time) static int sandbox_i2c_rtc_set(struct udevice *dev, const struct rtc_time *time) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(dev); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(dev); struct rtc_time tm_now; long now; @@ -122,7 +122,7 @@ static int sandbox_i2c_rtc_set(struct udevice *dev, const struct rtc_time *time) /* Update the current time in the registers */ static int sandbox_i2c_rtc_prepare_read(struct udevice *emul) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(emul); struct rtc_time time; int ret; @@ -143,7 +143,7 @@ static int sandbox_i2c_rtc_prepare_read(struct udevice *emul) static int sandbox_i2c_rtc_complete_write(struct udevice *emul) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(emul); struct rtc_time time; int ret; @@ -165,7 +165,7 @@ static int sandbox_i2c_rtc_complete_write(struct udevice *emul) static int sandbox_i2c_rtc_xfer(struct udevice *emul, struct i2c_msg *msg, int nmsgs) { - struct sandbox_i2c_rtc_plat_data *plat = dev_get_platdata(emul); + struct sandbox_i2c_rtc_plat_data *plat = dev_get_plat(emul); uint offset = 0; int ret; @@ -230,7 +230,7 @@ U_BOOT_DRIVER(sandbox_i2c_rtc_emul) = { .id = UCLASS_I2C_EMUL, .of_match = sandbox_i2c_rtc_ids, .bind = sandbox_i2c_rtc_bind, - .priv_auto_alloc_size = sizeof(struct sandbox_i2c_rtc), - .platdata_auto_alloc_size = sizeof(struct sandbox_i2c_rtc_plat_data), + .priv_auto = sizeof(struct sandbox_i2c_rtc), + .plat_auto = sizeof(struct sandbox_i2c_rtc_plat_data), .ops = &sandbox_i2c_rtc_emul_ops, }; diff --git a/drivers/rtc/mvrtc.c b/drivers/rtc/mvrtc.c index ed057f7bc4..50240d57fa 100644 --- a/drivers/rtc/mvrtc.c +++ b/drivers/rtc/mvrtc.c @@ -133,7 +133,7 @@ void rtc_reset(void) #ifdef CONFIG_DM_RTC static int mv_rtc_get(struct udevice *dev, struct rtc_time *tm) { - struct mvrtc_pdata *pdata = dev_get_platdata(dev); + struct mvrtc_pdata *pdata = dev_get_plat(dev); struct mvrtc_registers *regs = (struct mvrtc_registers *)pdata->iobase; return __mv_rtc_get(regs, tm); @@ -141,7 +141,7 @@ static int mv_rtc_get(struct udevice *dev, struct rtc_time *tm) static int mv_rtc_set(struct udevice *dev, const struct rtc_time *tm) { - struct mvrtc_pdata *pdata = dev_get_platdata(dev); + struct mvrtc_pdata *pdata = dev_get_plat(dev); struct mvrtc_registers *regs = (struct mvrtc_registers *)pdata->iobase; return __mv_rtc_set(regs, tm); @@ -149,7 +149,7 @@ static int mv_rtc_set(struct udevice *dev, const struct rtc_time *tm) static int mv_rtc_reset(struct udevice *dev) { - struct mvrtc_pdata *pdata = dev_get_platdata(dev); + struct mvrtc_pdata *pdata = dev_get_plat(dev); struct mvrtc_registers *regs = (struct mvrtc_registers *)pdata->iobase; __mv_rtc_reset(regs); @@ -168,9 +168,9 @@ static const struct udevice_id mv_rtc_ids[] = { { } }; -static int mv_rtc_ofdata_to_platdata(struct udevice *dev) +static int mv_rtc_of_to_plat(struct udevice *dev) { - struct mvrtc_pdata *pdata = dev_get_platdata(dev); + struct mvrtc_pdata *pdata = dev_get_plat(dev); pdata->iobase = dev_read_addr(dev); return 0; @@ -179,7 +179,7 @@ static int mv_rtc_ofdata_to_platdata(struct udevice *dev) U_BOOT_DRIVER(rtc_mv) = { .name = "rtc-mv", .id = UCLASS_RTC, - .ofdata_to_platdata = mv_rtc_ofdata_to_platdata, + .of_to_plat = mv_rtc_of_to_plat, .of_match = mv_rtc_ids, .ops = &mv_rtc_ops, }; diff --git a/drivers/rtc/pcf2127.c b/drivers/rtc/pcf2127.c index 88ff8c52c3..57f86401d3 100644 --- a/drivers/rtc/pcf2127.c +++ b/drivers/rtc/pcf2127.c @@ -25,7 +25,7 @@ static int pcf2127_rtc_read(struct udevice *dev, uint offset, u8 *buffer, uint len) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct i2c_msg msg; int ret; diff --git a/drivers/rtc/pl031.c b/drivers/rtc/pl031.c index 1b6717232c..a1d376611d 100644 --- a/drivers/rtc/pl031.c +++ b/drivers/rtc/pl031.c @@ -29,20 +29,20 @@ #define RTC_CR_START (1 << 0) -struct pl031_platdata { +struct pl031_plat { phys_addr_t base; }; static inline u32 pl031_read_reg(struct udevice *dev, int reg) { - struct pl031_platdata *pdata = dev_get_platdata(dev); + struct pl031_plat *pdata = dev_get_plat(dev); return readl(pdata->base + reg); } static inline u32 pl031_write_reg(struct udevice *dev, int reg, u32 value) { - struct pl031_platdata *pdata = dev_get_platdata(dev); + struct pl031_plat *pdata = dev_get_plat(dev); return writel(value, pdata->base + reg); } @@ -122,9 +122,9 @@ static const struct udevice_id pl031_ids[] = { { } }; -static int pl031_ofdata_to_platdata(struct udevice *dev) +static int pl031_of_to_plat(struct udevice *dev) { - struct pl031_platdata *pdata = dev_get_platdata(dev); + struct pl031_plat *pdata = dev_get_plat(dev); pdata->base = dev_read_addr(dev); @@ -136,7 +136,7 @@ U_BOOT_DRIVER(rtc_pl031) = { .id = UCLASS_RTC, .of_match = pl031_ids, .probe = pl031_probe, - .ofdata_to_platdata = pl031_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct pl031_platdata), + .of_to_plat = pl031_of_to_plat, + .plat_auto = sizeof(struct pl031_plat), .ops = &pl031_ops, }; diff --git a/drivers/rtc/stm32_rtc.c b/drivers/rtc/stm32_rtc.c index f9db318af1..f1d0ea90d3 100644 --- a/drivers/rtc/stm32_rtc.c +++ b/drivers/rtc/stm32_rtc.c @@ -327,5 +327,5 @@ U_BOOT_DRIVER(rtc_stm32) = { .probe = stm32_rtc_probe, .of_match = stm32_rtc_ids, .ops = &stm32_rtc_ops, - .priv_auto_alloc_size = sizeof(struct stm32_rtc_priv), + .priv_auto = sizeof(struct stm32_rtc_priv), }; diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c index acf3b3dc95..90a0adda47 100644 --- a/drivers/scsi/scsi-uclass.c +++ b/drivers/scsi/scsi-uclass.c @@ -35,5 +35,5 @@ int scsi_bus_reset(struct udevice *dev) UCLASS_DRIVER(scsi) = { .id = UCLASS_SCSI, .name = "scsi", - .per_device_platdata_auto_alloc_size = sizeof(struct scsi_platdata), + .per_device_plat_auto = sizeof(struct scsi_plat), }; diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 0ab1d441f4..7389484490 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -149,9 +149,9 @@ static void scsi_setup_write_ext(struct scsi_cmd *pccb, lbaint_t start, static ulong scsi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); struct udevice *bdev = dev->parent; - struct scsi_platdata *uc_plat = dev_get_uclass_platdata(bdev); + struct scsi_plat *uc_plat = dev_get_uclass_plat(bdev); lbaint_t start, blks, max_blks; uintptr_t buf_addr; unsigned short smallblks = 0; @@ -219,9 +219,9 @@ static ulong scsi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + struct blk_desc *block_dev = dev_get_uclass_plat(dev); struct udevice *bdev = dev->parent; - struct scsi_platdata *uc_plat = dev_get_uclass_platdata(bdev); + struct scsi_plat *uc_plat = dev_get_uclass_plat(bdev); lbaint_t start, blks, max_blks; uintptr_t buf_addr; unsigned short smallblks; @@ -586,7 +586,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) return ret; } - bdesc = dev_get_uclass_platdata(bdev); + bdesc = dev_get_uclass_plat(bdev); bdesc->target = id; bdesc->lun = lun; bdesc->removable = bd.removable; @@ -604,7 +604,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) int scsi_scan_dev(struct udevice *dev, bool verbose) { - struct scsi_platdata *uc_plat; /* scsi controller platdata */ + struct scsi_plat *uc_plat; /* scsi controller plat */ int ret; int i; int lun; @@ -614,8 +614,8 @@ int scsi_scan_dev(struct udevice *dev, bool verbose) if (ret) return ret; - /* Get controller platdata */ - uc_plat = dev_get_uclass_platdata(dev); + /* Get controller plat */ + uc_plat = dev_get_uclass_plat(dev); for (i = 0; i < uc_plat->max_id; i++) for (lun = 0; lun < uc_plat->max_lun; lun++) diff --git a/drivers/serial/altera_jtag_uart.c b/drivers/serial/altera_jtag_uart.c index 35b76f53f9..4435fcf56b 100644 --- a/drivers/serial/altera_jtag_uart.c +++ b/drivers/serial/altera_jtag_uart.c @@ -26,7 +26,7 @@ struct altera_jtaguart_regs { u32 control; /* Control register */ }; -struct altera_jtaguart_platdata { +struct altera_jtaguart_plat { struct altera_jtaguart_regs *regs; }; @@ -37,7 +37,7 @@ static int altera_jtaguart_setbrg(struct udevice *dev, int baudrate) static int altera_jtaguart_putc(struct udevice *dev, const char ch) { - struct altera_jtaguart_platdata *plat = dev->platdata; + struct altera_jtaguart_plat *plat = dev_get_plat(dev); struct altera_jtaguart_regs *const regs = plat->regs; u32 st = readl(®s->control); @@ -56,7 +56,7 @@ static int altera_jtaguart_putc(struct udevice *dev, const char ch) static int altera_jtaguart_pending(struct udevice *dev, bool input) { - struct altera_jtaguart_platdata *plat = dev->platdata; + struct altera_jtaguart_plat *plat = dev_get_plat(dev); struct altera_jtaguart_regs *const regs = plat->regs; u32 st = readl(®s->control); @@ -68,7 +68,7 @@ static int altera_jtaguart_pending(struct udevice *dev, bool input) static int altera_jtaguart_getc(struct udevice *dev) { - struct altera_jtaguart_platdata *plat = dev->platdata; + struct altera_jtaguart_plat *plat = dev_get_plat(dev); struct altera_jtaguart_regs *const regs = plat->regs; u32 val; @@ -83,7 +83,7 @@ static int altera_jtaguart_getc(struct udevice *dev) static int altera_jtaguart_probe(struct udevice *dev) { #ifdef CONFIG_ALTERA_JTAG_UART_BYPASS - struct altera_jtaguart_platdata *plat = dev->platdata; + struct altera_jtaguart_plat *plat = dev_get_plat(dev); struct altera_jtaguart_regs *const regs = plat->regs; writel(ALTERA_JTAG_AC, ®s->control); /* clear AC flag */ @@ -91,9 +91,9 @@ static int altera_jtaguart_probe(struct udevice *dev) return 0; } -static int altera_jtaguart_ofdata_to_platdata(struct udevice *dev) +static int altera_jtaguart_of_to_plat(struct udevice *dev) { - struct altera_jtaguart_platdata *plat = dev_get_platdata(dev); + struct altera_jtaguart_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_jtaguart_regs), @@ -118,8 +118,8 @@ U_BOOT_DRIVER(altera_jtaguart) = { .name = "altera_jtaguart", .id = UCLASS_SERIAL, .of_match = altera_jtaguart_ids, - .ofdata_to_platdata = altera_jtaguart_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_jtaguart_platdata), + .of_to_plat = altera_jtaguart_of_to_plat, + .plat_auto = sizeof(struct altera_jtaguart_plat), .probe = altera_jtaguart_probe, .ops = &altera_jtaguart_ops, }; diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c index 0be5cd75c8..b18be6e245 100644 --- a/drivers/serial/altera_uart.c +++ b/drivers/serial/altera_uart.c @@ -25,14 +25,14 @@ struct altera_uart_regs { u32 endofpacket; /* End-of-packet reg */ }; -struct altera_uart_platdata { +struct altera_uart_plat { struct altera_uart_regs *regs; unsigned int uartclk; }; static int altera_uart_setbrg(struct udevice *dev, int baudrate) { - struct altera_uart_platdata *plat = dev->platdata; + struct altera_uart_plat *plat = dev_get_plat(dev); struct altera_uart_regs *const regs = plat->regs; u32 div; @@ -44,7 +44,7 @@ static int altera_uart_setbrg(struct udevice *dev, int baudrate) static int altera_uart_putc(struct udevice *dev, const char ch) { - struct altera_uart_platdata *plat = dev->platdata; + struct altera_uart_plat *plat = dev_get_plat(dev); struct altera_uart_regs *const regs = plat->regs; if (!(readl(®s->status) & ALTERA_UART_TRDY)) @@ -57,7 +57,7 @@ static int altera_uart_putc(struct udevice *dev, const char ch) static int altera_uart_pending(struct udevice *dev, bool input) { - struct altera_uart_platdata *plat = dev->platdata; + struct altera_uart_plat *plat = dev_get_plat(dev); struct altera_uart_regs *const regs = plat->regs; u32 st = readl(®s->status); @@ -69,7 +69,7 @@ static int altera_uart_pending(struct udevice *dev, bool input) static int altera_uart_getc(struct udevice *dev) { - struct altera_uart_platdata *plat = dev->platdata; + struct altera_uart_plat *plat = dev_get_plat(dev); struct altera_uart_regs *const regs = plat->regs; if (!(readl(®s->status) & ALTERA_UART_RRDY)) @@ -83,9 +83,9 @@ static int altera_uart_probe(struct udevice *dev) return 0; } -static int altera_uart_ofdata_to_platdata(struct udevice *dev) +static int altera_uart_of_to_plat(struct udevice *dev) { - struct altera_uart_platdata *plat = dev_get_platdata(dev); + struct altera_uart_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_uart_regs), @@ -111,8 +111,8 @@ U_BOOT_DRIVER(altera_uart) = { .name = "altera_uart", .id = UCLASS_SERIAL, .of_match = altera_uart_ids, - .ofdata_to_platdata = altera_uart_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_uart_platdata), + .of_to_plat = altera_uart_of_to_plat, + .plat_auto = sizeof(struct altera_uart_plat), .probe = altera_uart_probe, .ops = &altera_uart_ops, }; diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c index f759ea8893..7edec23e64 100644 --- a/drivers/serial/atmel_usart.c +++ b/drivers/serial/atmel_usart.c @@ -262,7 +262,7 @@ static int atmel_serial_enable_clk(struct udevice *dev) static int atmel_serial_probe(struct udevice *dev) { - struct atmel_serial_platdata *plat = dev->platdata; + struct atmel_serial_plat *plat = dev_get_plat(dev); struct atmel_serial_priv *priv = dev_get_priv(dev); int ret; #if CONFIG_IS_ENABLED(OF_CONTROL) @@ -304,14 +304,14 @@ U_BOOT_DRIVER(serial_atmel) = { .id = UCLASS_SERIAL, #if CONFIG_IS_ENABLED(OF_CONTROL) .of_match = atmel_serial_ids, - .platdata_auto_alloc_size = sizeof(struct atmel_serial_platdata), + .plat_auto = sizeof(struct atmel_serial_plat), #endif .probe = atmel_serial_probe, .ops = &atmel_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, #endif - .priv_auto_alloc_size = sizeof(struct atmel_serial_priv), + .priv_auto = sizeof(struct atmel_serial_priv), }; #endif diff --git a/drivers/serial/lpc32xx_hsuart.c b/drivers/serial/lpc32xx_hsuart.c index 7d31c6d4a1..d39a3c0494 100644 --- a/drivers/serial/lpc32xx_hsuart.c +++ b/drivers/serial/lpc32xx_hsuart.c @@ -85,10 +85,10 @@ static int lpc32xx_serial_init(struct hsuart_regs *hsuart) static int lpc32xx_hsuart_probe(struct udevice *dev) { - struct lpc32xx_hsuart_platdata *platdata = dev_get_platdata(dev); + struct lpc32xx_hsuart_plat *plat = dev_get_plat(dev); struct lpc32xx_hsuart_priv *priv = dev_get_priv(dev); - priv->hsuart = (struct hsuart_regs *)platdata->base; + priv->hsuart = (struct hsuart_regs *)plat->base; lpc32xx_serial_init(priv->hsuart); @@ -107,6 +107,6 @@ U_BOOT_DRIVER(lpc32xx_hsuart) = { .id = UCLASS_SERIAL, .probe = lpc32xx_hsuart_probe, .ops = &lpc32xx_hsuart_ops, - .priv_auto_alloc_size = sizeof(struct lpc32xx_hsuart_priv), + .priv_auto = sizeof(struct lpc32xx_hsuart_priv), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 702109b23b..65c6db073e 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -103,7 +103,7 @@ static inline int serial_in_shift(void *addr, int shift) * on a platform */ #ifdef CONFIG_NS16550_DYNAMIC -static void serial_out_dynamic(struct ns16550_platdata *plat, u8 *addr, +static void serial_out_dynamic(struct ns16550_plat *plat, u8 *addr, int value) { if (plat->flags & NS16550_FLAG_IO) { @@ -124,7 +124,7 @@ static void serial_out_dynamic(struct ns16550_platdata *plat, u8 *addr, } } -static int serial_in_dynamic(struct ns16550_platdata *plat, u8 *addr) +static int serial_in_dynamic(struct ns16550_plat *plat, u8 *addr) { if (plat->flags & NS16550_FLAG_IO) { return inb(addr); @@ -144,21 +144,21 @@ static int serial_in_dynamic(struct ns16550_platdata *plat, u8 *addr) } } #else -static inline void serial_out_dynamic(struct ns16550_platdata *plat, u8 *addr, +static inline void serial_out_dynamic(struct ns16550_plat *plat, u8 *addr, int value) { } -static inline int serial_in_dynamic(struct ns16550_platdata *plat, u8 *addr) +static inline int serial_in_dynamic(struct ns16550_plat *plat, u8 *addr) { return 0; } #endif /* CONFIG_NS16550_DYNAMIC */ -static void ns16550_writeb(NS16550_t port, int offset, int value) +static void ns16550_writeb(struct ns16550 *port, int offset, int value) { - struct ns16550_platdata *plat = port->plat; + struct ns16550_plat *plat = port->plat; unsigned char *addr; offset *= 1 << plat->reg_shift; @@ -170,9 +170,9 @@ static void ns16550_writeb(NS16550_t port, int offset, int value) serial_out_shift(addr, plat->reg_shift, value); } -static int ns16550_readb(NS16550_t port, int offset) +static int ns16550_readb(struct ns16550 *port, int offset) { - struct ns16550_platdata *plat = port->plat; + struct ns16550_plat *plat = port->plat; unsigned char *addr; offset *= 1 << plat->reg_shift; @@ -184,9 +184,9 @@ static int ns16550_readb(NS16550_t port, int offset) return serial_in_shift(addr, plat->reg_shift); } -static u32 ns16550_getfcr(NS16550_t port) +static u32 ns16550_getfcr(struct ns16550 *port) { - struct ns16550_platdata *plat = port->plat; + struct ns16550_plat *plat = port->plat; return plat->fcr; } @@ -199,20 +199,20 @@ static u32 ns16550_getfcr(NS16550_t port) ns16550_readb(com_port, \ (unsigned char *)addr - (unsigned char *)com_port) #else -static u32 ns16550_getfcr(NS16550_t port) +static u32 ns16550_getfcr(struct ns16550 *port) { return UART_FCR_DEFVAL; } #endif -int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate) +int ns16550_calc_divisor(struct ns16550 *port, int clock, int baudrate) { const unsigned int mode_x_div = 16; return DIV_ROUND_CLOSEST(clock, mode_x_div * baudrate); } -static void NS16550_setbrg(NS16550_t com_port, int baud_divisor) +static void ns16550_setbrg(struct ns16550 *com_port, int baud_divisor) { /* to keep serial format, read lcr before writing BKSE */ int lcr_val = serial_in(&com_port->lcr) & ~UART_LCR_BKSE; @@ -223,7 +223,7 @@ static void NS16550_setbrg(NS16550_t com_port, int baud_divisor) serial_out(lcr_val, &com_port->lcr); } -void NS16550_init(NS16550_t com_port, int baud_divisor) +void ns16550_init(struct ns16550 *com_port, int baud_divisor) { #if (defined(CONFIG_SPL_BUILD) && \ (defined(CONFIG_OMAP34XX) || defined(CONFIG_OMAP44XX))) @@ -235,13 +235,13 @@ void NS16550_init(NS16550_t com_port, int baud_divisor) if ((serial_in(&com_port->lsr) & (UART_LSR_TEMT | UART_LSR_THRE)) == UART_LSR_THRE) { if (baud_divisor != -1) - NS16550_setbrg(com_port, baud_divisor); + ns16550_setbrg(com_port, baud_divisor); else { // Re-use old baud rate divisor to flush transmit reg. const int dll = serial_in(&com_port->dll); const int dlm = serial_in(&com_port->dlm); const int divisor = dll | (dlm << 8); - NS16550_setbrg(com_port, divisor); + ns16550_setbrg(com_port, divisor); } serial_out(0, &com_port->mdr1); } @@ -260,7 +260,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor) /* initialize serial config to 8N1 before writing baudrate */ serial_out(UART_LCRVAL, &com_port->lcr); if (baud_divisor != -1) - NS16550_setbrg(com_port, baud_divisor); + ns16550_setbrg(com_port, baud_divisor); #if defined(CONFIG_ARCH_OMAP2PLUS) || defined(CONFIG_SOC_DA8XX) || \ defined(CONFIG_OMAP_SERIAL) /* /16 is proper to hit 115200 with 48MHz */ @@ -272,17 +272,17 @@ void NS16550_init(NS16550_t com_port, int baud_divisor) } #ifndef CONFIG_NS16550_MIN_FUNCTIONS -void NS16550_reinit(NS16550_t com_port, int baud_divisor) +void ns16550_reinit(struct ns16550 *com_port, int baud_divisor) { serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier); - NS16550_setbrg(com_port, 0); + ns16550_setbrg(com_port, 0); serial_out(UART_MCRVAL, &com_port->mcr); serial_out(ns16550_getfcr(com_port), &com_port->fcr); - NS16550_setbrg(com_port, baud_divisor); + ns16550_setbrg(com_port, baud_divisor); } #endif /* CONFIG_NS16550_MIN_FUNCTIONS */ -void NS16550_putc(NS16550_t com_port, char c) +void ns16550_putc(struct ns16550 *com_port, char c) { while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0) ; @@ -299,7 +299,7 @@ void NS16550_putc(NS16550_t com_port, char c) } #ifndef CONFIG_NS16550_MIN_FUNCTIONS -char NS16550_getc(NS16550_t com_port) +char ns16550_getc(struct ns16550 *com_port) { while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) { #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USB_TTY) @@ -311,7 +311,7 @@ char NS16550_getc(NS16550_t com_port) return serial_in(&com_port->rbr); } -int NS16550_tstc(NS16550_t com_port) +int ns16550_tstc(struct ns16550 *com_port) { return (serial_in(&com_port->lsr) & UART_LSR_DR) != 0; } @@ -324,7 +324,7 @@ int NS16550_tstc(NS16550_t com_port) static inline void _debug_uart_init(void) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; int baud_divisor; /* @@ -345,7 +345,7 @@ static inline void _debug_uart_init(void) serial_dout(&com_port->lcr, UART_LCRVAL); } -static inline int NS16550_read_baud_divisor(struct NS16550 *com_port) +static inline int NS16550_read_baud_divisor(struct ns16550 *com_port) { int ret; @@ -359,7 +359,7 @@ static inline int NS16550_read_baud_divisor(struct NS16550 *com_port) static inline void _debug_uart_putc(int ch) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) { #ifdef CONFIG_DEBUG_UART_NS16550_CHECK_ENABLED @@ -377,7 +377,7 @@ DEBUG_UART_FUNCS #if CONFIG_IS_ENABLED(DM_SERIAL) static int ns16550_serial_putc(struct udevice *dev, const char ch) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); if (!(serial_in(&com_port->lsr) & UART_LSR_THRE)) return -EAGAIN; @@ -397,7 +397,7 @@ static int ns16550_serial_putc(struct udevice *dev, const char ch) static int ns16550_serial_pending(struct udevice *dev, bool input) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); if (input) return (serial_in(&com_port->lsr) & UART_LSR_DR) ? 1 : 0; @@ -407,7 +407,7 @@ static int ns16550_serial_pending(struct udevice *dev, bool input) static int ns16550_serial_getc(struct udevice *dev) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); if (!(serial_in(&com_port->lsr) & UART_LSR_DR)) return -EAGAIN; @@ -417,20 +417,20 @@ static int ns16550_serial_getc(struct udevice *dev) static int ns16550_serial_setbrg(struct udevice *dev, int baudrate) { - struct NS16550 *const com_port = dev_get_priv(dev); - struct ns16550_platdata *plat = com_port->plat; + struct ns16550 *const com_port = dev_get_priv(dev); + struct ns16550_plat *plat = com_port->plat; int clock_divisor; clock_divisor = ns16550_calc_divisor(com_port, plat->clock, baudrate); - NS16550_setbrg(com_port, clock_divisor); + ns16550_setbrg(com_port, clock_divisor); return 0; } static int ns16550_serial_setconfig(struct udevice *dev, uint serial_config) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); int lcr_val = UART_LCR_WLS_8; uint parity = SERIAL_GET_PARITY(serial_config); uint bits = SERIAL_GET_BITS(serial_config); @@ -464,8 +464,8 @@ static int ns16550_serial_setconfig(struct udevice *dev, uint serial_config) static int ns16550_serial_getinfo(struct udevice *dev, struct serial_device_info *info) { - struct NS16550 *const com_port = dev_get_priv(dev); - struct ns16550_platdata *plat = com_port->plat; + struct ns16550 *const com_port = dev_get_priv(dev); + struct ns16550_plat *plat = com_port->plat; info->type = SERIAL_CHIP_16550_COMPATIBLE; #ifdef CONFIG_SYS_NS16550_PORT_MAPPED @@ -482,7 +482,7 @@ static int ns16550_serial_getinfo(struct udevice *dev, return 0; } -static int ns16550_serial_assign_base(struct ns16550_platdata *plat, ulong base) +static int ns16550_serial_assign_base(struct ns16550_plat *plat, ulong base) { if (base == FDT_ADDR_T_NONE) return -EINVAL; @@ -498,15 +498,15 @@ static int ns16550_serial_assign_base(struct ns16550_platdata *plat, ulong base) int ns16550_serial_probe(struct udevice *dev) { - struct ns16550_platdata *plat = dev->platdata; - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550_plat *plat = dev_get_plat(dev); + struct ns16550 *const com_port = dev_get_priv(dev); struct reset_ctl_bulk reset_bulk; fdt_addr_t addr; int ret; /* * If we are on PCI bus, either directly attached to a PCI root port, - * or via a PCI bridge, assign platdata->base before probing hardware. + * or via a PCI bridge, assign plat->base before probing hardware. */ if (device_is_on_pci_bus(dev)) { addr = devfdt_get_addr_pci(dev); @@ -519,8 +519,8 @@ int ns16550_serial_probe(struct udevice *dev) if (!ret) reset_deassert_bulk(&reset_bulk); - com_port->plat = dev_get_platdata(dev); - NS16550_init(com_port, -1); + com_port->plat = dev_get_plat(dev); + ns16550_init(com_port, -1); return 0; } @@ -533,9 +533,9 @@ enum { #endif #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -int ns16550_serial_ofdata_to_platdata(struct udevice *dev) +int ns16550_serial_of_to_plat(struct udevice *dev) { - struct ns16550_platdata *plat = dev->platdata; + struct ns16550_plat *plat = dev_get_plat(dev); const u32 port_type = dev_get_driver_data(dev); fdt_addr_t addr; struct clk clk; @@ -610,10 +610,10 @@ U_BOOT_DRIVER(ns16550_serial) = { .id = UCLASS_SERIAL, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = ns16550_serial_ids, - .ofdata_to_platdata = ns16550_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), + .of_to_plat = ns16550_serial_of_to_plat, + .plat_auto = sizeof(struct ns16550_plat), #endif - .priv_auto_alloc_size = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .probe = ns16550_serial_probe, .ops = &ns16550_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) @@ -621,9 +621,9 @@ U_BOOT_DRIVER(ns16550_serial) = { #endif }; -U_BOOT_DRIVER_ALIAS(ns16550_serial, rockchip_rk3328_uart) -U_BOOT_DRIVER_ALIAS(ns16550_serial, rockchip_rk3368_uart) -U_BOOT_DRIVER_ALIAS(ns16550_serial, ti_da830_uart) +DM_DRIVER_ALIAS(ns16550_serial, rockchip_rk3328_uart) +DM_DRIVER_ALIAS(ns16550_serial, rockchip_rk3368_uart) +DM_DRIVER_ALIAS(ns16550_serial, ti_da830_uart) #endif #endif /* SERIAL_PRESENT */ diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index db2fbac629..756738c2d2 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -12,39 +12,16 @@ #include <common.h> #include <console.h> #include <dm.h> -#include <fdtdec.h> #include <lcd.h> #include <os.h> #include <serial.h> #include <video.h> #include <linux/compiler.h> +#include <asm/serial.h> #include <asm/state.h> DECLARE_GLOBAL_DATA_PTR; -#if CONFIG_IS_ENABLED(OF_CONTROL) - -/* - * - * serial_buf: A buffer that holds keyboard characters for the - * Sandbox U-Boot. - * - * invariants: - * serial_buf_write == serial_buf_read -> empty buffer - * (serial_buf_write + 1) % 16 == serial_buf_read -> full buffer - */ -static unsigned char serial_buf[16]; -static unsigned int serial_buf_write; -static unsigned int serial_buf_read; - -struct sandbox_serial_platdata { - int colour; /* Text colour to use for output, -1 for none */ -}; - -struct sandbox_serial_priv { - bool start_of_line; -}; - /** * output_ansi_colour() - Output an ANSI colour code * @@ -74,13 +51,14 @@ static int sandbox_serial_probe(struct udevice *dev) if (state->term_raw != STATE_TERM_RAW) disable_ctrlc(1); + membuff_init(&priv->buf, priv->serial_buf, sizeof(priv->serial_buf)); return 0; } static int sandbox_serial_remove(struct udevice *dev) { - struct sandbox_serial_platdata *plat = dev->platdata; + struct sandbox_serial_plat *plat = dev_get_plat(dev); if (plat->colour != -1) output_ansi_reset(); @@ -91,7 +69,7 @@ static int sandbox_serial_remove(struct udevice *dev) static int sandbox_serial_putc(struct udevice *dev, const char ch) { struct sandbox_serial_priv *priv = dev_get_priv(dev); - struct sandbox_serial_platdata *plat = dev->platdata; + struct sandbox_serial_plat *plat = dev_get_plat(dev); /* With of-platdata we don't real the colour correctly, so disable it */ if (!CONFIG_IS_ENABLED(OF_PLATDATA) && priv->start_of_line && @@ -107,46 +85,39 @@ static int sandbox_serial_putc(struct udevice *dev, const char ch) return 0; } -static unsigned int increment_buffer_index(unsigned int index) -{ - return (index + 1) % ARRAY_SIZE(serial_buf); -} - static int sandbox_serial_pending(struct udevice *dev, bool input) { - const unsigned int next_index = - increment_buffer_index(serial_buf_write); + struct sandbox_serial_priv *priv = dev_get_priv(dev); ssize_t count; + char *data; + int avail; if (!input) return 0; os_usleep(100); -#ifndef CONFIG_SPL_BUILD - video_sync_all(); -#endif - if (next_index == serial_buf_read) + if (!IS_ENABLED(CONFIG_SPL_BUILD)) + video_sync_all(); + avail = membuff_putraw(&priv->buf, 100, false, &data); + if (!avail) return 1; /* buffer full */ - count = os_read(0, &serial_buf[serial_buf_write], 1); - if (count == 1) - serial_buf_write = next_index; + count = os_read(0, data, avail); + if (count > 0) + membuff_putraw(&priv->buf, count, true, &data); - return serial_buf_write != serial_buf_read; + return membuff_avail(&priv->buf); } static int sandbox_serial_getc(struct udevice *dev) { - int result; + struct sandbox_serial_priv *priv = dev_get_priv(dev); if (!sandbox_serial_pending(dev, true)) return -EAGAIN; /* buffer empty */ - result = serial_buf[serial_buf_read]; - serial_buf_read = increment_buffer_index(serial_buf_read); - return result; + return membuff_getbyte(&priv->buf); } -#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */ #ifdef CONFIG_DEBUG_UART_SANDBOX @@ -211,23 +182,21 @@ static int sandbox_serial_getinfo(struct udevice *dev, return 0; } -#if CONFIG_IS_ENABLED(OF_CONTROL) static const char * const ansi_colour[] = { "black", "red", "green", "yellow", "blue", "megenta", "cyan", "white", }; -static int sandbox_serial_ofdata_to_platdata(struct udevice *dev) +static int sandbox_serial_of_to_plat(struct udevice *dev) { - struct sandbox_serial_platdata *plat = dev->platdata; + struct sandbox_serial_plat *plat = dev_get_plat(dev); const char *colour; int i; if (CONFIG_IS_ENABLED(OF_PLATDATA)) return 0; plat->colour = -1; - colour = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), - "sandbox,text-colour", NULL); + colour = dev_read_string(dev, "sandbox,text-colour"); if (colour) { for (i = 0; i < ARRAY_SIZE(ansi_colour); i++) { if (!strcmp(colour, ansi_colour[i])) { @@ -258,9 +227,9 @@ U_BOOT_DRIVER(sandbox_serial) = { .name = "sandbox_serial", .id = UCLASS_SERIAL, .of_match = sandbox_serial_ids, - .ofdata_to_platdata = sandbox_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct sandbox_serial_platdata), - .priv_auto_alloc_size = sizeof(struct sandbox_serial_priv), + .of_to_plat = sandbox_serial_of_to_plat, + .plat_auto = sizeof(struct sandbox_serial_plat), + .priv_auto = sizeof(struct sandbox_serial_priv), .probe = sandbox_serial_probe, .remove = sandbox_serial_remove, .ops = &sandbox_serial_ops, @@ -268,14 +237,12 @@ U_BOOT_DRIVER(sandbox_serial) = { }; #if !CONFIG_IS_ENABLED(OF_PLATDATA) -static const struct sandbox_serial_platdata platdata_non_fdt = { +static const struct sandbox_serial_plat platdata_non_fdt = { .colour = -1, }; -U_BOOT_DEVICE(serial_sandbox_non_fdt) = { +U_BOOT_DRVINFO(serial_sandbox_non_fdt) = { .name = "sandbox_serial", - .platdata = &platdata_non_fdt, + .plat = &platdata_non_fdt, }; #endif - -#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */ diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index f3c25d4216..58a6541d8c 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -123,7 +123,7 @@ static void serial_find_console_or_panic(void) #ifdef CONFIG_SERIAL_SEARCH_ALL if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) || !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) { - if (dev->flags & DM_FLAG_ACTIVATED) { + if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) { gd->cur_serial_dev = dev; return; } @@ -507,6 +507,6 @@ UCLASS_DRIVER(serial) = { .flags = DM_UC_FLAG_SEQ_ALIAS, .post_probe = serial_post_probe, .pre_remove = serial_pre_remove, - .per_device_auto_alloc_size = sizeof(struct serial_dev_priv), + .per_device_auto = sizeof(struct serial_dev_priv), }; #endif diff --git a/drivers/serial/serial_ar933x.c b/drivers/serial/serial_ar933x.c index 9de94b69bd..da06bef97c 100644 --- a/drivers/serial/serial_ar933x.c +++ b/drivers/serial/serial_ar933x.c @@ -188,7 +188,7 @@ U_BOOT_DRIVER(serial_ar933x) = { .name = "serial_ar933x", .id = UCLASS_SERIAL, .of_match = ar933x_serial_ids, - .priv_auto_alloc_size = sizeof(struct ar933x_serial_priv), + .priv_auto = sizeof(struct ar933x_serial_priv), .probe = ar933x_serial_probe, .ops = &ar933x_serial_ops, }; diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 04063fbe39..445eacc8aa 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -25,7 +25,7 @@ struct arc_serial_regs { }; -struct arc_serial_platdata { +struct arc_serial_plat { struct arc_serial_regs *reg; unsigned int uartclk; }; @@ -37,7 +37,7 @@ struct arc_serial_platdata { static int arc_serial_setbrg(struct udevice *dev, int baudrate) { - struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_plat *plat = dev_get_plat(dev); struct arc_serial_regs *const regs = plat->reg; int arc_console_baud = gd->cpu_clk / (baudrate * 4) - 1; @@ -49,7 +49,7 @@ static int arc_serial_setbrg(struct udevice *dev, int baudrate) static int arc_serial_putc(struct udevice *dev, const char c) { - struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_plat *plat = dev_get_plat(dev); struct arc_serial_regs *const regs = plat->reg; while (!(readb(®s->status) & UART_TXEMPTY)) @@ -67,7 +67,7 @@ static int arc_serial_tstc(struct arc_serial_regs *const regs) static int arc_serial_pending(struct udevice *dev, bool input) { - struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_plat *plat = dev_get_plat(dev); struct arc_serial_regs *const regs = plat->reg; uint32_t status = readb(®s->status); @@ -79,7 +79,7 @@ static int arc_serial_pending(struct udevice *dev, bool input) static int arc_serial_getc(struct udevice *dev) { - struct arc_serial_platdata *plat = dev->platdata; + struct arc_serial_plat *plat = dev_get_plat(dev); struct arc_serial_regs *const regs = plat->reg; while (!arc_serial_tstc(regs)) @@ -109,9 +109,9 @@ static const struct udevice_id arc_serial_ids[] = { { } }; -static int arc_serial_ofdata_to_platdata(struct udevice *dev) +static int arc_serial_of_to_plat(struct udevice *dev) { - struct arc_serial_platdata *plat = dev_get_platdata(dev); + struct arc_serial_plat *plat = dev_get_plat(dev); DECLARE_GLOBAL_DATA_PTR; plat->reg = dev_read_addr_ptr(dev); @@ -125,8 +125,8 @@ U_BOOT_DRIVER(serial_arc) = { .name = "serial_arc", .id = UCLASS_SERIAL, .of_match = arc_serial_ids, - .ofdata_to_platdata = arc_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct arc_serial_platdata), + .of_to_plat = arc_serial_of_to_plat, + .plat_auto = sizeof(struct arc_serial_plat), .probe = arc_serial_probe, .ops = &arc_serial_ops, }; diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 8a4af87eb6..58fa722b4b 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -55,7 +55,7 @@ static int bcm283x_mu_serial_getc(struct udevice *dev); static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate) { - struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); + struct bcm283x_mu_serial_plat *plat = dev_get_plat(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); struct bcm283x_mu_regs *regs = priv->regs; u32 divider; @@ -158,7 +158,7 @@ static bool bcm283x_is_serial_muxed(void) static int bcm283x_mu_serial_probe(struct udevice *dev) { - struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); + struct bcm283x_mu_serial_plat *plat = dev_get_plat(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); fdt_addr_t addr; @@ -167,7 +167,7 @@ static int bcm283x_mu_serial_probe(struct udevice *dev) return -ENODEV; /* - * Read the ofdata here rather than in an ofdata_to_platdata() method + * Read the ofdata here rather than in an of_to_plat() method * since we need the soc simple-bus to be probed so that the 'ranges' * property is used. */ @@ -194,11 +194,11 @@ U_BOOT_DRIVER(serial_bcm283x_mu) = { .name = "serial_bcm283x_mu", .id = UCLASS_SERIAL, .of_match = of_match_ptr(bcm283x_mu_serial_id), - .platdata_auto_alloc_size = sizeof(struct bcm283x_mu_serial_platdata), + .plat_auto = sizeof(struct bcm283x_mu_serial_plat), .probe = bcm283x_mu_serial_probe, .ops = &bcm283x_mu_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) || CONFIG_IS_ENABLED(OF_BOARD) .flags = DM_FLAG_PRE_RELOC, #endif - .priv_auto_alloc_size = sizeof(struct bcm283x_mu_priv), + .priv_auto = sizeof(struct bcm283x_mu_priv), }; diff --git a/drivers/serial/serial_bcm283x_pl011.c b/drivers/serial/serial_bcm283x_pl011.c index 923f402fbe..2d2e970316 100644 --- a/drivers/serial/serial_bcm283x_pl011.c +++ b/drivers/serial/serial_bcm283x_pl011.c @@ -35,7 +35,7 @@ static bool bcm283x_is_serial_muxed(void) static int bcm283x_pl011_serial_probe(struct udevice *dev) { - struct pl01x_serial_platdata *plat = dev_get_platdata(dev); + struct pl01x_serial_plat *plat = dev_get_plat(dev); int ret; /* Don't spawn the device if it's not muxed */ @@ -43,11 +43,11 @@ static int bcm283x_pl011_serial_probe(struct udevice *dev) return -ENODEV; /* - * Read the ofdata here rather than in an ofdata_to_platdata() method + * Read the ofdata here rather than in an of_to_plat() method * since we need the soc simple-bus to be probed so that the 'ranges' * property is used. */ - ret = pl01x_serial_ofdata_to_platdata(dev); + ret = pl01x_serial_of_to_plat(dev); if (ret) return ret; @@ -92,10 +92,10 @@ U_BOOT_DRIVER(bcm283x_pl011_uart) = { .id = UCLASS_SERIAL, .of_match = of_match_ptr(bcm283x_pl011_serial_id), .probe = bcm283x_pl011_serial_probe, - .platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata), + .plat_auto = sizeof(struct pl01x_serial_plat), .ops = &bcm283x_pl011_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) || CONFIG_IS_ENABLED(OF_BOARD) .flags = DM_FLAG_PRE_RELOC, #endif - .priv_auto_alloc_size = sizeof(struct pl01x_priv), + .priv_auto = sizeof(struct pl01x_priv), }; diff --git a/drivers/serial/serial_bcm6345.c b/drivers/serial/serial_bcm6345.c index 5b963ce45b..f08e91ff3b 100644 --- a/drivers/serial/serial_bcm6345.c +++ b/drivers/serial/serial_bcm6345.c @@ -262,7 +262,7 @@ U_BOOT_DRIVER(bcm6345_serial) = { .id = UCLASS_SERIAL, .of_match = bcm6345_serial_ids, .probe = bcm6345_serial_probe, - .priv_auto_alloc_size = sizeof(struct bcm6345_serial_priv), + .priv_auto = sizeof(struct bcm6345_serial_priv), .ops = &bcm6345_serial_ops, }; diff --git a/drivers/serial/serial_coreboot.c b/drivers/serial/serial_coreboot.c index ccab347514..88c8209c5d 100644 --- a/drivers/serial/serial_coreboot.c +++ b/drivers/serial/serial_coreboot.c @@ -11,9 +11,9 @@ #include <serial.h> #include <asm/arch/sysinfo.h> -static int coreboot_ofdata_to_platdata(struct udevice *dev) +static int coreboot_of_to_plat(struct udevice *dev) { - struct ns16550_platdata *plat = dev_get_platdata(dev); + struct ns16550_plat *plat = dev_get_plat(dev); struct cb_serial *cb_info = lib_sysinfo.serial; plat->base = cb_info->baseaddr; @@ -37,9 +37,9 @@ U_BOOT_DRIVER(coreboot_uart) = { .name = "coreboot_uart", .id = UCLASS_SERIAL, .of_match = coreboot_serial_ids, - .priv_auto_alloc_size = sizeof(struct NS16550), - .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), - .ofdata_to_platdata = coreboot_ofdata_to_platdata, + .priv_auto = sizeof(struct ns16550), + .plat_auto = sizeof(struct ns16550_plat), + .of_to_plat = coreboot_of_to_plat, .probe = ns16550_serial_probe, .ops = &ns16550_serial_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/serial/serial_cortina.c b/drivers/serial/serial_cortina.c index cc20673efe..6dc81a775d 100644 --- a/drivers/serial/serial_cortina.c +++ b/drivers/serial/serial_cortina.c @@ -131,7 +131,7 @@ static int ca_serial_probe(struct udevice *dev) return 0; } -static int ca_serial_ofdata_to_platdata(struct udevice *dev) +static int ca_serial_of_to_plat(struct udevice *dev) { struct ca_uart_priv *priv = dev_get_priv(dev); @@ -158,8 +158,8 @@ U_BOOT_DRIVER(serial_cortina) = { .name = "serial_cortina", .id = UCLASS_SERIAL, .of_match = ca_serial_ids, - .ofdata_to_platdata = ca_serial_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct ca_uart_priv), + .of_to_plat = ca_serial_of_to_plat, + .priv_auto = sizeof(struct ca_uart_priv), .probe = ca_serial_probe, .ops = &ca_serial_ops }; diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c index b152e10258..33ddbd6080 100644 --- a/drivers/serial/serial_efi.c +++ b/drivers/serial/serial_efi.c @@ -150,7 +150,7 @@ U_BOOT_DRIVER(serial_efi) = { .name = "serial_efi", .id = UCLASS_SERIAL, .of_match = serial_efi_ids, - .priv_auto_alloc_size = sizeof(struct serial_efi_priv), + .priv_auto = sizeof(struct serial_efi_priv), .probe = serial_efi_probe, .ops = &serial_efi_ops, }; diff --git a/drivers/serial/serial_intel_mid.c b/drivers/serial/serial_intel_mid.c index 39bd40e68b..bbf19057c4 100644 --- a/drivers/serial/serial_intel_mid.c +++ b/drivers/serial/serial_intel_mid.c @@ -21,7 +21,7 @@ #define UART_MUL 0x34 #define UART_DIV 0x38 -static void mid_writel(struct ns16550_platdata *plat, int offset, int value) +static void mid_writel(struct ns16550_plat *plat, int offset, int value) { unsigned char *addr; @@ -33,7 +33,7 @@ static void mid_writel(struct ns16550_platdata *plat, int offset, int value) static int mid_serial_probe(struct udevice *dev) { - struct ns16550_platdata *plat = dev_get_platdata(dev); + struct ns16550_plat *plat = dev_get_plat(dev); /* * Initialize fractional divider correctly for Intel Edison @@ -59,9 +59,9 @@ U_BOOT_DRIVER(serial_intel_mid) = { .name = "serial_intel_mid", .id = UCLASS_SERIAL, .of_match = mid_serial_ids, - .ofdata_to_platdata = ns16550_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), - .priv_auto_alloc_size = sizeof(struct NS16550), + .of_to_plat = ns16550_serial_of_to_plat, + .plat_auto = sizeof(struct ns16550_plat), + .priv_auto = sizeof(struct ns16550), .probe = mid_serial_probe, .ops = &ns16550_serial_ops, }; diff --git a/drivers/serial/serial_linflexuart.c b/drivers/serial/serial_linflexuart.c index 83dc96c449..c3714e1e1e 100644 --- a/drivers/serial/serial_linflexuart.c +++ b/drivers/serial/serial_linflexuart.c @@ -115,7 +115,7 @@ static int _linflex_serial_init(struct linflex_fsl *base) return 0; } -struct linflex_serial_platdata { +struct linflex_serial_plat { struct linflex_fsl *base_addr; u8 port_id; /* do we need this? */ }; @@ -168,7 +168,7 @@ static void linflex_serial_init_internal(struct linflex_fsl *lfuart) static int linflex_serial_probe(struct udevice *dev) { - struct linflex_serial_platdata *plat = dev->platdata; + struct linflex_serial_plat *plat = dev_get_plat(dev); struct linflex_serial_priv *priv = dev_get_priv(dev); priv->lfuart = (struct linflex_fsl *)plat->base_addr; @@ -190,7 +190,7 @@ U_BOOT_DRIVER(serial_linflex) = { .probe = linflex_serial_probe, .ops = &linflex_serial_ops, .flags = DM_FLAG_PRE_RELOC, - .priv_auto_alloc_size = sizeof(struct linflex_serial_priv), + .priv_auto = sizeof(struct linflex_serial_priv), }; #ifdef CONFIG_DEBUG_UART_LINFLEXUART diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c index 95cbe63b3d..a35e5be303 100644 --- a/drivers/serial/serial_lpuart.c +++ b/drivers/serial/serial_lpuart.c @@ -74,7 +74,7 @@ enum lpuart_devtype { DEV_IMXRT, }; -struct lpuart_serial_platdata { +struct lpuart_serial_plat { void *reg; enum lpuart_devtype devtype; ulong flags; @@ -138,7 +138,7 @@ static inline int get_lpuart_clk_rate(struct udevice *dev, u32 *clk) static bool is_lpuart32(struct udevice *dev) { - struct lpuart_serial_platdata *plat = dev->platdata; + struct lpuart_serial_plat *plat = dev_get_plat(dev); return plat->flags & LPUART_FLAG_REGMAP_32BIT_REG; } @@ -146,7 +146,7 @@ static bool is_lpuart32(struct udevice *dev) static void _lpuart_serial_setbrg(struct udevice *dev, int baudrate) { - struct lpuart_serial_platdata *plat = dev_get_platdata(dev); + struct lpuart_serial_plat *plat = dev_get_plat(dev); struct lpuart_fsl *base = plat->reg; u32 clk; u16 sbr; @@ -167,7 +167,7 @@ static void _lpuart_serial_setbrg(struct udevice *dev, __raw_writeb(sbr & 0xff, &base->ubdl); } -static int _lpuart_serial_getc(struct lpuart_serial_platdata *plat) +static int _lpuart_serial_getc(struct lpuart_serial_plat *plat) { struct lpuart_fsl *base = plat->reg; while (!(__raw_readb(&base->us1) & (US1_RDRF | US1_OR))) @@ -178,7 +178,7 @@ static int _lpuart_serial_getc(struct lpuart_serial_platdata *plat) return __raw_readb(&base->ud); } -static void _lpuart_serial_putc(struct lpuart_serial_platdata *plat, +static void _lpuart_serial_putc(struct lpuart_serial_plat *plat, const char c) { struct lpuart_fsl *base = plat->reg; @@ -190,7 +190,7 @@ static void _lpuart_serial_putc(struct lpuart_serial_platdata *plat, } /* Test whether a character is in the RX buffer */ -static int _lpuart_serial_tstc(struct lpuart_serial_platdata *plat) +static int _lpuart_serial_tstc(struct lpuart_serial_plat *plat) { struct lpuart_fsl *base = plat->reg; @@ -206,7 +206,7 @@ static int _lpuart_serial_tstc(struct lpuart_serial_platdata *plat) */ static int _lpuart_serial_init(struct udevice *dev) { - struct lpuart_serial_platdata *plat = dev_get_platdata(dev); + struct lpuart_serial_plat *plat = dev_get_plat(dev); struct lpuart_fsl *base = (struct lpuart_fsl *)plat->reg; u8 ctrl; @@ -235,7 +235,7 @@ static int _lpuart_serial_init(struct udevice *dev) static void _lpuart32_serial_setbrg_7ulp(struct udevice *dev, int baudrate) { - struct lpuart_serial_platdata *plat = dev_get_platdata(dev); + struct lpuart_serial_plat *plat = dev_get_plat(dev); struct lpuart_fsl_reg32 *base = plat->reg; u32 sbr, osr, baud_diff, tmp_osr, tmp_sbr, tmp_diff, tmp; u32 clk; @@ -304,7 +304,7 @@ static void _lpuart32_serial_setbrg_7ulp(struct udevice *dev, static void _lpuart32_serial_setbrg(struct udevice *dev, int baudrate) { - struct lpuart_serial_platdata *plat = dev_get_platdata(dev); + struct lpuart_serial_plat *plat = dev_get_plat(dev); struct lpuart_fsl_reg32 *base = plat->reg; u32 clk; u32 sbr; @@ -324,7 +324,7 @@ static void _lpuart32_serial_setbrg(struct udevice *dev, lpuart_write32(plat->flags, &base->baud, sbr); } -static int _lpuart32_serial_getc(struct lpuart_serial_platdata *plat) +static int _lpuart32_serial_getc(struct lpuart_serial_plat *plat) { struct lpuart_fsl_reg32 *base = plat->reg; u32 stat, val; @@ -345,7 +345,7 @@ static int _lpuart32_serial_getc(struct lpuart_serial_platdata *plat) return val & 0x3ff; } -static void _lpuart32_serial_putc(struct lpuart_serial_platdata *plat, +static void _lpuart32_serial_putc(struct lpuart_serial_plat *plat, const char c) { struct lpuart_fsl_reg32 *base = plat->reg; @@ -367,7 +367,7 @@ static void _lpuart32_serial_putc(struct lpuart_serial_platdata *plat, } /* Test whether a character is in the RX buffer */ -static int _lpuart32_serial_tstc(struct lpuart_serial_platdata *plat) +static int _lpuart32_serial_tstc(struct lpuart_serial_plat *plat) { struct lpuart_fsl_reg32 *base = plat->reg; u32 water; @@ -386,7 +386,7 @@ static int _lpuart32_serial_tstc(struct lpuart_serial_platdata *plat) */ static int _lpuart32_serial_init(struct udevice *dev) { - struct lpuart_serial_platdata *plat = dev_get_platdata(dev); + struct lpuart_serial_plat *plat = dev_get_plat(dev); struct lpuart_fsl_reg32 *base = (struct lpuart_fsl_reg32 *)plat->reg; u32 val, tx_fifo_size; @@ -428,7 +428,7 @@ static int _lpuart32_serial_init(struct udevice *dev) static int lpuart_serial_setbrg(struct udevice *dev, int baudrate) { - struct lpuart_serial_platdata *plat = dev_get_platdata(dev); + struct lpuart_serial_plat *plat = dev_get_plat(dev); if (is_lpuart32(dev)) { if (plat->devtype == DEV_MX7ULP || plat->devtype == DEV_IMX8 || @@ -445,7 +445,7 @@ static int lpuart_serial_setbrg(struct udevice *dev, int baudrate) static int lpuart_serial_getc(struct udevice *dev) { - struct lpuart_serial_platdata *plat = dev->platdata; + struct lpuart_serial_plat *plat = dev_get_plat(dev); if (is_lpuart32(dev)) return _lpuart32_serial_getc(plat); @@ -455,7 +455,7 @@ static int lpuart_serial_getc(struct udevice *dev) static int lpuart_serial_putc(struct udevice *dev, const char c) { - struct lpuart_serial_platdata *plat = dev->platdata; + struct lpuart_serial_plat *plat = dev_get_plat(dev); if (is_lpuart32(dev)) _lpuart32_serial_putc(plat, c); @@ -467,7 +467,7 @@ static int lpuart_serial_putc(struct udevice *dev, const char c) static int lpuart_serial_pending(struct udevice *dev, bool input) { - struct lpuart_serial_platdata *plat = dev->platdata; + struct lpuart_serial_plat *plat = dev_get_plat(dev); struct lpuart_fsl *reg = plat->reg; struct lpuart_fsl_reg32 *reg32 = plat->reg; u32 stat; @@ -511,9 +511,9 @@ static int lpuart_serial_probe(struct udevice *dev) return _lpuart_serial_init(dev); } -static int lpuart_serial_ofdata_to_platdata(struct udevice *dev) +static int lpuart_serial_of_to_plat(struct udevice *dev) { - struct lpuart_serial_platdata *plat = dev->platdata; + struct lpuart_serial_plat *plat = dev_get_plat(dev); const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); fdt_addr_t addr; @@ -566,8 +566,8 @@ U_BOOT_DRIVER(serial_lpuart) = { .name = "serial_lpuart", .id = UCLASS_SERIAL, .of_match = lpuart_serial_ids, - .ofdata_to_platdata = lpuart_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct lpuart_serial_platdata), + .of_to_plat = lpuart_serial_of_to_plat, + .plat_auto = sizeof(struct lpuart_serial_plat), .probe = lpuart_serial_probe, .ops = &lpuart_serial_ops, }; diff --git a/drivers/serial/serial_mcf.c b/drivers/serial/serial_mcf.c index 402fd5343c..e6e21b2ce8 100644 --- a/drivers/serial/serial_mcf.c +++ b/drivers/serial/serial_mcf.c @@ -83,9 +83,9 @@ static void mcf_serial_setbrg_common(uart_t *uart, int baudrate) static int coldfire_serial_probe(struct udevice *dev) { - struct coldfire_serial_platdata *plat = dev->platdata; + struct coldfire_serial_plat *plat = dev_get_plat(dev); - plat->port = dev->seq; + plat->port = dev_seq(dev); return mcf_serial_init_common((uart_t *)plat->base, plat->port, plat->baudrate); @@ -93,7 +93,7 @@ static int coldfire_serial_probe(struct udevice *dev) static int coldfire_serial_putc(struct udevice *dev, const char ch) { - struct coldfire_serial_platdata *plat = dev->platdata; + struct coldfire_serial_plat *plat = dev_get_plat(dev); uart_t *uart = (uart_t *)plat->base; /* Wait for last character to go. */ @@ -107,7 +107,7 @@ static int coldfire_serial_putc(struct udevice *dev, const char ch) static int coldfire_serial_getc(struct udevice *dev) { - struct coldfire_serial_platdata *plat = dev->platdata; + struct coldfire_serial_plat *plat = dev_get_plat(dev); uart_t *uart = (uart_t *)(plat->base); /* Wait for a character to arrive. */ @@ -119,7 +119,7 @@ static int coldfire_serial_getc(struct udevice *dev) int coldfire_serial_setbrg(struct udevice *dev, int baudrate) { - struct coldfire_serial_platdata *plat = dev->platdata; + struct coldfire_serial_plat *plat = dev_get_plat(dev); uart_t *uart = (uart_t *)(plat->base); mcf_serial_setbrg_common(uart, baudrate); @@ -129,7 +129,7 @@ int coldfire_serial_setbrg(struct udevice *dev, int baudrate) static int coldfire_serial_pending(struct udevice *dev, bool input) { - struct coldfire_serial_platdata *plat = dev->platdata; + struct coldfire_serial_plat *plat = dev_get_plat(dev); uart_t *uart = (uart_t *)(plat->base); if (input) @@ -140,9 +140,9 @@ static int coldfire_serial_pending(struct udevice *dev, bool input) return 0; } -static int coldfire_ofdata_to_platdata(struct udevice *dev) +static int coldfire_of_to_plat(struct udevice *dev) { - struct coldfire_serial_platdata *plat = dev_get_platdata(dev); + struct coldfire_serial_plat *plat = dev_get_plat(dev); fdt_addr_t addr_base; addr_base = dev_read_addr(dev); @@ -171,8 +171,8 @@ U_BOOT_DRIVER(serial_coldfire) = { .name = "serial_coldfire", .id = UCLASS_SERIAL, .of_match = coldfire_serial_ids, - .ofdata_to_platdata = coldfire_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct coldfire_serial_platdata), + .of_to_plat = coldfire_of_to_plat, + .plat_auto = sizeof(struct coldfire_serial_plat), .probe = coldfire_serial_probe, .ops = &coldfire_serial_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c index 496a2ca2c3..d69ec221e4 100644 --- a/drivers/serial/serial_meson.c +++ b/drivers/serial/serial_meson.c @@ -19,7 +19,7 @@ struct meson_uart { u32 misc; }; -struct meson_serial_platdata { +struct meson_serial_plat { struct meson_uart *reg; }; @@ -57,7 +57,7 @@ static void meson_serial_init(struct meson_uart *uart) static int meson_serial_probe(struct udevice *dev) { - struct meson_serial_platdata *plat = dev->platdata; + struct meson_serial_plat *plat = dev_get_plat(dev); struct meson_uart *const uart = plat->reg; meson_serial_init(uart); @@ -67,7 +67,7 @@ static int meson_serial_probe(struct udevice *dev) static void meson_serial_rx_error(struct udevice *dev) { - struct meson_serial_platdata *plat = dev->platdata; + struct meson_serial_plat *plat = dev_get_plat(dev); struct meson_uart *const uart = plat->reg; u32 val = readl(&uart->control); @@ -83,7 +83,7 @@ static void meson_serial_rx_error(struct udevice *dev) static int meson_serial_getc(struct udevice *dev) { - struct meson_serial_platdata *plat = dev->platdata; + struct meson_serial_plat *plat = dev_get_plat(dev); struct meson_uart *const uart = plat->reg; uint32_t status = readl(&uart->status); @@ -100,7 +100,7 @@ static int meson_serial_getc(struct udevice *dev) static int meson_serial_putc(struct udevice *dev, const char ch) { - struct meson_serial_platdata *plat = dev->platdata; + struct meson_serial_plat *plat = dev_get_plat(dev); struct meson_uart *const uart = plat->reg; if (readl(&uart->status) & AML_UART_TX_FULL) @@ -113,7 +113,7 @@ static int meson_serial_putc(struct udevice *dev, const char ch) static int meson_serial_pending(struct udevice *dev, bool input) { - struct meson_serial_platdata *plat = dev->platdata; + struct meson_serial_plat *plat = dev_get_plat(dev); struct meson_uart *const uart = plat->reg; uint32_t status = readl(&uart->status); @@ -136,9 +136,9 @@ static int meson_serial_pending(struct udevice *dev, bool input) } } -static int meson_serial_ofdata_to_platdata(struct udevice *dev) +static int meson_serial_of_to_plat(struct udevice *dev) { - struct meson_serial_platdata *plat = dev->platdata; + struct meson_serial_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -168,8 +168,8 @@ U_BOOT_DRIVER(serial_meson) = { .of_match = meson_serial_ids, .probe = meson_serial_probe, .ops = &meson_serial_ops, - .ofdata_to_platdata = meson_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct meson_serial_platdata), + .of_to_plat = meson_serial_of_to_plat, + .plat_auto = sizeof(struct meson_serial_plat), }; #ifdef CONFIG_DEBUG_UART_MESON diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c index c8946c3aae..024c2c956e 100644 --- a/drivers/serial/serial_msm.c +++ b/drivers/serial/serial_msm.c @@ -216,7 +216,7 @@ static int msm_serial_probe(struct udevice *dev) return 0; } -static int msm_serial_ofdata_to_platdata(struct udevice *dev) +static int msm_serial_of_to_plat(struct udevice *dev) { struct msm_serial_data *priv = dev_get_priv(dev); @@ -239,8 +239,8 @@ U_BOOT_DRIVER(serial_msm) = { .name = "serial_msm", .id = UCLASS_SERIAL, .of_match = msm_serial_ids, - .ofdata_to_platdata = msm_serial_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct msm_serial_data), + .of_to_plat = msm_serial_of_to_plat, + .priv_auto = sizeof(struct msm_serial_data), .probe = msm_serial_probe, .ops = &msm_serial_ops, }; diff --git a/drivers/serial/serial_mtk.c b/drivers/serial/serial_mtk.c index 778a04d87e..665b2aa3b2 100644 --- a/drivers/serial/serial_mtk.c +++ b/drivers/serial/serial_mtk.c @@ -216,7 +216,7 @@ static int mtk_serial_probe(struct udevice *dev) return 0; } -static int mtk_serial_ofdata_to_platdata(struct udevice *dev) +static int mtk_serial_of_to_plat(struct udevice *dev) { struct mtk_serial_priv *priv = dev_get_priv(dev); fdt_addr_t addr; @@ -267,8 +267,8 @@ U_BOOT_DRIVER(serial_mtk) = { .name = "serial_mtk", .id = UCLASS_SERIAL, .of_match = mtk_serial_ids, - .ofdata_to_platdata = mtk_serial_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct mtk_serial_priv), + .of_to_plat = mtk_serial_of_to_plat, + .priv_auto = sizeof(struct mtk_serial_priv), .probe = mtk_serial_probe, .ops = &mtk_serial_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/serial/serial_mvebu_a3700.c b/drivers/serial/serial_mvebu_a3700.c index fb43f88eaf..5a1d40e0a6 100644 --- a/drivers/serial/serial_mvebu_a3700.c +++ b/drivers/serial/serial_mvebu_a3700.c @@ -8,7 +8,7 @@ #include <serial.h> #include <asm/io.h> -struct mvebu_platdata { +struct mvebu_plat { void __iomem *base; }; @@ -32,7 +32,7 @@ struct mvebu_platdata { static int mvebu_serial_putc(struct udevice *dev, const char ch) { - struct mvebu_platdata *plat = dev_get_platdata(dev); + struct mvebu_plat *plat = dev_get_plat(dev); void __iomem *base = plat->base; while (readl(base + UART_STATUS_REG) & UART_STATUS_TXFIFO_FULL) @@ -45,7 +45,7 @@ static int mvebu_serial_putc(struct udevice *dev, const char ch) static int mvebu_serial_getc(struct udevice *dev) { - struct mvebu_platdata *plat = dev_get_platdata(dev); + struct mvebu_plat *plat = dev_get_plat(dev); void __iomem *base = plat->base; while (!(readl(base + UART_STATUS_REG) & UART_STATUS_RX_RDY)) @@ -56,7 +56,7 @@ static int mvebu_serial_getc(struct udevice *dev) static int mvebu_serial_pending(struct udevice *dev, bool input) { - struct mvebu_platdata *plat = dev_get_platdata(dev); + struct mvebu_plat *plat = dev_get_plat(dev); void __iomem *base = plat->base; if (readl(base + UART_STATUS_REG) & UART_STATUS_RX_RDY) @@ -67,7 +67,7 @@ static int mvebu_serial_pending(struct udevice *dev, bool input) static int mvebu_serial_setbrg(struct udevice *dev, int baudrate) { - struct mvebu_platdata *plat = dev_get_platdata(dev); + struct mvebu_plat *plat = dev_get_plat(dev); void __iomem *base = plat->base; /* @@ -87,7 +87,7 @@ static int mvebu_serial_setbrg(struct udevice *dev, int baudrate) static int mvebu_serial_probe(struct udevice *dev) { - struct mvebu_platdata *plat = dev_get_platdata(dev); + struct mvebu_plat *plat = dev_get_plat(dev); void __iomem *base = plat->base; /* reset FIFOs */ @@ -100,9 +100,9 @@ static int mvebu_serial_probe(struct udevice *dev) return 0; } -static int mvebu_serial_ofdata_to_platdata(struct udevice *dev) +static int mvebu_serial_of_to_plat(struct udevice *dev) { - struct mvebu_platdata *plat = dev_get_platdata(dev); + struct mvebu_plat *plat = dev_get_plat(dev); plat->base = dev_read_addr_ptr(dev); @@ -125,8 +125,8 @@ U_BOOT_DRIVER(serial_mvebu) = { .name = "serial_mvebu", .id = UCLASS_SERIAL, .of_match = mvebu_serial_ids, - .ofdata_to_platdata = mvebu_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mvebu_platdata), + .of_to_plat = mvebu_serial_of_to_plat, + .plat_auto = sizeof(struct mvebu_plat), .probe = mvebu_serial_probe, .ops = &mvebu_serial_ops, }; diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index de6cefcd3a..e5795da99d 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -264,7 +264,7 @@ __weak struct serial_device *default_serial_console(void) int mxc_serial_setbrg(struct udevice *dev, int baudrate) { - struct mxc_serial_platdata *plat = dev->platdata; + struct mxc_serial_plat *plat = dev_get_plat(dev); u32 clk = imx_get_uartclk(); _mxc_serial_setbrg(plat->reg, clk, baudrate, plat->use_dte); @@ -274,7 +274,7 @@ int mxc_serial_setbrg(struct udevice *dev, int baudrate) static int mxc_serial_probe(struct udevice *dev) { - struct mxc_serial_platdata *plat = dev->platdata; + struct mxc_serial_plat *plat = dev_get_plat(dev); _mxc_serial_init(plat->reg, plat->use_dte); @@ -283,7 +283,7 @@ static int mxc_serial_probe(struct udevice *dev) static int mxc_serial_getc(struct udevice *dev) { - struct mxc_serial_platdata *plat = dev->platdata; + struct mxc_serial_plat *plat = dev_get_plat(dev); struct mxc_uart *const uart = plat->reg; if (readl(&uart->ts) & UTS_RXEMPTY) @@ -294,7 +294,7 @@ static int mxc_serial_getc(struct udevice *dev) static int mxc_serial_putc(struct udevice *dev, const char ch) { - struct mxc_serial_platdata *plat = dev->platdata; + struct mxc_serial_plat *plat = dev_get_plat(dev); struct mxc_uart *const uart = plat->reg; if (!(readl(&uart->ts) & UTS_TXEMPTY)) @@ -307,7 +307,7 @@ static int mxc_serial_putc(struct udevice *dev, const char ch) static int mxc_serial_pending(struct udevice *dev, bool input) { - struct mxc_serial_platdata *plat = dev->platdata; + struct mxc_serial_plat *plat = dev_get_plat(dev); struct mxc_uart *const uart = plat->reg; uint32_t sr2 = readl(&uart->sr2); @@ -325,9 +325,9 @@ static const struct dm_serial_ops mxc_serial_ops = { }; #if CONFIG_IS_ENABLED(OF_CONTROL) -static int mxc_serial_ofdata_to_platdata(struct udevice *dev) +static int mxc_serial_of_to_plat(struct udevice *dev) { - struct mxc_serial_platdata *plat = dev->platdata; + struct mxc_serial_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -357,8 +357,8 @@ U_BOOT_DRIVER(serial_mxc) = { .id = UCLASS_SERIAL, #if CONFIG_IS_ENABLED(OF_CONTROL) .of_match = mxc_serial_ids, - .ofdata_to_platdata = mxc_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mxc_serial_platdata), + .of_to_plat = mxc_serial_of_to_plat, + .plat_auto = sizeof(struct mxc_serial_plat), #endif .probe = mxc_serial_probe, .ops = &mxc_serial_ops, diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index ef394b7235..b5beca976d 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -36,34 +36,34 @@ DECLARE_GLOBAL_DATA_PTR; /* Note: The port number specified in the functions is 1 based. * the array is 0 based. */ -static NS16550_t serial_ports[6] = { +static struct ns16550 *serial_ports[6] = { #ifdef CONFIG_SYS_NS16550_COM1 - (NS16550_t)CONFIG_SYS_NS16550_COM1, + (struct ns16550 *)CONFIG_SYS_NS16550_COM1, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM2 - (NS16550_t)CONFIG_SYS_NS16550_COM2, + (struct ns16550 *)CONFIG_SYS_NS16550_COM2, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM3 - (NS16550_t)CONFIG_SYS_NS16550_COM3, + (struct ns16550 *)CONFIG_SYS_NS16550_COM3, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM4 - (NS16550_t)CONFIG_SYS_NS16550_COM4, + (struct ns16550 *)CONFIG_SYS_NS16550_COM4, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM5 - (NS16550_t)CONFIG_SYS_NS16550_COM5, + (struct ns16550 *)CONFIG_SYS_NS16550_COM5, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM6 - (NS16550_t)CONFIG_SYS_NS16550_COM6 + (struct ns16550 *)CONFIG_SYS_NS16550_COM6 #else NULL #endif @@ -78,7 +78,7 @@ static NS16550_t serial_ports[6] = { int clock_divisor; \ clock_divisor = ns16550_calc_divisor(serial_ports[port-1], \ CONFIG_SYS_NS16550_CLK, gd->baudrate); \ - NS16550_init(serial_ports[port-1], clock_divisor); \ + ns16550_init(serial_ports[port - 1], clock_divisor); \ return 0 ; \ } \ static void eserial##port##_setbrg(void) \ @@ -117,9 +117,9 @@ static NS16550_t serial_ports[6] = { static void _serial_putc(const char c, const int port) { if (c == '\n') - NS16550_putc(PORT, '\r'); + ns16550_putc(PORT, '\r'); - NS16550_putc(PORT, c); + ns16550_putc(PORT, c); } static void _serial_puts(const char *s, const int port) @@ -131,12 +131,12 @@ static void _serial_puts(const char *s, const int port) static int _serial_getc(const int port) { - return NS16550_getc(PORT); + return ns16550_getc(PORT); } static int _serial_tstc(const int port) { - return NS16550_tstc(PORT); + return ns16550_tstc(PORT); } static void _serial_setbrg(const int port) @@ -145,7 +145,7 @@ static void _serial_setbrg(const int port) clock_divisor = ns16550_calc_divisor(PORT, CONFIG_SYS_NS16550_CLK, gd->baudrate); - NS16550_reinit(PORT, clock_divisor); + ns16550_reinit(PORT, clock_divisor); } static inline void diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c index f7997fc788..2b23ece442 100644 --- a/drivers/serial/serial_omap.c +++ b/drivers/serial/serial_omap.c @@ -66,7 +66,7 @@ static inline int serial_in_shift(void *addr, int shift) static inline void _debug_uart_init(void) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; int baud_divisor; baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK, @@ -85,7 +85,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) ; @@ -99,9 +99,9 @@ DEBUG_UART_FUNCS #if CONFIG_IS_ENABLED(DM_SERIAL) #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int omap_serial_ofdata_to_platdata(struct udevice *dev) +static int omap_serial_of_to_plat(struct udevice *dev) { - struct ns16550_platdata *plat = dev->platdata; + struct ns16550_plat *plat = dev_get_plat(dev); fdt_addr_t addr; struct clk clk; int err; @@ -157,10 +157,10 @@ U_BOOT_DRIVER(omap_serial) = { .id = UCLASS_SERIAL, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = omap_serial_ids, - .ofdata_to_platdata = omap_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), + .of_to_plat = omap_serial_of_to_plat, + .plat_auto = sizeof(struct ns16550_plat), #endif - .priv_auto_alloc_size = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .probe = ns16550_serial_probe, .ops = &ns16550_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c index 2651a45a7f..3b795785f7 100644 --- a/drivers/serial/serial_owl.c +++ b/drivers/serial/serial_owl.c @@ -102,7 +102,7 @@ static int owl_serial_probe(struct udevice *dev) return 0; } -static int owl_serial_ofdata_to_platdata(struct udevice *dev) +static int owl_serial_of_to_plat(struct udevice *dev) { struct owl_serial_priv *priv = dev_get_priv(dev); @@ -129,8 +129,8 @@ U_BOOT_DRIVER(serial_owl) = { .name = "serial_owl", .id = UCLASS_SERIAL, .of_match = owl_serial_ids, - .ofdata_to_platdata = owl_serial_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct owl_serial_priv), + .of_to_plat = owl_serial_of_to_plat, + .priv_auto = sizeof(struct owl_serial_priv), .probe = owl_serial_probe, .ops = &owl_serial_ops, }; diff --git a/drivers/serial/serial_pic32.c b/drivers/serial/serial_pic32.c index a492063e39..5d1dbe7a91 100644 --- a/drivers/serial/serial_pic32.c +++ b/drivers/serial/serial_pic32.c @@ -178,7 +178,7 @@ U_BOOT_DRIVER(pic32_serial) = { .of_match = pic32_uart_ids, .probe = pic32_uart_probe, .ops = &pic32_uart_ops, - .priv_auto_alloc_size = sizeof(struct pic32_uart_priv), + .priv_auto = sizeof(struct pic32_uart_priv), }; #ifdef CONFIG_DEBUG_UART_PIC32 diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index d9e35c6a2b..b21e943d21 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -281,7 +281,7 @@ __weak struct serial_device *default_serial_console(void) int pl01x_serial_setbrg(struct udevice *dev, int baudrate) { - struct pl01x_serial_platdata *plat = dev_get_platdata(dev); + struct pl01x_serial_plat *plat = dev_get_plat(dev); struct pl01x_priv *priv = dev_get_priv(dev); if (!plat->skip_init) { @@ -294,7 +294,7 @@ int pl01x_serial_setbrg(struct udevice *dev, int baudrate) int pl01x_serial_probe(struct udevice *dev) { - struct pl01x_serial_platdata *plat = dev_get_platdata(dev); + struct pl01x_serial_plat *plat = dev_get_plat(dev); struct pl01x_priv *priv = dev_get_priv(dev); priv->regs = (struct pl01x_regs *)plat->base; @@ -348,9 +348,9 @@ static const struct udevice_id pl01x_serial_id[] ={ #define CONFIG_PL011_CLOCK 0 #endif -int pl01x_serial_ofdata_to_platdata(struct udevice *dev) +int pl01x_serial_of_to_plat(struct udevice *dev) { - struct pl01x_serial_platdata *plat = dev_get_platdata(dev); + struct pl01x_serial_plat *plat = dev_get_plat(dev); struct clk clk; fdt_addr_t addr; int ret; @@ -387,12 +387,12 @@ U_BOOT_DRIVER(serial_pl01x) = { .name = "serial_pl01x", .id = UCLASS_SERIAL, .of_match = of_match_ptr(pl01x_serial_id), - .ofdata_to_platdata = of_match_ptr(pl01x_serial_ofdata_to_platdata), - .platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata), + .of_to_plat = of_match_ptr(pl01x_serial_of_to_plat), + .plat_auto = sizeof(struct pl01x_serial_plat), .probe = pl01x_serial_probe, .ops = &pl01x_serial_ops, .flags = DM_FLAG_PRE_RELOC, - .priv_auto_alloc_size = sizeof(struct pl01x_priv), + .priv_auto = sizeof(struct pl01x_priv), }; #endif diff --git a/drivers/serial/serial_pl01x_internal.h b/drivers/serial/serial_pl01x_internal.h index c5c706b153..dfd95a0b77 100644 --- a/drivers/serial/serial_pl01x_internal.h +++ b/drivers/serial/serial_pl01x_internal.h @@ -40,7 +40,7 @@ struct pl01x_regs { #ifdef CONFIG_DM_SERIAL -int pl01x_serial_ofdata_to_platdata(struct udevice *dev); +int pl01x_serial_of_to_plat(struct udevice *dev); int pl01x_serial_probe(struct udevice *dev); /* Needed for external pl01x_serial_ops drivers */ diff --git a/drivers/serial/serial_pxa.c b/drivers/serial/serial_pxa.c index 6f8f7e1198..669841ede4 100644 --- a/drivers/serial/serial_pxa.c +++ b/drivers/serial/serial_pxa.c @@ -268,7 +268,7 @@ void pxa_serial_initialize(void) #ifdef CONFIG_DM_SERIAL static int pxa_serial_probe(struct udevice *dev) { - struct pxa_serial_platdata *plat = dev->platdata; + struct pxa_serial_plat *plat = dev_get_plat(dev); pxa_setbrg_common((struct pxa_uart_regs *)plat->base, plat->port, plat->baudrate); @@ -277,7 +277,7 @@ static int pxa_serial_probe(struct udevice *dev) static int pxa_serial_putc(struct udevice *dev, const char ch) { - struct pxa_serial_platdata *plat = dev->platdata; + struct pxa_serial_plat *plat = dev_get_plat(dev); struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base; /* Wait for last character to go. */ @@ -291,7 +291,7 @@ static int pxa_serial_putc(struct udevice *dev, const char ch) static int pxa_serial_getc(struct udevice *dev) { - struct pxa_serial_platdata *plat = dev->platdata; + struct pxa_serial_plat *plat = dev_get_plat(dev); struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base; /* Wait for a character to arrive. */ @@ -303,7 +303,7 @@ static int pxa_serial_getc(struct udevice *dev) int pxa_serial_setbrg(struct udevice *dev, int baudrate) { - struct pxa_serial_platdata *plat = dev->platdata; + struct pxa_serial_plat *plat = dev_get_plat(dev); struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base; int port = plat->port; @@ -314,7 +314,7 @@ int pxa_serial_setbrg(struct udevice *dev, int baudrate) static int pxa_serial_pending(struct udevice *dev, bool input) { - struct pxa_serial_platdata *plat = dev->platdata; + struct pxa_serial_plat *plat = dev_get_plat(dev); struct pxa_uart_regs *uart_regs = (struct pxa_uart_regs *)plat->base; if (input) diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c index b1718f72d1..97d40869a2 100644 --- a/drivers/serial/serial_rockchip.c +++ b/drivers/serial/serial_rockchip.c @@ -10,31 +10,32 @@ #include <ns16550.h> #include <serial.h> #include <asm/arch-rockchip/clock.h> +#include <dm/device-internal.h> #if defined(CONFIG_ROCKCHIP_RK3188) -struct rockchip_uart_platdata { +struct rockchip_uart_plat { struct dtd_rockchip_rk3188_uart dtplat; - struct ns16550_platdata plat; + struct ns16550_plat plat; }; struct dtd_rockchip_rk3188_uart *dtplat, s_dtplat; #elif defined(CONFIG_ROCKCHIP_RK3288) -struct rockchip_uart_platdata { +struct rockchip_uart_plat { struct dtd_rockchip_rk3288_uart dtplat; - struct ns16550_platdata plat; + struct ns16550_plat plat; }; struct dtd_rockchip_rk3288_uart *dtplat, s_dtplat; #endif static int rockchip_serial_probe(struct udevice *dev) { - struct rockchip_uart_platdata *plat = dev_get_platdata(dev); + struct rockchip_uart_plat *plat = dev_get_plat(dev); /* Create some new platform data for the standard driver */ plat->plat.base = plat->dtplat.reg[0]; plat->plat.reg_shift = plat->dtplat.reg_shift; plat->plat.clock = plat->dtplat.clock_frequency; plat->plat.fcr = UART_FCR_DEFVAL; - dev->platdata = &plat->plat; + dev_set_plat(dev, &plat->plat); return ns16550_serial_probe(dev); } @@ -42,8 +43,8 @@ static int rockchip_serial_probe(struct udevice *dev) U_BOOT_DRIVER(rockchip_rk3188_uart) = { .name = "rockchip_rk3188_uart", .id = UCLASS_SERIAL, - .priv_auto_alloc_size = sizeof(struct NS16550), - .platdata_auto_alloc_size = sizeof(struct rockchip_uart_platdata), + .priv_auto = sizeof(struct ns16550), + .plat_auto = sizeof(struct rockchip_uart_plat), .probe = rockchip_serial_probe, .ops = &ns16550_serial_ops, .flags = DM_FLAG_PRE_RELOC, @@ -52,8 +53,8 @@ U_BOOT_DRIVER(rockchip_rk3188_uart) = { U_BOOT_DRIVER(rockchip_rk3288_uart) = { .name = "rockchip_rk3288_uart", .id = UCLASS_SERIAL, - .priv_auto_alloc_size = sizeof(struct NS16550), - .platdata_auto_alloc_size = sizeof(struct rockchip_uart_platdata), + .priv_auto = sizeof(struct ns16550), + .plat_auto = sizeof(struct rockchip_uart_plat), .probe = rockchip_serial_probe, .ops = &ns16550_serial_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index 9bb2be21e7..0eac0d53a5 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR; #define TX_FIFO_FULL (1 << 24) /* Information about a serial port */ -struct s5p_serial_platdata { +struct s5p_serial_plat { struct s5p_uart *reg; /* address of registers in physical memory */ u8 port_id; /* uart port number */ }; @@ -88,7 +88,7 @@ static void __maybe_unused s5p_serial_baud(struct s5p_uart *uart, uint uclk, #ifndef CONFIG_SPL_BUILD int s5p_serial_setbrg(struct udevice *dev, int baudrate) { - struct s5p_serial_platdata *plat = dev->platdata; + struct s5p_serial_plat *plat = dev_get_plat(dev); struct s5p_uart *const uart = plat->reg; u32 uclk; @@ -111,7 +111,7 @@ int s5p_serial_setbrg(struct udevice *dev, int baudrate) static int s5p_serial_probe(struct udevice *dev) { - struct s5p_serial_platdata *plat = dev->platdata; + struct s5p_serial_plat *plat = dev_get_plat(dev); struct s5p_uart *const uart = plat->reg; s5p_serial_init(uart); @@ -140,7 +140,7 @@ static int serial_err_check(const struct s5p_uart *const uart, int op) static int s5p_serial_getc(struct udevice *dev) { - struct s5p_serial_platdata *plat = dev->platdata; + struct s5p_serial_plat *plat = dev_get_plat(dev); struct s5p_uart *const uart = plat->reg; if (!(readl(&uart->ufstat) & RX_FIFO_COUNT_MASK)) @@ -152,7 +152,7 @@ static int s5p_serial_getc(struct udevice *dev) static int s5p_serial_putc(struct udevice *dev, const char ch) { - struct s5p_serial_platdata *plat = dev->platdata; + struct s5p_serial_plat *plat = dev_get_plat(dev); struct s5p_uart *const uart = plat->reg; if (readl(&uart->ufstat) & TX_FIFO_FULL) @@ -166,7 +166,7 @@ static int s5p_serial_putc(struct udevice *dev, const char ch) static int s5p_serial_pending(struct udevice *dev, bool input) { - struct s5p_serial_platdata *plat = dev->platdata; + struct s5p_serial_plat *plat = dev_get_plat(dev); struct s5p_uart *const uart = plat->reg; uint32_t ufstat = readl(&uart->ufstat); @@ -176,9 +176,9 @@ static int s5p_serial_pending(struct udevice *dev, bool input) return (ufstat & TX_FIFO_COUNT_MASK) >> TX_FIFO_COUNT_SHIFT; } -static int s5p_serial_ofdata_to_platdata(struct udevice *dev) +static int s5p_serial_of_to_plat(struct udevice *dev) { - struct s5p_serial_platdata *plat = dev->platdata; + struct s5p_serial_plat *plat = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -187,7 +187,7 @@ static int s5p_serial_ofdata_to_platdata(struct udevice *dev) plat->reg = (struct s5p_uart *)addr; plat->port_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "id", dev->seq); + "id", dev_seq(dev)); return 0; } @@ -207,8 +207,8 @@ U_BOOT_DRIVER(serial_s5p) = { .name = "serial_s5p", .id = UCLASS_SERIAL, .of_match = s5p_serial_ids, - .ofdata_to_platdata = s5p_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct s5p_serial_platdata), + .of_to_plat = s5p_serial_of_to_plat, + .plat_auto = sizeof(struct s5p_serial_plat), .probe = s5p_serial_probe, .ops = &s5p_serial_ops, }; diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index e27d256574..d74f890233 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -169,7 +169,7 @@ static int sh_serial_getc(struct udevice *dev) static int sh_serial_setbrg(struct udevice *dev, int baudrate) { - struct sh_serial_platdata *plat = dev_get_platdata(dev); + struct sh_serial_plat *plat = dev_get_plat(dev); struct uart_port *priv = dev_get_priv(dev); sh_serial_setbrg_generic(priv, plat->clk, baudrate); @@ -179,7 +179,7 @@ static int sh_serial_setbrg(struct udevice *dev, int baudrate) static int sh_serial_probe(struct udevice *dev) { - struct sh_serial_platdata *plat = dev_get_platdata(dev); + struct sh_serial_plat *plat = dev_get_plat(dev); struct uart_port *priv = dev_get_priv(dev); priv->membase = (unsigned char *)plat->base; @@ -207,9 +207,9 @@ static const struct udevice_id sh_serial_id[] ={ {} }; -static int sh_serial_ofdata_to_platdata(struct udevice *dev) +static int sh_serial_of_to_plat(struct udevice *dev) { - struct sh_serial_platdata *plat = dev_get_platdata(dev); + struct sh_serial_plat *plat = dev_get_plat(dev); struct clk sh_serial_clk; fdt_addr_t addr; int ret; @@ -239,14 +239,14 @@ U_BOOT_DRIVER(serial_sh) = { .name = "serial_sh", .id = UCLASS_SERIAL, .of_match = of_match_ptr(sh_serial_id), - .ofdata_to_platdata = of_match_ptr(sh_serial_ofdata_to_platdata), - .platdata_auto_alloc_size = sizeof(struct sh_serial_platdata), + .of_to_plat = of_match_ptr(sh_serial_of_to_plat), + .plat_auto = sizeof(struct sh_serial_plat), .probe = sh_serial_probe, .ops = &sh_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, #endif - .priv_auto_alloc_size = sizeof(struct uart_port), + .priv_auto = sizeof(struct uart_port), }; #else /* CONFIG_DM_SERIAL */ diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c index fcc47fb348..d26fe7e770 100644 --- a/drivers/serial/serial_sifive.c +++ b/drivers/serial/serial_sifive.c @@ -37,7 +37,7 @@ struct uart_sifive { u32 div; }; -struct sifive_uart_platdata { +struct sifive_uart_plat { unsigned long clock; struct uart_sifive *regs; }; @@ -105,7 +105,7 @@ static int sifive_serial_setbrg(struct udevice *dev, int baudrate) { int ret; struct clk clk; - struct sifive_uart_platdata *platdata = dev_get_platdata(dev); + struct sifive_uart_plat *plat = dev_get_plat(dev); u32 clock = 0; ret = clk_get_by_index(dev, 0, &clk); @@ -123,21 +123,21 @@ static int sifive_serial_setbrg(struct udevice *dev, int baudrate) return 0; } } - platdata->clock = clock; - _sifive_serial_setbrg(platdata->regs, platdata->clock, baudrate); + plat->clock = clock; + _sifive_serial_setbrg(plat->regs, plat->clock, baudrate); return 0; } static int sifive_serial_probe(struct udevice *dev) { - struct sifive_uart_platdata *platdata = dev_get_platdata(dev); + struct sifive_uart_plat *plat = dev_get_plat(dev); /* No need to reinitialize the UART after relocation */ if (gd->flags & GD_FLG_RELOC) return 0; - _sifive_serial_init(platdata->regs); + _sifive_serial_init(plat->regs); return 0; } @@ -145,8 +145,8 @@ static int sifive_serial_probe(struct udevice *dev) static int sifive_serial_getc(struct udevice *dev) { int c; - struct sifive_uart_platdata *platdata = dev_get_platdata(dev); - struct uart_sifive *regs = platdata->regs; + struct sifive_uart_plat *plat = dev_get_plat(dev); + struct uart_sifive *regs = plat->regs; while ((c = _sifive_serial_getc(regs)) == -EAGAIN) ; @@ -156,17 +156,17 @@ static int sifive_serial_getc(struct udevice *dev) static int sifive_serial_putc(struct udevice *dev, const char ch) { int rc; - struct sifive_uart_platdata *platdata = dev_get_platdata(dev); + struct sifive_uart_plat *plat = dev_get_plat(dev); - while ((rc = _sifive_serial_putc(platdata->regs, ch)) == -EAGAIN) ; + while ((rc = _sifive_serial_putc(plat->regs, ch)) == -EAGAIN) ; return rc; } static int sifive_serial_pending(struct udevice *dev, bool input) { - struct sifive_uart_platdata *platdata = dev_get_platdata(dev); - struct uart_sifive *regs = platdata->regs; + struct sifive_uart_plat *plat = dev_get_plat(dev); + struct uart_sifive *regs = plat->regs; if (input) return (readl(®s->ip) & UART_IP_RXWM); @@ -174,13 +174,13 @@ static int sifive_serial_pending(struct udevice *dev, bool input) return !!(readl(®s->txfifo) & UART_TXFIFO_FULL); } -static int sifive_serial_ofdata_to_platdata(struct udevice *dev) +static int sifive_serial_of_to_plat(struct udevice *dev) { - struct sifive_uart_platdata *platdata = dev_get_platdata(dev); + struct sifive_uart_plat *plat = dev_get_plat(dev); - platdata->regs = (struct uart_sifive *)dev_read_addr(dev); - if (IS_ERR(platdata->regs)) - return PTR_ERR(platdata->regs); + plat->regs = (struct uart_sifive *)dev_read_addr(dev); + if (IS_ERR(plat->regs)) + return PTR_ERR(plat->regs); return 0; } @@ -201,8 +201,8 @@ U_BOOT_DRIVER(serial_sifive) = { .name = "serial_sifive", .id = UCLASS_SERIAL, .of_match = sifive_serial_ids, - .ofdata_to_platdata = sifive_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct sifive_uart_platdata), + .of_to_plat = sifive_serial_of_to_plat, + .plat_auto = sizeof(struct sifive_uart_plat), .probe = sifive_serial_probe, .ops = &sifive_serial_ops, }; diff --git a/drivers/serial/serial_sti_asc.c b/drivers/serial/serial_sti_asc.c index 91e1574638..5d1a46c6bc 100644 --- a/drivers/serial/serial_sti_asc.c +++ b/drivers/serial/serial_sti_asc.c @@ -206,6 +206,6 @@ U_BOOT_DRIVER(serial_sti_asc) = { .of_match = sti_serial_of_match, .ops = &sti_asc_serial_ops, .probe = sti_asc_serial_probe, - .priv_auto_alloc_size = sizeof(struct sti_asc_serial), + .priv_auto = sizeof(struct sti_asc_serial), }; diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c index cab0db2c96..818c34cf11 100644 --- a/drivers/serial/serial_stm32.c +++ b/drivers/serial/serial_stm32.c @@ -44,7 +44,7 @@ static void _stm32_serial_setbrg(fdt_addr_t base, static int stm32_serial_setbrg(struct udevice *dev, int baudrate) { - struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); + struct stm32x7_serial_plat *plat = dev_get_plat(dev); _stm32_serial_setbrg(plat->base, plat->uart_info, plat->clock_rate, baudrate); @@ -54,7 +54,7 @@ static int stm32_serial_setbrg(struct udevice *dev, int baudrate) static int stm32_serial_setconfig(struct udevice *dev, uint serial_config) { - struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); + struct stm32x7_serial_plat *plat = dev_get_plat(dev); bool stm32f4 = plat->uart_info->stm32f4; u8 uart_enable_bit = plat->uart_info->uart_enable_bit; u32 cr1 = plat->base + CR1_OFFSET(stm32f4); @@ -102,7 +102,7 @@ static int stm32_serial_setconfig(struct udevice *dev, uint serial_config) static int stm32_serial_getc(struct udevice *dev) { - struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); + struct stm32x7_serial_plat *plat = dev_get_plat(dev); bool stm32f4 = plat->uart_info->stm32f4; fdt_addr_t base = plat->base; u32 isr = readl(base + ISR_OFFSET(stm32f4)); @@ -139,14 +139,14 @@ static int _stm32_serial_putc(fdt_addr_t base, static int stm32_serial_putc(struct udevice *dev, const char c) { - struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); + struct stm32x7_serial_plat *plat = dev_get_plat(dev); return _stm32_serial_putc(plat->base, plat->uart_info, c); } static int stm32_serial_pending(struct udevice *dev, bool input) { - struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); + struct stm32x7_serial_plat *plat = dev_get_plat(dev); bool stm32f4 = plat->uart_info->stm32f4; fdt_addr_t base = plat->base; @@ -175,7 +175,7 @@ static void _stm32_serial_init(fdt_addr_t base, static int stm32_serial_probe(struct udevice *dev) { - struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); + struct stm32x7_serial_plat *plat = dev_get_plat(dev); struct clk clk; struct reset_ctl reset; int ret; @@ -217,9 +217,9 @@ static const struct udevice_id stm32_serial_id[] = { {} }; -static int stm32_serial_ofdata_to_platdata(struct udevice *dev) +static int stm32_serial_of_to_plat(struct udevice *dev) { - struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); + struct stm32x7_serial_plat *plat = dev_get_plat(dev); plat->base = dev_read_addr(dev); if (plat->base == FDT_ADDR_T_NONE) @@ -240,8 +240,8 @@ U_BOOT_DRIVER(serial_stm32) = { .name = "serial_stm32", .id = UCLASS_SERIAL, .of_match = of_match_ptr(stm32_serial_id), - .ofdata_to_platdata = of_match_ptr(stm32_serial_ofdata_to_platdata), - .platdata_auto_alloc_size = sizeof(struct stm32x7_serial_platdata), + .of_to_plat = of_match_ptr(stm32_serial_of_to_plat), + .plat_auto = sizeof(struct stm32x7_serial_plat), .ops = &stm32_serial_ops, .probe = stm32_serial_probe, #if !CONFIG_IS_ENABLED(OF_CONTROL) diff --git a/drivers/serial/serial_stm32.h b/drivers/serial/serial_stm32.h index 5737651888..5bee68fa9c 100644 --- a/drivers/serial/serial_stm32.h +++ b/drivers/serial/serial_stm32.h @@ -48,7 +48,7 @@ struct stm32_uart_info stm32h7_info = { }; /* Information about a serial port */ -struct stm32x7_serial_platdata { +struct stm32x7_serial_plat { fdt_addr_t base; /* address of registers in physical memory */ struct stm32_uart_info *uart_info; unsigned long int clock_rate; diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c index a098028ca0..27e4b92c39 100644 --- a/drivers/serial/serial_uniphier.c +++ b/drivers/serial/serial_uniphier.c @@ -172,6 +172,6 @@ U_BOOT_DRIVER(uniphier_serial) = { .id = UCLASS_SERIAL, .of_match = uniphier_uart_of_match, .probe = uniphier_serial_probe, - .priv_auto_alloc_size = sizeof(struct uniphier_serial_priv), + .priv_auto = sizeof(struct uniphier_serial_priv), .ops = &uniphier_serial_ops, }; diff --git a/drivers/serial/serial_xen.c b/drivers/serial/serial_xen.c index ba6504b947..dbb7b22b51 100644 --- a/drivers/serial/serial_xen.c +++ b/drivers/serial/serial_xen.c @@ -172,7 +172,7 @@ U_BOOT_DRIVER(serial_xen) = { #if CONFIG_IS_ENABLED(OF_CONTROL) .of_match = xen_serial_ids, #endif - .priv_auto_alloc_size = sizeof(struct xen_uart_priv), + .priv_auto = sizeof(struct xen_uart_priv), .probe = xen_serial_probe, .ops = &xen_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) diff --git a/drivers/serial/serial_xuartlite.c b/drivers/serial/serial_xuartlite.c index 236ab860ad..9780a44d09 100644 --- a/drivers/serial/serial_xuartlite.c +++ b/drivers/serial/serial_xuartlite.c @@ -32,7 +32,7 @@ struct uartlite { unsigned int control; }; -struct uartlite_platdata { +struct uartlite_plat { struct uartlite *regs; }; @@ -54,7 +54,7 @@ static void uart_out32(void __iomem *addr, u32 val) static int uartlite_serial_putc(struct udevice *dev, const char ch) { - struct uartlite_platdata *plat = dev_get_platdata(dev); + struct uartlite_plat *plat = dev_get_plat(dev); struct uartlite *regs = plat->regs; if (uart_in32(®s->status) & SR_TX_FIFO_FULL) @@ -67,7 +67,7 @@ static int uartlite_serial_putc(struct udevice *dev, const char ch) static int uartlite_serial_getc(struct udevice *dev) { - struct uartlite_platdata *plat = dev_get_platdata(dev); + struct uartlite_plat *plat = dev_get_plat(dev); struct uartlite *regs = plat->regs; if (!(uart_in32(®s->status) & SR_RX_FIFO_VALID_DATA)) @@ -78,7 +78,7 @@ static int uartlite_serial_getc(struct udevice *dev) static int uartlite_serial_pending(struct udevice *dev, bool input) { - struct uartlite_platdata *plat = dev_get_platdata(dev); + struct uartlite_plat *plat = dev_get_plat(dev); struct uartlite *regs = plat->regs; if (input) @@ -89,7 +89,7 @@ static int uartlite_serial_pending(struct udevice *dev, bool input) static int uartlite_serial_probe(struct udevice *dev) { - struct uartlite_platdata *plat = dev_get_platdata(dev); + struct uartlite_plat *plat = dev_get_plat(dev); struct uartlite *regs = plat->regs; int ret; @@ -106,9 +106,9 @@ static int uartlite_serial_probe(struct udevice *dev) return 0; } -static int uartlite_serial_ofdata_to_platdata(struct udevice *dev) +static int uartlite_serial_of_to_plat(struct udevice *dev) { - struct uartlite_platdata *plat = dev_get_platdata(dev); + struct uartlite_plat *plat = dev_get_plat(dev); plat->regs = dev_read_addr_ptr(dev); @@ -131,8 +131,8 @@ U_BOOT_DRIVER(serial_uartlite) = { .name = "serial_uartlite", .id = UCLASS_SERIAL, .of_match = uartlite_serial_ids, - .ofdata_to_platdata = uartlite_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct uartlite_platdata), + .of_to_plat = uartlite_serial_of_to_plat, + .plat_auto = sizeof(struct uartlite_plat), .probe = uartlite_serial_probe, .ops = &uartlite_serial_ops, }; @@ -148,7 +148,7 @@ static inline void _debug_uart_init(void) uart_out32(®s->control, 0); uart_out32(®s->control, ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX); - uart_in32(®s->status); + ret = uart_in32(®s->status); /* Endianness detection */ if ((ret & SR_TX_FIFO_EMPTY) != SR_TX_FIFO_EMPTY) { little_endian = true; diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c index 0e71cada1b..2883e2466f 100644 --- a/drivers/serial/serial_zynq.c +++ b/drivers/serial/serial_zynq.c @@ -41,7 +41,7 @@ struct uart_zynq { u32 baud_rate_divider; /* 0x34 - Baud Rate Divider [7:0] */ }; -struct zynq_uart_platdata { +struct zynq_uart_plat { struct uart_zynq *regs; }; @@ -107,7 +107,7 @@ static int _uart_zynq_serial_putc(struct uart_zynq *regs, const char c) static int zynq_serial_setbrg(struct udevice *dev, int baudrate) { - struct zynq_uart_platdata *platdata = dev_get_platdata(dev); + struct zynq_uart_plat *plat = dev_get_plat(dev); unsigned long clock; int ret; @@ -132,15 +132,15 @@ static int zynq_serial_setbrg(struct udevice *dev, int baudrate) return ret; } - _uart_zynq_serial_setbrg(platdata->regs, clock, baudrate); + _uart_zynq_serial_setbrg(plat->regs, clock, baudrate); return 0; } static int zynq_serial_probe(struct udevice *dev) { - struct zynq_uart_platdata *platdata = dev_get_platdata(dev); - struct uart_zynq *regs = platdata->regs; + struct zynq_uart_plat *plat = dev_get_plat(dev); + struct uart_zynq *regs = plat->regs; u32 val; /* No need to reinitialize the UART if TX already enabled */ @@ -148,15 +148,15 @@ static int zynq_serial_probe(struct udevice *dev) if (val & ZYNQ_UART_CR_TX_EN) return 0; - _uart_zynq_serial_init(platdata->regs); + _uart_zynq_serial_init(plat->regs); return 0; } static int zynq_serial_getc(struct udevice *dev) { - struct zynq_uart_platdata *platdata = dev_get_platdata(dev); - struct uart_zynq *regs = platdata->regs; + struct zynq_uart_plat *plat = dev_get_plat(dev); + struct uart_zynq *regs = plat->regs; if (readl(®s->channel_sts) & ZYNQ_UART_SR_RXEMPTY) return -EAGAIN; @@ -166,15 +166,15 @@ static int zynq_serial_getc(struct udevice *dev) static int zynq_serial_putc(struct udevice *dev, const char ch) { - struct zynq_uart_platdata *platdata = dev_get_platdata(dev); + struct zynq_uart_plat *plat = dev_get_plat(dev); - return _uart_zynq_serial_putc(platdata->regs, ch); + return _uart_zynq_serial_putc(plat->regs, ch); } static int zynq_serial_pending(struct udevice *dev, bool input) { - struct zynq_uart_platdata *platdata = dev_get_platdata(dev); - struct uart_zynq *regs = platdata->regs; + struct zynq_uart_plat *plat = dev_get_plat(dev); + struct uart_zynq *regs = plat->regs; if (input) return !(readl(®s->channel_sts) & ZYNQ_UART_SR_RXEMPTY); @@ -182,13 +182,13 @@ static int zynq_serial_pending(struct udevice *dev, bool input) return !!(readl(®s->channel_sts) & ZYNQ_UART_SR_TXACTIVE); } -static int zynq_serial_ofdata_to_platdata(struct udevice *dev) +static int zynq_serial_of_to_plat(struct udevice *dev) { - struct zynq_uart_platdata *platdata = dev_get_platdata(dev); + struct zynq_uart_plat *plat = dev_get_plat(dev); - platdata->regs = (struct uart_zynq *)dev_read_addr(dev); - if (IS_ERR(platdata->regs)) - return PTR_ERR(platdata->regs); + plat->regs = (struct uart_zynq *)dev_read_addr(dev); + if (IS_ERR(plat->regs)) + return PTR_ERR(plat->regs); return 0; } @@ -211,8 +211,8 @@ U_BOOT_DRIVER(serial_zynq) = { .name = "serial_zynq", .id = UCLASS_SERIAL, .of_match = zynq_serial_ids, - .ofdata_to_platdata = zynq_serial_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct zynq_uart_platdata), + .of_to_plat = zynq_serial_of_to_plat, + .plat_auto = sizeof(struct zynq_uart_plat), .probe = zynq_serial_probe, .ops = &zynq_serial_ops, }; diff --git a/drivers/soc/soc_ti_k3.c b/drivers/soc/soc_ti_k3.c index 94285403ca..ecc3278cb4 100644 --- a/drivers/soc/soc_ti_k3.c +++ b/drivers/soc/soc_ti_k3.c @@ -22,7 +22,7 @@ #define JTAG_ID_PARTNO_SHIFT 12 #define JTAG_ID_PARTNO_MASK (0xffff << 12) -struct soc_ti_k3_platdata { +struct soc_ti_k3_plat { const char *family; const char *revision; }; @@ -74,7 +74,7 @@ static const char *get_rev_string(u32 idreg) static int soc_ti_k3_get_family(struct udevice *dev, char *buf, int size) { - struct soc_ti_k3_platdata *plat = dev_get_platdata(dev); + struct soc_ti_k3_plat *plat = dev_get_plat(dev); snprintf(buf, size, "%s", plat->family); @@ -83,7 +83,7 @@ static int soc_ti_k3_get_family(struct udevice *dev, char *buf, int size) static int soc_ti_k3_get_revision(struct udevice *dev, char *buf, int size) { - struct soc_ti_k3_platdata *plat = dev_get_platdata(dev); + struct soc_ti_k3_plat *plat = dev_get_plat(dev); snprintf(buf, size, "SR%s", plat->revision); @@ -97,7 +97,7 @@ static const struct soc_ops soc_ti_k3_ops = { int soc_ti_k3_probe(struct udevice *dev) { - struct soc_ti_k3_platdata *plat = dev_get_platdata(dev); + struct soc_ti_k3_plat *plat = dev_get_plat(dev); u32 idreg; void *idreg_addr; @@ -124,5 +124,5 @@ U_BOOT_DRIVER(soc_ti_k3) = { .ops = &soc_ti_k3_ops, .of_match = soc_ti_k3_ids, .probe = soc_ti_k3_probe, - .platdata_auto_alloc_size = sizeof(struct soc_ti_k3_platdata), + .plat_auto = sizeof(struct soc_ti_k3_plat), }; diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c index c48e9befe4..c5099ad084 100644 --- a/drivers/soc/ti/k3-navss-ringacc.c +++ b/drivers/soc/ti/k3-navss-ringacc.c @@ -1130,5 +1130,5 @@ U_BOOT_DRIVER(k3_navss_ringacc) = { .id = UCLASS_MISC, .of_match = knav_ringacc_ids, .probe = k3_nav_ringacc_probe, - .priv_auto_alloc_size = sizeof(struct k3_nav_ringacc), + .priv_auto = sizeof(struct k3_nav_ringacc), }; diff --git a/drivers/sound/broadwell_i2s.c b/drivers/sound/broadwell_i2s.c index adb0b2b104..7f754e6567 100644 --- a/drivers/sound/broadwell_i2s.c +++ b/drivers/sound/broadwell_i2s.c @@ -304,5 +304,5 @@ U_BOOT_DRIVER(broadwell_i2s) = { .of_match = broadwell_i2s_ids, .probe = broadwell_i2s_probe, .ops = &broadwell_i2s_ops, - .priv_auto_alloc_size = sizeof(struct broadwell_i2s_priv), + .priv_auto = sizeof(struct broadwell_i2s_priv), }; diff --git a/drivers/sound/hda_codec.c b/drivers/sound/hda_codec.c index 4154d29399..eb92830ad9 100644 --- a/drivers/sound/hda_codec.c +++ b/drivers/sound/hda_codec.c @@ -539,7 +539,7 @@ U_BOOT_DRIVER(hda_codec) = { .name = "hda_codec", .id = UCLASS_SOUND, .ops = &hda_codec_ops, - .priv_auto_alloc_size = sizeof(struct hda_codec_priv), + .priv_auto = sizeof(struct hda_codec_priv), .probe = hda_codec_init, }; diff --git a/drivers/sound/i2s-uclass.c b/drivers/sound/i2s-uclass.c index b741e3952d..2639c86ea2 100644 --- a/drivers/sound/i2s-uclass.c +++ b/drivers/sound/i2s-uclass.c @@ -21,5 +21,5 @@ int i2s_tx_data(struct udevice *dev, void *data, uint data_size) UCLASS_DRIVER(i2s) = { .id = UCLASS_I2S, .name = "i2s", - .per_device_auto_alloc_size = sizeof(struct i2s_uc_priv), + .per_device_auto = sizeof(struct i2s_uc_priv), }; diff --git a/drivers/sound/ivybridge_sound.c b/drivers/sound/ivybridge_sound.c index bc3c1e85f8..492a86cafe 100644 --- a/drivers/sound/ivybridge_sound.c +++ b/drivers/sound/ivybridge_sound.c @@ -22,7 +22,7 @@ static int bd82x6x_azalia_probe(struct udevice *dev) { - struct pci_child_platdata *plat; + struct pci_child_plat *plat; struct hda_codec_priv *priv; struct udevice *pch; u32 codec_mask; @@ -71,7 +71,7 @@ static int bd82x6x_azalia_probe(struct udevice *dev) dm_pci_clrset_config32(dev, 0xd0, 1U << 31, 0); /* Additional step on Panther Point */ - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); if (plat->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_HDA) dm_pci_clrset_config32(dev, 0xc4, 0, 1 << 17); @@ -135,5 +135,5 @@ U_BOOT_DRIVER(bd82x6x_azalia_drv) = { .of_match = bd82x6x_azalia_ids, .probe = bd82x6x_azalia_probe, .ops = &bd82x6x_azalia_ops, - .priv_auto_alloc_size = sizeof(struct hda_codec_priv), + .priv_auto = sizeof(struct hda_codec_priv), }; diff --git a/drivers/sound/max98088.c b/drivers/sound/max98088.c index 5b4c489f4b..4bcb7482b2 100644 --- a/drivers/sound/max98088.c +++ b/drivers/sound/max98088.c @@ -421,5 +421,5 @@ U_BOOT_DRIVER(max98088) = { .of_match = max98088_ids, .probe = max98088_probe, .ops = &max98088_ops, - .priv_auto_alloc_size = sizeof(struct maxim_priv), + .priv_auto = sizeof(struct maxim_priv), }; diff --git a/drivers/sound/max98090.c b/drivers/sound/max98090.c index d23955d6e1..c77a732277 100644 --- a/drivers/sound/max98090.c +++ b/drivers/sound/max98090.c @@ -368,5 +368,5 @@ U_BOOT_DRIVER(max98090) = { .of_match = max98090_ids, .probe = max98090_probe, .ops = &max98090_ops, - .priv_auto_alloc_size = sizeof(struct maxim_priv), + .priv_auto = sizeof(struct maxim_priv), }; diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c index 5037f9516f..002dab437f 100644 --- a/drivers/sound/max98095.c +++ b/drivers/sound/max98095.c @@ -462,5 +462,5 @@ U_BOOT_DRIVER(max98095) = { .of_match = max98095_ids, .probe = max98095_probe, .ops = &max98095_ops, - .priv_auto_alloc_size = sizeof(struct maxim_priv), + .priv_auto = sizeof(struct maxim_priv), }; diff --git a/drivers/sound/max98357a.c b/drivers/sound/max98357a.c index b3d27a3616..a2088f0301 100644 --- a/drivers/sound/max98357a.c +++ b/drivers/sound/max98357a.c @@ -25,7 +25,7 @@ struct max98357a_priv { struct gpio_desc sdmode_gpio; }; -static int max98357a_ofdata_to_platdata(struct udevice *dev) +static int max98357a_of_to_plat(struct udevice *dev) { struct max98357a_priv *priv = dev_get_priv(dev); int ret; @@ -155,7 +155,7 @@ U_BOOT_DRIVER(max98357a) = { .name = "max98357a", .id = UCLASS_AUDIO_CODEC, .of_match = max98357a_ids, - .ofdata_to_platdata = max98357a_ofdata_to_platdata, + .of_to_plat = max98357a_of_to_plat, .ops = &max98357a_ops, ACPI_OPS_PTR(&max98357a_acpi_ops) }; diff --git a/drivers/sound/rt5677.c b/drivers/sound/rt5677.c index 16aa9dfc5b..b655bb40b6 100644 --- a/drivers/sound/rt5677.c +++ b/drivers/sound/rt5677.c @@ -331,5 +331,5 @@ U_BOOT_DRIVER(rt5677_drv) = { .of_match = rt5677_ids, .ops = &rt5677_ops, .probe = rt5677_probe, - .priv_auto_alloc_size = sizeof(struct rt5677_priv), + .priv_auto = sizeof(struct rt5677_priv), }; diff --git a/drivers/sound/samsung-i2s.c b/drivers/sound/samsung-i2s.c index aa1d6bb209..d3d75c046e 100644 --- a/drivers/sound/samsung-i2s.c +++ b/drivers/sound/samsung-i2s.c @@ -385,7 +385,7 @@ static int samsung_i2s_probe(struct udevice *dev) return i2s_tx_init(priv); } -static int samsung_i2s_ofdata_to_platdata(struct udevice *dev) +static int samsung_i2s_of_to_plat(struct udevice *dev) { struct i2s_uc_priv *priv = dev_get_uclass_priv(dev); ulong base; @@ -451,6 +451,6 @@ U_BOOT_DRIVER(samsung_i2s) = { .id = UCLASS_I2S, .of_match = samsung_i2s_ids, .probe = samsung_i2s_probe, - .ofdata_to_platdata = samsung_i2s_ofdata_to_platdata, + .of_to_plat = samsung_i2s_of_to_plat, .ops = &samsung_i2s_ops, }; diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c index 0686add3c8..4a2c87a84c 100644 --- a/drivers/sound/sandbox.c +++ b/drivers/sound/sandbox.c @@ -223,7 +223,7 @@ U_BOOT_DRIVER(sandbox_codec) = { .id = UCLASS_AUDIO_CODEC, .of_match = sandbox_codec_ids, .ops = &sandbox_codec_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_codec_priv), + .priv_auto = sizeof(struct sandbox_codec_priv), }; static const struct i2s_ops sandbox_i2s_ops = { @@ -241,7 +241,7 @@ U_BOOT_DRIVER(sandbox_i2s) = { .of_match = sandbox_i2s_ids, .ops = &sandbox_i2s_ops, .probe = sandbox_i2s_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_i2s_priv), + .priv_auto = sizeof(struct sandbox_i2s_priv), }; static const struct sound_ops sandbox_sound_ops = { @@ -262,6 +262,6 @@ U_BOOT_DRIVER(sandbox_sound) = { .id = UCLASS_SOUND, .of_match = sandbox_sound_ids, .ops = &sandbox_sound_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_sound_priv), + .priv_auto = sizeof(struct sandbox_sound_priv), .probe = sandbox_sound_probe, }; diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c index 92f4b0b924..0c71e01f33 100644 --- a/drivers/sound/sound-uclass.c +++ b/drivers/sound/sound-uclass.c @@ -172,5 +172,5 @@ int sound_find_codec_i2s(struct udevice *dev) UCLASS_DRIVER(sound) = { .id = UCLASS_SOUND, .name = "sound", - .per_device_auto_alloc_size = sizeof(struct sound_uc_priv), + .per_device_auto = sizeof(struct sound_uc_priv), }; diff --git a/drivers/sound/tegra_ahub.c b/drivers/sound/tegra_ahub.c index 26d457255c..8708fc44a9 100644 --- a/drivers/sound/tegra_ahub.c +++ b/drivers/sound/tegra_ahub.c @@ -253,5 +253,5 @@ U_BOOT_DRIVER(tegra_ahub) = { .of_match = tegra_ahub_ids, .ops = &tegra_ahub_ops, .probe = tegra_ahub_probe, - .priv_auto_alloc_size = sizeof(struct tegra_ahub_priv), + .priv_auto = sizeof(struct tegra_ahub_priv), }; diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 367e144541..cb1e97d7a5 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -873,5 +873,5 @@ U_BOOT_DRIVER(wm8994) = { .of_match = wm8994_ids, .probe = wm8994_probe, .ops = &wm8994_ops, - .priv_auto_alloc_size = sizeof(struct wm8994_priv), + .priv_auto = sizeof(struct wm8994_priv), }; diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 61372c52b0..fadc9f3965 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -32,7 +32,7 @@ struct altera_spi_regs { u32 slave_sel; }; -struct altera_spi_platdata { +struct altera_spi_plat { struct altera_spi_regs *regs; }; @@ -89,7 +89,7 @@ static int altera_spi_xfer(struct udevice *dev, unsigned int bitlen, struct udevice *bus = dev->parent; struct altera_spi_priv *priv = dev_get_priv(bus); struct altera_spi_regs *const regs = priv->regs; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); /* assume spi core configured to do 8 bit transfers */ unsigned int bytes = bitlen / 8; @@ -98,7 +98,7 @@ static int altera_spi_xfer(struct udevice *dev, unsigned int bitlen, uint32_t reg, data, start; debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__, - bus->seq, slave_plat->cs, bitlen, bytes, flags); + dev_seq(bus), slave_plat->cs, bitlen, bytes, flags); if (bitlen == 0) goto done; @@ -161,7 +161,7 @@ static int altera_spi_set_mode(struct udevice *bus, uint mode) static int altera_spi_probe(struct udevice *bus) { - struct altera_spi_platdata *plat = dev_get_platdata(bus); + struct altera_spi_plat *plat = dev_get_plat(bus); struct altera_spi_priv *priv = dev_get_priv(bus); priv->regs = plat->regs; @@ -169,9 +169,9 @@ static int altera_spi_probe(struct udevice *bus) return 0; } -static int altera_spi_ofdata_to_platdata(struct udevice *bus) +static int altera_spi_of_to_plat(struct udevice *bus) { - struct altera_spi_platdata *plat = dev_get_platdata(bus); + struct altera_spi_plat *plat = dev_get_plat(bus); plat->regs = map_physmem(dev_read_addr(bus), sizeof(struct altera_spi_regs), @@ -202,8 +202,8 @@ U_BOOT_DRIVER(altera_spi) = { .id = UCLASS_SPI, .of_match = altera_spi_ids, .ops = &altera_spi_ops, - .ofdata_to_platdata = altera_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_spi_platdata), - .priv_auto_alloc_size = sizeof(struct altera_spi_priv), + .of_to_plat = altera_spi_of_to_plat, + .plat_auto = sizeof(struct altera_spi_plat), + .priv_auto = sizeof(struct altera_spi_priv), .probe = altera_spi_probe, }; diff --git a/drivers/spi/atcspi200_spi.c b/drivers/spi/atcspi200_spi.c index 39c6e226ba..0f05158c84 100644 --- a/drivers/spi/atcspi200_spi.c +++ b/drivers/spi/atcspi200_spi.c @@ -309,8 +309,8 @@ static int atcspi200_spi_set_mode(struct udevice *bus, uint mode) static int atcspi200_spi_claim_bus(struct udevice *dev) { - struct dm_spi_slave_platdata *slave_plat = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = + dev_get_parent_plat(dev); struct udevice *bus = dev->parent; struct nds_spi_slave *ns = dev_get_priv(bus); @@ -408,7 +408,7 @@ U_BOOT_DRIVER(atcspi200_spi) = { .id = UCLASS_SPI, .of_match = atcspi200_spi_ids, .ops = &atcspi200_spi_ops, - .ofdata_to_platdata = atcspi200_ofdata_to_platadata, - .priv_auto_alloc_size = sizeof(struct nds_spi_slave), + .of_to_plat = atcspi200_ofdata_to_platadata, + .priv_auto = sizeof(struct nds_spi_slave), .probe = atcspi200_spi_probe, }; diff --git a/drivers/spi/ath79_spi.c b/drivers/spi/ath79_spi.c index 70bedc7fbe..205567ef54 100644 --- a/drivers/spi/ath79_spi.c +++ b/drivers/spi/ath79_spi.c @@ -59,7 +59,7 @@ static int ath79_spi_xfer(struct udevice *dev, unsigned int bitlen, { struct udevice *bus = dev_get_parent(dev); struct ath79_spi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave = dev_get_parent_plat(dev); u8 *rx = din; const u8 *tx = dout; u8 curbyte, curbitlen, restbits; @@ -224,6 +224,6 @@ U_BOOT_DRIVER(ath79_spi) = { .id = UCLASS_SPI, .of_match = ath79_spi_ids, .ops = &ath79_spi_ops, - .priv_auto_alloc_size = sizeof(struct ath79_spi_priv), + .priv_auto = sizeof(struct ath79_spi_priv), .probe = ath79_spi_probe, }; diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c index 9320a8be68..b1a3aa9a29 100644 --- a/drivers/spi/atmel-quadspi.c +++ b/drivers/spi/atmel-quadspi.c @@ -624,6 +624,6 @@ U_BOOT_DRIVER(atmel_qspi) = { .id = UCLASS_SPI, .of_match = atmel_qspi_ids, .ops = &atmel_qspi_ops, - .priv_auto_alloc_size = sizeof(struct atmel_qspi), + .priv_auto = sizeof(struct atmel_qspi), .probe = atmel_qspi_probe, }; diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index c65733c87a..702e225358 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -105,7 +105,7 @@ #define spi_writel(as, reg, value) \ writel(value, as->regs + ATMEL_SPI_##reg) -struct atmel_spi_platdata { +struct atmel_spi_plat { struct at91_spi *regs; }; @@ -121,9 +121,9 @@ struct atmel_spi_priv { static int atmel_spi_claim_bus(struct udevice *dev) { struct udevice *bus = dev_get_parent(dev); - struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus); + struct atmel_spi_plat *bus_plat = dev_get_plat(bus); struct atmel_spi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); struct at91_spi *reg_base = bus_plat->regs; u32 cs = slave_plat->cs; u32 freq = priv->freq; @@ -161,7 +161,7 @@ static int atmel_spi_claim_bus(struct udevice *dev) static int atmel_spi_release_bus(struct udevice *dev) { struct udevice *bus = dev_get_parent(dev); - struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus); + struct atmel_spi_plat *bus_plat = dev_get_plat(bus); writel(ATMEL_SPI_CR_SPIDIS, &bus_plat->regs->cr); @@ -173,7 +173,7 @@ static void atmel_spi_cs_activate(struct udevice *dev) #if CONFIG_IS_ENABLED(DM_GPIO) struct udevice *bus = dev_get_parent(dev); struct atmel_spi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); u32 cs = slave_plat->cs; if (!dm_gpio_is_valid(&priv->cs_gpios[cs])) @@ -188,7 +188,7 @@ static void atmel_spi_cs_deactivate(struct udevice *dev) #if CONFIG_IS_ENABLED(DM_GPIO) struct udevice *bus = dev_get_parent(dev); struct atmel_spi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); u32 cs = slave_plat->cs; if (!dm_gpio_is_valid(&priv->cs_gpios[cs])) @@ -202,7 +202,7 @@ static int atmel_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev_get_parent(dev); - struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus); + struct atmel_spi_plat *bus_plat = dev_get_plat(bus); struct at91_spi *reg_base = bus_plat->regs; u32 len_tx, len_rx, len; @@ -344,7 +344,7 @@ static int atmel_spi_enable_clk(struct udevice *bus) static int atmel_spi_probe(struct udevice *bus) { - struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus); + struct atmel_spi_plat *bus_plat = dev_get_plat(bus); int ret; ret = atmel_spi_enable_clk(bus); @@ -388,7 +388,7 @@ U_BOOT_DRIVER(atmel_spi) = { .id = UCLASS_SPI, .of_match = atmel_spi_ids, .ops = &atmel_spi_ops, - .platdata_auto_alloc_size = sizeof(struct atmel_spi_platdata), - .priv_auto_alloc_size = sizeof(struct atmel_spi_priv), + .plat_auto = sizeof(struct atmel_spi_plat), + .priv_auto = sizeof(struct atmel_spi_priv), .probe = atmel_spi_probe, }; diff --git a/drivers/spi/bcm63xx_hsspi.c b/drivers/spi/bcm63xx_hsspi.c index f30a8a42bd..85108df565 100644 --- a/drivers/spi/bcm63xx_hsspi.c +++ b/drivers/spi/bcm63xx_hsspi.c @@ -140,7 +140,7 @@ static int bcm63xx_hsspi_set_speed(struct udevice *bus, uint speed) } static void bcm63xx_hsspi_activate_cs(struct bcm63xx_hsspi_priv *priv, - struct dm_spi_slave_platdata *plat) + struct dm_spi_slave_plat *plat) { uint32_t clr, set; @@ -217,7 +217,7 @@ static int bcm63xx_hsspi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct bcm63xx_hsspi_priv *priv = dev_get_priv(dev->parent); - struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); size_t data_bytes = bitlen / 8; size_t step_size = HSSPI_FIFO_SIZE; uint16_t opcode = 0; @@ -316,7 +316,7 @@ static const struct udevice_id bcm63xx_hsspi_ids[] = { static int bcm63xx_hsspi_child_pre_probe(struct udevice *dev) { struct bcm63xx_hsspi_priv *priv = dev_get_priv(dev->parent); - struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); /* check cs */ if (plat->cs >= priv->num_cs) { @@ -403,7 +403,7 @@ U_BOOT_DRIVER(bcm63xx_hsspi) = { .id = UCLASS_SPI, .of_match = bcm63xx_hsspi_ids, .ops = &bcm63xx_hsspi_ops, - .priv_auto_alloc_size = sizeof(struct bcm63xx_hsspi_priv), + .priv_auto = sizeof(struct bcm63xx_hsspi_priv), .child_pre_probe = bcm63xx_hsspi_child_pre_probe, .probe = bcm63xx_hsspi_probe, }; diff --git a/drivers/spi/bcm63xx_spi.c b/drivers/spi/bcm63xx_spi.c index acc1a493c4..dd5e62b2fe 100644 --- a/drivers/spi/bcm63xx_spi.c +++ b/drivers/spi/bcm63xx_spi.c @@ -236,8 +236,8 @@ static int bcm63xx_spi_xfer(struct udevice *dev, unsigned int bitlen, } if (flags & SPI_XFER_END) { - struct dm_spi_slave_platdata *plat = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = + dev_get_parent_plat(dev); uint16_t val, cmd; int ret; @@ -351,7 +351,7 @@ static int bcm63xx_spi_child_pre_probe(struct udevice *dev) struct bcm63xx_spi_priv *priv = dev_get_priv(dev->parent); const unsigned long *regs = priv->regs; struct spi_slave *slave = dev_get_parent_priv(dev); - struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); /* check cs */ if (plat->cs >= priv->num_cs) { @@ -422,7 +422,7 @@ U_BOOT_DRIVER(bcm63xx_spi) = { .id = UCLASS_SPI, .of_match = bcm63xx_spi_ids, .ops = &bcm63xx_spi_ops, - .priv_auto_alloc_size = sizeof(struct bcm63xx_spi_priv), + .priv_auto = sizeof(struct bcm63xx_spi_priv), .child_pre_probe = bcm63xx_spi_child_pre_probe, .probe = bcm63xx_spi_probe, }; diff --git a/drivers/spi/bcmstb_spi.c b/drivers/spi/bcmstb_spi.c index fb1dc46b70..dc4fdacdc9 100644 --- a/drivers/spi/bcmstb_spi.c +++ b/drivers/spi/bcmstb_spi.c @@ -76,7 +76,7 @@ enum bcmstb_base_type { BASE_LAST, }; -struct bcmstb_spi_platdata { +struct bcmstb_spi_plat { void *base[4]; }; @@ -94,9 +94,9 @@ struct bcmstb_spi_priv { void *saved_din_addr; }; -static int bcmstb_spi_ofdata_to_platdata(struct udevice *bus) +static int bcmstb_spi_of_to_plat(struct udevice *bus) { - struct bcmstb_spi_platdata *plat = dev_get_platdata(bus); + struct bcmstb_spi_plat *plat = dev_get_plat(bus); const void *fdt = gd->fdt_blob; int node = dev_of_offset(bus); int ret = 0; @@ -159,7 +159,7 @@ static void bcmstb_spi_clear_interrupt(void *base, u32 mask) static int bcmstb_spi_probe(struct udevice *bus) { - struct bcmstb_spi_platdata *plat = dev_get_platdata(bus); + struct bcmstb_spi_plat *plat = dev_get_plat(bus); struct bcmstb_spi_priv *priv = dev_get_priv(bus); priv->regs = plat->base[HIF_MSPI]; @@ -432,8 +432,8 @@ U_BOOT_DRIVER(bcmstb_spi) = { .id = UCLASS_SPI, .of_match = bcmstb_spi_id, .ops = &bcmstb_spi_ops, - .ofdata_to_platdata = bcmstb_spi_ofdata_to_platdata, + .of_to_plat = bcmstb_spi_of_to_plat, .probe = bcmstb_spi_probe, - .platdata_auto_alloc_size = sizeof(struct bcmstb_spi_platdata), - .priv_auto_alloc_size = sizeof(struct bcmstb_spi_priv), + .plat_auto = sizeof(struct bcmstb_spi_plat), + .priv_auto = sizeof(struct bcmstb_spi_priv), }; diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c index 1e85749209..67980431ba 100644 --- a/drivers/spi/cadence_qspi.c +++ b/drivers/spi/cadence_qspi.c @@ -27,7 +27,7 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz) { - struct cadence_spi_platdata *plat = bus->platdata; + struct cadence_spi_plat *plat = dev_get_plat(bus); struct cadence_spi_priv *priv = dev_get_priv(bus); cadence_qspi_apb_config_baudrate_div(priv->regbase, @@ -130,7 +130,7 @@ static int spi_calibration(struct udevice *bus, uint hz) static int cadence_spi_set_speed(struct udevice *bus, uint hz) { - struct cadence_spi_platdata *plat = bus->platdata; + struct cadence_spi_plat *plat = dev_get_plat(bus); struct cadence_spi_priv *priv = dev_get_priv(bus); int err; @@ -165,7 +165,7 @@ static int cadence_spi_set_speed(struct udevice *bus, uint hz) static int cadence_spi_probe(struct udevice *bus) { - struct cadence_spi_platdata *plat = bus->platdata; + struct cadence_spi_plat *plat = dev_get_plat(bus); struct cadence_spi_priv *priv = dev_get_priv(bus); struct clk clk; int ret; @@ -212,7 +212,7 @@ static int cadence_spi_remove(struct udevice *dev) static int cadence_spi_set_mode(struct udevice *bus, uint mode) { - struct cadence_spi_platdata *plat = bus->platdata; + struct cadence_spi_plat *plat = dev_get_plat(bus); struct cadence_spi_priv *priv = dev_get_priv(bus); /* Disable QSPI */ @@ -235,7 +235,7 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi, const struct spi_mem_op *op) { struct udevice *bus = spi->dev->parent; - struct cadence_spi_platdata *plat = bus->platdata; + struct cadence_spi_plat *plat = dev_get_plat(bus); struct cadence_spi_priv *priv = dev_get_priv(bus); void *base = priv->regbase; int err = 0; @@ -282,9 +282,9 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi, return err; } -static int cadence_spi_ofdata_to_platdata(struct udevice *bus) +static int cadence_spi_of_to_plat(struct udevice *bus) { - struct cadence_spi_platdata *plat = bus->platdata; + struct cadence_spi_plat *plat = dev_get_plat(bus); ofnode subnode; plat->regbase = (void *)devfdt_get_addr_index(bus, 0); @@ -353,9 +353,9 @@ U_BOOT_DRIVER(cadence_spi) = { .id = UCLASS_SPI, .of_match = cadence_spi_ids, .ops = &cadence_spi_ops, - .ofdata_to_platdata = cadence_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct cadence_spi_platdata), - .priv_auto_alloc_size = sizeof(struct cadence_spi_priv), + .of_to_plat = cadence_spi_of_to_plat, + .plat_auto = sizeof(struct cadence_spi_plat), + .priv_auto = sizeof(struct cadence_spi_priv), .probe = cadence_spi_probe, .remove = cadence_spi_remove, .flags = DM_FLAG_OS_PREPARE, diff --git a/drivers/spi/cadence_qspi.h b/drivers/spi/cadence_qspi.h index ae459c74a1..64c5867609 100644 --- a/drivers/spi/cadence_qspi.h +++ b/drivers/spi/cadence_qspi.h @@ -15,7 +15,7 @@ #define CQSPI_DECODER_MAX_CS 16 #define CQSPI_READ_CAPTURE_MAX_DELAY 16 -struct cadence_spi_platdata { +struct cadence_spi_plat { unsigned int ref_clk_hz; unsigned int max_hz; void *regbase; @@ -52,7 +52,7 @@ struct cadence_spi_priv { }; /* Functions call declaration */ -void cadence_qspi_apb_controller_init(struct cadence_spi_platdata *plat); +void cadence_qspi_apb_controller_init(struct cadence_spi_plat *plat); void cadence_qspi_apb_controller_enable(void *reg_base_addr); void cadence_qspi_apb_controller_disable(void *reg_base_addr); void cadence_qspi_apb_dac_mode_enable(void *reg_base); @@ -62,13 +62,13 @@ int cadence_qspi_apb_command_read(void *reg_base_addr, int cadence_qspi_apb_command_write(void *reg_base_addr, const struct spi_mem_op *op); -int cadence_qspi_apb_read_setup(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_read_setup(struct cadence_spi_plat *plat, const struct spi_mem_op *op); -int cadence_qspi_apb_read_execute(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_read_execute(struct cadence_spi_plat *plat, const struct spi_mem_op *op); -int cadence_qspi_apb_write_setup(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_write_setup(struct cadence_spi_plat *plat, const struct spi_mem_op *op); -int cadence_qspi_apb_write_execute(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_write_execute(struct cadence_spi_plat *plat, const struct spi_mem_op *op); void cadence_qspi_apb_chipselect(void *reg_base, diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index f9675f75a4..b051f462ed 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -377,7 +377,7 @@ void cadence_qspi_apb_delay(void *reg_base, cadence_qspi_apb_controller_enable(reg_base); } -void cadence_qspi_apb_controller_init(struct cadence_spi_platdata *plat) +void cadence_qspi_apb_controller_init(struct cadence_spi_plat *plat) { unsigned reg; @@ -526,7 +526,7 @@ int cadence_qspi_apb_command_write(void *reg_base, const struct spi_mem_op *op) } /* Opcode + Address (3/4 bytes) + dummy bytes (0-4 bytes) */ -int cadence_qspi_apb_read_setup(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_read_setup(struct cadence_spi_plat *plat, const struct spi_mem_op *op) { unsigned int reg; @@ -572,14 +572,14 @@ int cadence_qspi_apb_read_setup(struct cadence_spi_platdata *plat, return 0; } -static u32 cadence_qspi_get_rd_sram_level(struct cadence_spi_platdata *plat) +static u32 cadence_qspi_get_rd_sram_level(struct cadence_spi_plat *plat) { u32 reg = readl(plat->regbase + CQSPI_REG_SDRAMLEVEL); reg >>= CQSPI_REG_SDRAMLEVEL_RD_LSB; return reg & CQSPI_REG_SDRAMLEVEL_RD_MASK; } -static int cadence_qspi_wait_for_data(struct cadence_spi_platdata *plat) +static int cadence_qspi_wait_for_data(struct cadence_spi_plat *plat) { unsigned int timeout = 10000; u32 reg; @@ -595,7 +595,7 @@ static int cadence_qspi_wait_for_data(struct cadence_spi_platdata *plat) } static int -cadence_qspi_apb_indirect_read_execute(struct cadence_spi_platdata *plat, +cadence_qspi_apb_indirect_read_execute(struct cadence_spi_plat *plat, unsigned int n_rx, u8 *rxbuf) { unsigned int remaining = n_rx; @@ -657,7 +657,7 @@ failrd: return ret; } -int cadence_qspi_apb_read_execute(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_read_execute(struct cadence_spi_plat *plat, const struct spi_mem_op *op) { u64 from = op->addr.val; @@ -678,7 +678,7 @@ int cadence_qspi_apb_read_execute(struct cadence_spi_platdata *plat, } /* Opcode + Address (3/4 bytes) */ -int cadence_qspi_apb_write_setup(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_write_setup(struct cadence_spi_plat *plat, const struct spi_mem_op *op) { unsigned int reg; @@ -701,7 +701,7 @@ int cadence_qspi_apb_write_setup(struct cadence_spi_platdata *plat, } static int -cadence_qspi_apb_indirect_write_execute(struct cadence_spi_platdata *plat, +cadence_qspi_apb_indirect_write_execute(struct cadence_spi_plat *plat, unsigned int n_tx, const u8 *txbuf) { unsigned int page_size = plat->page_size; @@ -774,7 +774,7 @@ failwr: return ret; } -int cadence_qspi_apb_write_execute(struct cadence_spi_platdata *plat, +int cadence_qspi_apb_write_execute(struct cadence_spi_plat *plat, const struct spi_mem_op *op) { u32 to = op->addr.val; diff --git a/drivers/spi/cf_spi.c b/drivers/spi/cf_spi.c index 8fa6d35107..298f350ef3 100644 --- a/drivers/spi/cf_spi.c +++ b/drivers/spi/cf_spi.c @@ -114,8 +114,8 @@ static int coldfire_spi_claim_bus(struct udevice *dev) struct udevice *bus = dev->parent; struct coldfire_spi_priv *cfspi = dev_get_priv(bus); struct dspi *dspi = cfspi->regs; - struct dm_spi_slave_platdata *slave_plat = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = + dev_get_parent_plat(dev); if ((in_be32(&dspi->sr) & DSPI_SR_TXRXS) != DSPI_SR_TXRXS) return -1; @@ -133,8 +133,8 @@ static int coldfire_spi_release_bus(struct udevice *dev) struct udevice *bus = dev->parent; struct coldfire_spi_priv *cfspi = dev_get_priv(bus); struct dspi *dspi = cfspi->regs; - struct dm_spi_slave_platdata *slave_plat = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = + dev_get_parent_plat(dev); /* Clear FIFO */ clrbits_be32(&dspi->mcr, DSPI_MCR_CTXF | DSPI_MCR_CRXF); @@ -150,7 +150,7 @@ static int coldfire_spi_xfer(struct udevice *dev, unsigned int bitlen, { struct udevice *bus = dev_get_parent(dev); struct coldfire_spi_priv *cfspi = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); u16 *spi_rd16 = NULL, *spi_wr16 = NULL; u8 *spi_rd = NULL, *spi_wr = NULL; static u32 ctrl; @@ -240,7 +240,7 @@ static int coldfire_spi_set_speed(struct udevice *bus, uint max_hz) cfspi->baudrate = max_hz; /* Read current setup */ - bus_setup = readl(&dspi->ctar[bus->seq]); + bus_setup = readl(&dspi->ctar[dev_seq(bus)]); tmp = (prescaler[3] * scaler[15]); /* Maximum and minimum baudrate it can handle */ @@ -294,7 +294,7 @@ static int coldfire_spi_set_speed(struct udevice *bus, uint max_hz) bus_setup &= ~(DSPI_CTAR_PBR(0x03) | DSPI_CTAR_BR(0x0f)); bus_setup |= (DSPI_CTAR_PBR(best_i) | DSPI_CTAR_BR(best_j)); - writel(bus_setup, &dspi->ctar[bus->seq]); + writel(bus_setup, &dspi->ctar[dev_seq(bus)]); return 0; } @@ -318,7 +318,7 @@ static int coldfire_spi_set_mode(struct udevice *bus, uint mode) if (cfspi->mode & SPI_MODE_MOD) { if ((cfspi->mode & SPI_MODE_XFER_SZ_MASK) == 0) bus_setup |= - readl(&dspi->ctar[bus->seq]) & MCF_FRM_SZ_16BIT; + readl(&dspi->ctar[dev_seq(bus)]) & MCF_FRM_SZ_16BIT; else bus_setup |= ((cfspi->mode & SPI_MODE_XFER_SZ_MASK) >> 1); @@ -329,21 +329,21 @@ static int coldfire_spi_set_mode(struct udevice *bus, uint mode) bus_setup |= (cfspi->mode & SPI_MODE_DLY_SCA_MASK) >> 4; } else { bus_setup |= - (readl(&dspi->ctar[bus->seq]) & MCF_CTAR_MODE_MASK); + (readl(&dspi->ctar[dev_seq(bus)]) & MCF_CTAR_MODE_MASK); } cfspi->charbit = - ((readl(&dspi->ctar[bus->seq]) & MCF_FRM_SZ_16BIT) == + ((readl(&dspi->ctar[dev_seq(bus)]) & MCF_FRM_SZ_16BIT) == MCF_FRM_SZ_16BIT) ? 16 : 8; - setbits_be32(&dspi->ctar[bus->seq], bus_setup); + setbits_be32(&dspi->ctar[dev_seq(bus)], bus_setup); return 0; } static int coldfire_spi_probe(struct udevice *bus) { - struct coldfire_spi_platdata *plat = dev_get_platdata(bus); + struct coldfire_spi_plat *plat = dev_get_plat(bus); struct coldfire_spi_priv *cfspi = dev_get_priv(bus); struct dspi *dspi = cfspi->regs; int i; @@ -384,10 +384,10 @@ static int coldfire_spi_probe(struct udevice *bus) } #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int coldfire_dspi_ofdata_to_platdata(struct udevice *bus) +static int coldfire_dspi_of_to_plat(struct udevice *bus) { fdt_addr_t addr; - struct coldfire_spi_platdata *plat = bus->platdata; + struct coldfire_spi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); int *ctar, len; @@ -451,10 +451,10 @@ U_BOOT_DRIVER(coldfire_spi) = { .id = UCLASS_SPI, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = coldfire_spi_ids, - .ofdata_to_platdata = coldfire_dspi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct coldfire_spi_platdata), + .of_to_plat = coldfire_dspi_of_to_plat, + .plat_auto = sizeof(struct coldfire_spi_plat), #endif .probe = coldfire_spi_probe, .ops = &coldfire_spi_ops, - .priv_auto_alloc_size = sizeof(struct coldfire_spi_priv), + .priv_auto = sizeof(struct coldfire_spi_priv), }; diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index a11433db1e..53a791ea29 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -333,8 +333,8 @@ static int davinci_spi_set_mode(struct udevice *bus, uint mode) static int davinci_spi_claim_bus(struct udevice *dev) { - struct dm_spi_slave_platdata *slave_plat = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = + dev_get_parent_plat(dev); struct udevice *bus = dev->parent; struct davinci_spi_slave *ds = dev_get_priv(bus); @@ -358,8 +358,8 @@ static int davinci_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { - struct dm_spi_slave_platdata *slave = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave = + dev_get_parent_plat(dev); struct udevice *bus = dev->parent; struct davinci_spi_slave *ds = dev_get_priv(bus); @@ -383,7 +383,7 @@ static const struct dm_spi_ops davinci_spi_ops = { static int davinci_spi_probe(struct udevice *bus) { struct davinci_spi_slave *ds = dev_get_priv(bus); - struct davinci_spi_platdata *plat = bus->platdata; + struct davinci_spi_plat *plat = dev_get_plat(bus); ds->regs = plat->regs; ds->num_cs = plat->num_cs; @@ -393,7 +393,7 @@ static int davinci_spi_probe(struct udevice *bus) #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) static int davinci_ofdata_to_platadata(struct udevice *bus) { - struct davinci_spi_platdata *plat = bus->platdata; + struct davinci_spi_plat *plat = dev_get_plat(bus); fdt_addr_t addr; addr = dev_read_addr(bus); @@ -419,10 +419,10 @@ U_BOOT_DRIVER(davinci_spi) = { .id = UCLASS_SPI, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = davinci_spi_ids, - .ofdata_to_platdata = davinci_ofdata_to_platadata, - .platdata_auto_alloc_size = sizeof(struct davinci_spi_platdata), + .of_to_plat = davinci_ofdata_to_platadata, + .plat_auto = sizeof(struct davinci_spi_plat), #endif .probe = davinci_spi_probe, .ops = &davinci_spi_ops, - .priv_auto_alloc_size = sizeof(struct davinci_spi_slave), + .priv_auto = sizeof(struct davinci_spi_slave), }; diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c index ce74ac0abc..742121140d 100644 --- a/drivers/spi/designware_spi.c +++ b/drivers/spi/designware_spi.c @@ -113,7 +113,7 @@ #define RX_TIMEOUT 1000 /* timeout in ms */ -struct dw_spi_platdata { +struct dw_spi_plat { s32 frequency; /* Default clock frequency, -1 for none */ void __iomem *regs; }; @@ -228,9 +228,9 @@ static int request_gpio_cs(struct udevice *bus) return 0; } -static int dw_spi_ofdata_to_platdata(struct udevice *bus) +static int dw_spi_of_to_plat(struct udevice *bus) { - struct dw_spi_platdata *plat = bus->platdata; + struct dw_spi_plat *plat = dev_get_plat(bus); plat->regs = dev_read_addr_ptr(bus); if (!plat->regs) @@ -342,7 +342,7 @@ typedef int (*dw_spi_init_t)(struct udevice *bus, struct dw_spi_priv *priv); static int dw_spi_probe(struct udevice *bus) { dw_spi_init_t init = (dw_spi_init_t)dev_get_driver_data(bus); - struct dw_spi_platdata *plat = dev_get_platdata(bus); + struct dw_spi_plat *plat = dev_get_plat(bus); struct dw_spi_priv *priv = dev_get_priv(bus); int ret; u32 version; @@ -665,7 +665,7 @@ static const struct spi_controller_mem_ops dw_spi_mem_ops = { static int dw_spi_set_speed(struct udevice *bus, uint speed) { - struct dw_spi_platdata *plat = dev_get_platdata(bus); + struct dw_spi_plat *plat = dev_get_plat(bus); struct dw_spi_priv *priv = dev_get_priv(bus); u16 clk_div; @@ -774,9 +774,9 @@ U_BOOT_DRIVER(dw_spi) = { .id = UCLASS_SPI, .of_match = dw_spi_ids, .ops = &dw_spi_ops, - .ofdata_to_platdata = dw_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct dw_spi_platdata), - .priv_auto_alloc_size = sizeof(struct dw_spi_priv), + .of_to_plat = dw_spi_of_to_plat, + .plat_auto = sizeof(struct dw_spi_plat), + .priv_auto = sizeof(struct dw_spi_priv), .probe = dw_spi_probe, .remove = dw_spi_remove, }; diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index d338ff5a0b..30b1a77a73 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR; -struct exynos_spi_platdata { +struct exynos_spi_plat { enum periph_id periph_id; s32 frequency; /* Default clock frequency, -1 for none */ struct exynos_spi *regs; @@ -213,7 +213,7 @@ static int spi_rx_tx(struct exynos_spi_priv *priv, int todo, static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct exynos_spi_platdata *pdata = dev_get_platdata(bus); + struct exynos_spi_plat *pdata = dev_get_plat(bus); struct exynos_spi_priv *priv = dev_get_priv(bus); /* If it's too soon to do another transaction, wait */ @@ -239,7 +239,7 @@ static void spi_cs_activate(struct udevice *dev) static void spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct exynos_spi_platdata *pdata = dev_get_platdata(bus); + struct exynos_spi_plat *pdata = dev_get_plat(bus); struct exynos_spi_priv *priv = dev_get_priv(bus); setbits_le32(&priv->regs->cs_reg, SPI_SLAVE_SIG_INACT); @@ -251,9 +251,9 @@ static void spi_cs_deactivate(struct udevice *dev) debug("Deactivate CS, bus '%s'\n", bus->name); } -static int exynos_spi_ofdata_to_platdata(struct udevice *bus) +static int exynos_spi_of_to_plat(struct udevice *bus) { - struct exynos_spi_platdata *plat = bus->platdata; + struct exynos_spi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -280,7 +280,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus) static int exynos_spi_probe(struct udevice *bus) { - struct exynos_spi_platdata *plat = dev_get_platdata(bus); + struct exynos_spi_plat *plat = dev_get_plat(bus); struct exynos_spi_priv *priv = dev_get_priv(bus); priv->regs = plat->regs; @@ -368,7 +368,7 @@ static int exynos_spi_xfer(struct udevice *dev, unsigned int bitlen, static int exynos_spi_set_speed(struct udevice *bus, uint speed) { - struct exynos_spi_platdata *plat = bus->platdata; + struct exynos_spi_plat *plat = dev_get_plat(bus); struct exynos_spi_priv *priv = dev_get_priv(bus); int ret; @@ -426,8 +426,8 @@ U_BOOT_DRIVER(exynos_spi) = { .id = UCLASS_SPI, .of_match = exynos_spi_ids, .ops = &exynos_spi_ops, - .ofdata_to_platdata = exynos_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct exynos_spi_platdata), - .priv_auto_alloc_size = sizeof(struct exynos_spi_priv), + .of_to_plat = exynos_spi_of_to_plat, + .plat_auto = sizeof(struct exynos_spi_plat), + .priv_auto = sizeof(struct exynos_spi_priv), .probe = exynos_spi_probe, }; diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c index b22c9b3a09..c17a5522bc 100644 --- a/drivers/spi/fsl_dspi.c +++ b/drivers/spi/fsl_dspi.c @@ -31,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR; -/* fsl_dspi_platdata flags */ +/* fsl_dspi_plat flags */ #define DSPI_FLAG_REGMAP_ENDIAN_BIG BIT(0) /* idle data value */ @@ -65,14 +65,14 @@ DECLARE_GLOBAL_DATA_PTR; DSPI_CTAR_DT(15)) /** - * struct fsl_dspi_platdata - platform data for Freescale DSPI + * struct fsl_dspi_plat - platform data for Freescale DSPI * * @flags: Flags for DSPI DSPI_FLAG_... * @speed_hz: Default SCK frequency * @num_chipselect: Number of DSPI chipselect signals * @regs_addr: Base address of DSPI registers */ -struct fsl_dspi_platdata { +struct fsl_dspi_plat { uint flags; uint speed_hz; uint num_chipselect; @@ -448,7 +448,7 @@ static int fsl_dspi_cfg_speed(struct fsl_dspi_priv *priv, uint speed) static int fsl_dspi_child_pre_probe(struct udevice *dev) { - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); struct fsl_dspi_priv *priv = dev_get_priv(dev->parent); u32 cs_sck_delay = 0, sck_cs_delay = 0; unsigned char pcssck = 0, cssck = 0; @@ -460,8 +460,10 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev) return -EINVAL; } - ofnode_read_u32(dev->node, "fsl,spi-cs-sck-delay", &cs_sck_delay); - ofnode_read_u32(dev->node, "fsl,spi-sck-cs-delay", &sck_cs_delay); + ofnode_read_u32(dev_ofnode(dev), "fsl,spi-cs-sck-delay", + &cs_sck_delay); + ofnode_read_u32(dev_ofnode(dev), "fsl,spi-sck-cs-delay", + &sck_cs_delay); /* Set PCS to SCK delay scale values */ ns_delay_scale(&pcssck, &cssck, cs_sck_delay, priv->bus_clk); @@ -481,12 +483,12 @@ static int fsl_dspi_child_pre_probe(struct udevice *dev) static int fsl_dspi_probe(struct udevice *bus) { - struct fsl_dspi_platdata *plat = dev_get_platdata(bus); + struct fsl_dspi_plat *plat = dev_get_plat(bus); struct fsl_dspi_priv *priv = dev_get_priv(bus); struct dm_spi_bus *dm_spi_bus; uint mcr_cfg_val; - dm_spi_bus = bus->uclass_priv; + dm_spi_bus = dev_get_uclass_priv(bus); /* cpu speical pin muxing configure */ cpu_dspi_port_conf(); @@ -511,7 +513,7 @@ static int fsl_dspi_probe(struct udevice *bus) DSPI_MCR_CRXF | DSPI_MCR_CTXF; fsl_dspi_init_mcr(priv, mcr_cfg_val); - debug("%s probe done, bus-num %d.\n", bus->name, bus->seq); + debug("%s probe done, bus-num %d.\n", bus->name, dev_seq(bus)); return 0; } @@ -521,13 +523,13 @@ static int fsl_dspi_claim_bus(struct udevice *dev) uint sr_val; struct fsl_dspi_priv *priv; struct udevice *bus = dev->parent; - struct dm_spi_slave_platdata *slave_plat = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = + dev_get_parent_plat(dev); priv = dev_get_priv(bus); /* processor special preparation work */ - cpu_dspi_claim_bus(bus->seq, slave_plat->cs); + cpu_dspi_claim_bus(dev_seq(bus), slave_plat->cs); /* configure transfer mode */ fsl_dspi_cfg_ctar_mode(priv, slave_plat->cs, priv->mode); @@ -552,14 +554,14 @@ static int fsl_dspi_release_bus(struct udevice *dev) { struct udevice *bus = dev->parent; struct fsl_dspi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = - dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = + dev_get_parent_plat(dev); /* halt module */ dspi_halt(priv, 1); /* processor special release work */ - cpu_dspi_release_bus(bus->seq, slave_plat->cs); + cpu_dspi_release_bus(dev_seq(bus), slave_plat->cs); return 0; } @@ -569,14 +571,14 @@ static int fsl_dspi_release_bus(struct udevice *dev) */ static int fsl_dspi_bind(struct udevice *bus) { - debug("%s assigned req_seq %d.\n", bus->name, bus->req_seq); + debug("%s assigned seq %d.\n", bus->name, dev_seq(bus)); return 0; } -static int fsl_dspi_ofdata_to_platdata(struct udevice *bus) +static int fsl_dspi_of_to_plat(struct udevice *bus) { fdt_addr_t addr; - struct fsl_dspi_platdata *plat = bus->platdata; + struct fsl_dspi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -608,7 +610,7 @@ static int fsl_dspi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct fsl_dspi_priv *priv; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); struct udevice *bus; bus = dev->parent; @@ -659,9 +661,9 @@ U_BOOT_DRIVER(fsl_dspi) = { .id = UCLASS_SPI, .of_match = fsl_dspi_ids, .ops = &fsl_dspi_ops, - .ofdata_to_platdata = fsl_dspi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct fsl_dspi_platdata), - .priv_auto_alloc_size = sizeof(struct fsl_dspi_priv), + .of_to_plat = fsl_dspi_of_to_plat, + .plat_auto = sizeof(struct fsl_dspi_plat), + .priv_auto = sizeof(struct fsl_dspi_priv), .probe = fsl_dspi_probe, .child_pre_probe = fsl_dspi_child_pre_probe, .bind = fsl_dspi_bind, diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index 5c76fd962e..abc28e37d2 100644 --- a/drivers/spi/fsl_espi.c +++ b/drivers/spi/fsl_espi.c @@ -508,7 +508,7 @@ static int fsl_espi_set_mode(struct udevice *bus, uint mode) static int fsl_espi_child_pre_probe(struct udevice *dev) { - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); struct udevice *bus = dev->parent; struct fsl_spi_slave *fsl = dev_get_priv(bus); @@ -520,14 +520,14 @@ static int fsl_espi_child_pre_probe(struct udevice *dev) static int fsl_espi_probe(struct udevice *bus) { - struct fsl_espi_platdata *plat = dev_get_platdata(bus); + struct fsl_espi_plat *plat = dev_get_plat(bus); struct fsl_spi_slave *fsl = dev_get_priv(bus); fsl->espi = (ccsr_espi_t *)((u32)plat->regs_addr); fsl->max_transfer_length = ESPI_MAX_DATA_TRANSFER_LEN; fsl->speed_hz = plat->speed_hz; - debug("%s probe done, bus-num %d.\n", bus->name, bus->seq); + debug("%s probe done, bus-num %d.\n", bus->name, dev_seq(bus)); return 0; } @@ -541,10 +541,10 @@ static const struct dm_spi_ops fsl_espi_ops = { }; #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int fsl_espi_ofdata_to_platdata(struct udevice *bus) +static int fsl_espi_of_to_plat(struct udevice *bus) { fdt_addr_t addr; - struct fsl_espi_platdata *plat = bus->platdata; + struct fsl_espi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -573,11 +573,11 @@ U_BOOT_DRIVER(fsl_espi) = { .id = UCLASS_SPI, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = fsl_espi_ids, - .ofdata_to_platdata = fsl_espi_ofdata_to_platdata, + .of_to_plat = fsl_espi_of_to_plat, #endif .ops = &fsl_espi_ops, - .platdata_auto_alloc_size = sizeof(struct fsl_espi_platdata), - .priv_auto_alloc_size = sizeof(struct fsl_spi_slave), + .plat_auto = sizeof(struct fsl_espi_plat), + .priv_auto = sizeof(struct fsl_spi_slave), .probe = fsl_espi_probe, .child_pre_probe = fsl_espi_child_pre_probe, }; diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index 128f95877f..8bc7038a82 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -515,8 +515,8 @@ static void fsl_qspi_invalidate(struct fsl_qspi *q) static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_slave *slave) { - struct dm_spi_slave_platdata *plat = - dev_get_parent_platdata(slave->dev); + struct dm_spi_slave_plat *plat = + dev_get_parent_plat(slave->dev); if (q->selected == plat->cs) return; @@ -795,7 +795,7 @@ static const struct spi_controller_mem_ops fsl_qspi_mem_ops = { static int fsl_qspi_probe(struct udevice *bus) { - struct dm_spi_bus *dm_bus = bus->uclass_priv; + struct dm_spi_bus *dm_bus = dev_get_uclass_priv(bus); struct fsl_qspi *q = dev_get_priv(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -887,6 +887,6 @@ U_BOOT_DRIVER(fsl_qspi) = { .id = UCLASS_SPI, .of_match = fsl_qspi_ids, .ops = &fsl_qspi_ops, - .priv_auto_alloc_size = sizeof(struct fsl_qspi), + .priv_auto = sizeof(struct fsl_qspi), .probe = fsl_qspi_probe, }; diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index a91cb78568..1cd410493b 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -38,17 +38,6 @@ #define debug_trace(x, args...) #endif -struct ich_spi_platdata { -#if CONFIG_IS_ENABLED(OF_PLATDATA) - struct dtd_intel_fast_spi dtplat; -#endif - enum ich_version ich_version; /* Controller version, 7 or 9 */ - bool lockdown; /* lock down controller settings? */ - ulong mmio_base; /* Base of MMIO registers */ - pci_dev_t bdf; /* PCI address used by of-platdata */ - bool hwseq; /* Use hardware sequencing (not s/w) */ -}; - static u8 ich_readb(struct ich_spi_priv *priv, int reg) { u8 value = readb(priv->base + reg); @@ -139,7 +128,7 @@ static bool ich9_can_do_33mhz(struct udevice *dev) return speed == 1; } -static void spi_lock_down(struct ich_spi_platdata *plat, void *sbase) +static void spi_lock_down(struct ich_spi_plat *plat, void *sbase) { if (plat->ich_version == ICHV_7) { struct ich7_spi_regs *ich7_spi = sbase; @@ -152,7 +141,7 @@ static void spi_lock_down(struct ich_spi_platdata *plat, void *sbase) } } -static bool spi_lock_status(struct ich_spi_platdata *plat, void *sbase) +static bool spi_lock_status(struct ich_spi_plat *plat, void *sbase) { int lock = 0; @@ -264,7 +253,7 @@ static int ich_spi_exec_op_swseq(struct spi_slave *slave, const struct spi_mem_op *op) { struct udevice *bus = dev_get_parent(slave->dev); - struct ich_spi_platdata *plat = dev_get_platdata(bus); + struct ich_spi_plat *plat = dev_get_plat(bus); struct ich_spi_priv *ctlr = dev_get_priv(bus); uint16_t control; int16_t opcode_index; @@ -602,7 +591,7 @@ static int ich_spi_exec_op_hwseq(struct spi_slave *slave, static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) { struct udevice *bus = dev_get_parent(slave->dev); - struct ich_spi_platdata *plat = dev_get_platdata(bus); + struct ich_spi_plat *plat = dev_get_plat(bus); int ret; bootstage_start(BOOTSTAGE_ID_ACCUM_SPI, "fast_spi"); @@ -667,7 +656,7 @@ static int ich_spi_get_basics(struct udevice *bus, bool can_probe, * 1. Using of-platdata, in which case we have the BDF and can access the * registers by reading the BAR * 2. Not using of-platdata, but still with a SPI controller that is on its own - * PCI PDF. In this case we read the BDF from the parent platdata and again get + * PCI PDF. In this case we read the BDF from the parent plat and again get * the registers by reading the BAR * 3. Using a SPI controller that is a child of the PCH, in which case we try * to find the registers by asking the PCH. This only works if the PCH has @@ -685,9 +674,9 @@ static int ich_get_mmap_bus(struct udevice *bus, ulong *map_basep, pci_dev_t spi_bdf; #if !CONFIG_IS_ENABLED(OF_PLATDATA) if (device_is_on_pci_bus(bus)) { - struct pci_child_platdata *pplat; + struct pci_child_plat *pplat; - pplat = dev_get_parent_platdata(bus); + pplat = dev_get_parent_plat(bus); spi_bdf = pplat->devfn; } else { enum ich_version ich_version; @@ -706,7 +695,7 @@ static int ich_get_mmap_bus(struct udevice *bus, ulong *map_basep, offsetp); } #else - struct ich_spi_platdata *plat = dev_get_platdata(bus); + struct ich_spi_plat *plat = dev_get_plat(bus); /* * We cannot rely on plat->bdf being set up yet since this method can @@ -758,7 +747,7 @@ static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op) static int ich_protect_lockdown(struct udevice *dev) { - struct ich_spi_platdata *plat = dev_get_platdata(dev); + struct ich_spi_plat *plat = dev_get_plat(dev); struct ich_spi_priv *priv = dev_get_priv(dev); int ret = -ENOSYS; @@ -788,11 +777,11 @@ static int ich_protect_lockdown(struct udevice *dev) } static int ich_init_controller(struct udevice *dev, - struct ich_spi_platdata *plat, + struct ich_spi_plat *plat, struct ich_spi_priv *ctlr) { if (spl_phase() == PHASE_TPL) { - struct ich_spi_platdata *plat = dev_get_platdata(dev); + struct ich_spi_plat *plat = dev_get_plat(dev); int ret; ret = fast_spi_early_init(plat->bdf, plat->mmio_base); @@ -871,7 +860,7 @@ static int ich_cache_bios_region(struct udevice *dev) static int ich_spi_probe(struct udevice *dev) { - struct ich_spi_platdata *plat = dev_get_platdata(dev); + struct ich_spi_plat *plat = dev_get_plat(dev); struct ich_spi_priv *priv = dev_get_priv(dev); int ret; @@ -924,7 +913,7 @@ static int ich_spi_set_mode(struct udevice *bus, uint mode) static int ich_spi_child_pre_probe(struct udevice *dev) { struct udevice *bus = dev_get_parent(dev); - struct ich_spi_platdata *plat = dev_get_platdata(bus); + struct ich_spi_plat *plat = dev_get_plat(bus); struct ich_spi_priv *priv = dev_get_priv(bus); struct spi_slave *slave = dev_get_parent_priv(dev); @@ -945,9 +934,9 @@ static int ich_spi_child_pre_probe(struct udevice *dev) return 0; } -static int ich_spi_ofdata_to_platdata(struct udevice *dev) +static int ich_spi_of_to_plat(struct udevice *dev) { - struct ich_spi_platdata *plat = dev_get_platdata(dev); + struct ich_spi_plat *plat = dev_get_plat(dev); #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct ich_spi_priv *priv = dev_get_priv(dev); @@ -1004,9 +993,9 @@ U_BOOT_DRIVER(intel_fast_spi) = { .id = UCLASS_SPI, .of_match = ich_spi_ids, .ops = &ich_spi_ops, - .ofdata_to_platdata = ich_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct ich_spi_platdata), - .priv_auto_alloc_size = sizeof(struct ich_spi_priv), + .of_to_plat = ich_spi_of_to_plat, + .plat_auto = sizeof(struct ich_spi_plat), + .priv_auto = sizeof(struct ich_spi_priv), .child_pre_probe = ich_spi_child_pre_probe, .probe = ich_spi_probe, .remove = ich_spi_remove, diff --git a/drivers/spi/ich.h b/drivers/spi/ich.h index 23c7827740..8fd150d44a 100644 --- a/drivers/spi/ich.h +++ b/drivers/spi/ich.h @@ -230,4 +230,15 @@ struct ich_spi_priv { struct udevice *pch; /* PCH, used to control SPI access */ }; +struct ich_spi_plat { +#if CONFIG_IS_ENABLED(OF_PLATDATA) + struct dtd_intel_fast_spi dtplat; +#endif + enum ich_version ich_version; /* Controller version, 7 or 9 */ + bool lockdown; /* lock down controller settings? */ + ulong mmio_base; /* Base of MMIO registers */ + pci_dev_t bdf; /* PCI address used by of-platdata */ + bool hwseq; /* Use hardware sequencing (not s/w) */ +}; + #endif /* _ICH_H_ */ diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index dc7d2bc1f0..43812da0eb 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -23,7 +23,7 @@ struct mvebu_spi_dev { bool is_errata_50mhz_ac; }; -struct mvebu_spi_platdata { +struct mvebu_spi_plat { struct kwspi_registers *spireg; bool is_errata_50mhz_ac; }; @@ -109,7 +109,7 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen, static int mvebu_spi_set_speed(struct udevice *bus, uint hz) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct kwspi_registers *reg = plat->spireg; u32 data; @@ -127,7 +127,7 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz) static void mvebu_spi_50mhz_ac_timing_erratum(struct udevice *bus, uint mode) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct kwspi_registers *reg = plat->spireg; u32 data; @@ -160,7 +160,7 @@ static void mvebu_spi_50mhz_ac_timing_erratum(struct udevice *bus, uint mode) static int mvebu_spi_set_mode(struct udevice *bus, uint mode) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct kwspi_registers *reg = plat->spireg; u32 data = readl(®->cfg); @@ -185,7 +185,7 @@ static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev->parent; - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); return _spi_xfer(plat->spireg, bitlen, dout, din, flags); } @@ -198,7 +198,7 @@ __attribute__((weak)) int mvebu_board_spi_claim_bus(struct udevice *dev) static int mvebu_spi_claim_bus(struct udevice *dev) { struct udevice *bus = dev->parent; - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); /* Configure the chip-select in the CTRL register */ clrsetbits_le32(&plat->spireg->ctrl, @@ -220,7 +220,7 @@ static int mvebu_spi_release_bus(struct udevice *dev) static int mvebu_spi_probe(struct udevice *bus) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct kwspi_registers *reg = plat->spireg; writel(KWSPI_SMEMRDY, ®->ctrl); @@ -230,9 +230,9 @@ static int mvebu_spi_probe(struct udevice *bus) return 0; } -static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) +static int mvebu_spi_of_to_plat(struct udevice *bus) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); const struct mvebu_spi_dev *drvdata = (struct mvebu_spi_dev *)dev_get_driver_data(bus); @@ -295,8 +295,8 @@ U_BOOT_DRIVER(mvebu_spi) = { .id = UCLASS_SPI, .of_match = mvebu_spi_ids, .ops = &mvebu_spi_ops, - .ofdata_to_platdata = mvebu_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mvebu_spi_platdata), - .priv_auto_alloc_size = sizeof(struct mvebu_spi_priv), + .of_to_plat = mvebu_spi_of_to_plat, + .plat_auto = sizeof(struct mvebu_spi_plat), + .priv_auto = sizeof(struct mvebu_spi_priv), .probe = mvebu_spi_probe, }; diff --git a/drivers/spi/meson_spifc.c b/drivers/spi/meson_spifc.c index 2cdc018682..d99a151406 100644 --- a/drivers/spi/meson_spifc.c +++ b/drivers/spi/meson_spifc.c @@ -318,5 +318,5 @@ U_BOOT_DRIVER(meson_spifc) = { .of_match = meson_spifc_ids, .ops = &meson_spifc_ops, .probe = meson_spifc_probe, - .priv_auto_alloc_size = sizeof(struct meson_spifc_priv), + .priv_auto = sizeof(struct meson_spifc_priv), }; diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index ec39c12b3d..6869d60d97 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -48,7 +48,7 @@ struct mpc8xxx_priv { #define SPI_TIMEOUT 1000 -static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) +static int mpc8xxx_spi_of_to_plat(struct udevice *dev) { struct mpc8xxx_priv *priv = dev_get_priv(dev); struct clk clk; @@ -107,17 +107,17 @@ static int mpc8xxx_spi_probe(struct udevice *dev) static void mpc8xxx_spi_cs_activate(struct udevice *dev) { struct mpc8xxx_priv *priv = dev_get_priv(dev->parent); - struct dm_spi_slave_platdata *platdata = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); - dm_gpio_set_value(&priv->gpios[platdata->cs], 1); + dm_gpio_set_value(&priv->gpios[plat->cs], 1); } static void mpc8xxx_spi_cs_deactivate(struct udevice *dev) { struct mpc8xxx_priv *priv = dev_get_priv(dev->parent); - struct dm_spi_slave_platdata *platdata = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); - dm_gpio_set_value(&priv->gpios[platdata->cs], 0); + dm_gpio_set_value(&priv->gpios[plat->cs], 0); } static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, @@ -126,16 +126,16 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, struct udevice *bus = dev->parent; struct mpc8xxx_priv *priv = dev_get_priv(bus); spi8xxx_t *spi = priv->spi; - struct dm_spi_slave_platdata *platdata = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); u32 tmpdin = 0, tmpdout = 0, n; const u8 *cout = dout; u8 *cin = din; debug("%s: slave %s:%u dout %08X din %08X bitlen %u\n", __func__, - bus->name, platdata->cs, (uint)dout, (uint)din, bitlen); - if (platdata->cs >= priv->cs_count) { + bus->name, plat->cs, (uint)dout, (uint)din, bitlen); + if (plat->cs >= priv->cs_count) { dev_err(dev, "chip select index %d too large (cs_count=%d)\n", - platdata->cs, priv->cs_count); + plat->cs, priv->cs_count); return -EINVAL; } if (bitlen % 8) { @@ -279,7 +279,7 @@ U_BOOT_DRIVER(mpc8xxx_spi) = { .id = UCLASS_SPI, .of_match = mpc8xxx_spi_ids, .ops = &mpc8xxx_spi_ops, - .ofdata_to_platdata = mpc8xxx_spi_ofdata_to_platdata, + .of_to_plat = mpc8xxx_spi_of_to_plat, .probe = mpc8xxx_spi_probe, - .priv_auto_alloc_size = sizeof(struct mpc8xxx_priv), + .priv_auto = sizeof(struct mpc8xxx_priv), }; diff --git a/drivers/spi/mscc_bb_spi.c b/drivers/spi/mscc_bb_spi.c index e77447b655..2a01ea061f 100644 --- a/drivers/spi/mscc_bb_spi.c +++ b/drivers/spi/mscc_bb_spi.c @@ -117,7 +117,7 @@ int mscc_bb_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev_get_parent(dev); - struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); struct mscc_bb_priv *priv = dev_get_priv(bus); u32 i, count; const u8 *txd = dout; @@ -232,6 +232,6 @@ U_BOOT_DRIVER(mscc_bb) = { .id = UCLASS_SPI, .of_match = mscc_bb_ids, .ops = &mscc_bb_ops, - .priv_auto_alloc_size = sizeof(struct mscc_bb_priv), + .priv_auto = sizeof(struct mscc_bb_priv), .probe = mscc_bb_spi_probe, }; diff --git a/drivers/spi/mt7621_spi.c b/drivers/spi/mt7621_spi.c index 3a0738eb2b..eb0931747b 100644 --- a/drivers/spi/mt7621_spi.c +++ b/drivers/spi/mt7621_spi.c @@ -304,6 +304,6 @@ U_BOOT_DRIVER(mt7621_spi) = { .id = UCLASS_SPI, .of_match = mt7621_spi_ids, .ops = &mt7621_spi_ops, - .priv_auto_alloc_size = sizeof(struct mt7621_spi), + .priv_auto = sizeof(struct mt7621_spi), .probe = mt7621_spi_probe, }; diff --git a/drivers/spi/mtk_snfi_spi.c b/drivers/spi/mtk_snfi_spi.c index c30c8f4ff6..b6ab5fa3ad 100644 --- a/drivers/spi/mtk_snfi_spi.c +++ b/drivers/spi/mtk_snfi_spi.c @@ -313,6 +313,6 @@ U_BOOT_DRIVER(mtk_snfi_spi) = { .id = UCLASS_SPI, .of_match = mtk_snfi_spi_ids, .ops = &mtk_snfi_spi_ops, - .priv_auto_alloc_size = sizeof(struct mtk_snfi_priv), + .priv_auto = sizeof(struct mtk_snfi_priv), .probe = mtk_snfi_spi_probe, }; diff --git a/drivers/spi/mvebu_a3700_spi.c b/drivers/spi/mvebu_a3700_spi.c index eb13cf349e..c40d7d17be 100644 --- a/drivers/spi/mvebu_a3700_spi.c +++ b/drivers/spi/mvebu_a3700_spi.c @@ -38,13 +38,13 @@ struct spi_reg { u32 din; /* 0x1060c */ }; -struct mvebu_spi_platdata { +struct mvebu_spi_plat { struct spi_reg *spireg; struct clk clk; struct gpio_desc cs_gpios[MAX_CS_COUNT]; }; -static void spi_cs_activate(struct mvebu_spi_platdata *plat, int cs) +static void spi_cs_activate(struct mvebu_spi_plat *plat, int cs) { if (CONFIG_IS_ENABLED(DM_GPIO) && dm_gpio_is_valid(&plat->cs_gpios[cs])) dm_gpio_set_value(&plat->cs_gpios[cs], 1); @@ -52,7 +52,7 @@ static void spi_cs_activate(struct mvebu_spi_platdata *plat, int cs) setbits_le32(&plat->spireg->ctrl, MVEBU_SPI_A3700_SPI_EN_0 << cs); } -static void spi_cs_deactivate(struct mvebu_spi_platdata *plat, int cs) +static void spi_cs_deactivate(struct mvebu_spi_plat *plat, int cs) { if (CONFIG_IS_ENABLED(DM_GPIO) && dm_gpio_is_valid(&plat->cs_gpios[cs])) dm_gpio_set_value(&plat->cs_gpios[cs], 0); @@ -146,7 +146,7 @@ static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev->parent; - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct spi_reg *reg = plat->spireg; unsigned int bytelen; int ret; @@ -186,7 +186,7 @@ static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen, static int mvebu_spi_set_speed(struct udevice *bus, uint hz) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct spi_reg *reg = plat->spireg; u32 data, prescale; @@ -207,7 +207,7 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz) static int mvebu_spi_set_mode(struct udevice *bus, uint mode) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct spi_reg *reg = plat->spireg; /* @@ -229,7 +229,7 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode) static int mvebu_spi_probe(struct udevice *bus) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); struct spi_reg *reg = plat->spireg; u32 data; int ret; @@ -279,9 +279,9 @@ static int mvebu_spi_probe(struct udevice *bus) return 0; } -static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) +static int mvebu_spi_of_to_plat(struct udevice *bus) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); int ret; plat->spireg = dev_read_addr_ptr(bus); @@ -297,7 +297,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) static int mvebu_spi_remove(struct udevice *bus) { - struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + struct mvebu_spi_plat *plat = dev_get_plat(bus); clk_free(&plat->clk); @@ -324,8 +324,8 @@ U_BOOT_DRIVER(mvebu_spi) = { .id = UCLASS_SPI, .of_match = mvebu_spi_ids, .ops = &mvebu_spi_ops, - .ofdata_to_platdata = mvebu_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct mvebu_spi_platdata), + .of_to_plat = mvebu_spi_of_to_plat, + .plat_auto = sizeof(struct mvebu_spi_plat), .probe = mvebu_spi_probe, .remove = mvebu_spi_remove, }; diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index e90a06a66d..c5ffad80fb 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -69,7 +69,7 @@ static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs) { #if CONFIG_IS_ENABLED(DM_SPI) struct udevice *dev = mxcs->dev; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); u32 cs = slave_plat->cs; @@ -87,7 +87,7 @@ static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs) { #if CONFIG_IS_ENABLED(DM_SPI) struct udevice *dev = mxcs->dev; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); u32 cs = slave_plat->cs; @@ -512,7 +512,7 @@ void spi_release_bus(struct spi_slave *slave) static int mxc_spi_probe(struct udevice *bus) { - struct mxc_spi_slave *mxcs = dev_get_platdata(bus); + struct mxc_spi_slave *mxcs = dev_get_plat(bus); int node = dev_of_offset(bus); const void *blob = gd->fdt_blob; int ret; @@ -550,7 +550,7 @@ static int mxc_spi_probe(struct udevice *bus) static int mxc_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { - struct mxc_spi_slave *mxcs = dev_get_platdata(dev->parent); + struct mxc_spi_slave *mxcs = dev_get_plat(dev->parent); return mxc_spi_xfer_internal(mxcs, bitlen, dout, din, flags); @@ -558,8 +558,8 @@ static int mxc_spi_xfer(struct udevice *dev, unsigned int bitlen, static int mxc_spi_claim_bus(struct udevice *dev) { - struct mxc_spi_slave *mxcs = dev_get_platdata(dev->parent); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct mxc_spi_slave *mxcs = dev_get_plat(dev->parent); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); mxcs->dev = dev; @@ -579,7 +579,7 @@ static int mxc_spi_set_speed(struct udevice *bus, uint speed) static int mxc_spi_set_mode(struct udevice *bus, uint mode) { - struct mxc_spi_slave *mxcs = dev_get_platdata(bus); + struct mxc_spi_slave *mxcs = dev_get_plat(bus); mxcs->mode = mode; mxcs->ss_pol = (mode & SPI_CS_HIGH) ? 1 : 0; @@ -605,7 +605,7 @@ U_BOOT_DRIVER(mxc_spi) = { .id = UCLASS_SPI, .of_match = mxc_spi_ids, .ops = &mxc_spi_ops, - .platdata_auto_alloc_size = sizeof(struct mxc_spi_slave), + .plat_auto = sizeof(struct mxc_spi_slave), .probe = mxc_spi_probe, }; #endif diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c index fb0af02be0..d41352a0bb 100644 --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -41,7 +41,7 @@ #define MXS_SSP_IMX23_CLKID_SSP0 33 #define MXS_SSP_IMX28_CLKID_SSP0 46 -struct mxs_spi_platdata { +struct mxs_spi_plat { #if CONFIG_IS_ENABLED(OF_PLATDATA) struct dtd_fsl_imx23_spi dtplat; #endif @@ -311,7 +311,7 @@ int mxs_spi_xfer(struct udevice *dev, unsigned int bitlen, static int mxs_spi_probe(struct udevice *bus) { - struct mxs_spi_platdata *plat = dev_get_platdata(bus); + struct mxs_spi_plat *plat = dev_get_plat(bus); struct mxs_spi_priv *priv = dev_get_priv(bus); int ret; @@ -441,9 +441,9 @@ static const struct dm_spi_ops mxs_spi_ops = { }; #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -static int mxs_ofdata_to_platdata(struct udevice *bus) +static int mxs_of_to_plat(struct udevice *bus) { - struct mxs_spi_platdata *plat = bus->platdata; + struct mxs_spi_plat *plat = dev_get_plat(bus); u32 prop[2]; int ret; @@ -485,12 +485,12 @@ U_BOOT_DRIVER(fsl_imx23_spi) = { .id = UCLASS_SPI, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = mxs_spi_ids, - .ofdata_to_platdata = mxs_ofdata_to_platdata, + .of_to_plat = mxs_of_to_plat, #endif - .platdata_auto_alloc_size = sizeof(struct mxs_spi_platdata), + .plat_auto = sizeof(struct mxs_spi_plat), .ops = &mxs_spi_ops, - .priv_auto_alloc_size = sizeof(struct mxs_spi_priv), + .priv_auto = sizeof(struct mxs_spi_priv), .probe = mxs_spi_probe, }; -U_BOOT_DRIVER_ALIAS(fsl_imx23_spi, fsl_imx28_spi) +DM_DRIVER_ALIAS(fsl_imx23_spi, fsl_imx28_spi) diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c index 9661e9e10d..006dd04b9e 100644 --- a/drivers/spi/nxp_fspi.c +++ b/drivers/spi/nxp_fspi.c @@ -887,7 +887,7 @@ static int nxp_fspi_claim_bus(struct udevice *dev) { struct nxp_fspi *f; struct udevice *bus; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); bus = dev->parent; f = dev_get_priv(bus); @@ -922,7 +922,7 @@ static int nxp_fspi_set_mode(struct udevice *bus, uint mode) return 0; } -static int nxp_fspi_ofdata_to_platdata(struct udevice *bus) +static int nxp_fspi_of_to_plat(struct udevice *bus) { struct nxp_fspi *f = dev_get_priv(bus); #if CONFIG_IS_ENABLED(CLK) @@ -993,7 +993,7 @@ U_BOOT_DRIVER(nxp_fspi) = { .id = UCLASS_SPI, .of_match = nxp_fspi_ids, .ops = &nxp_fspi_ops, - .ofdata_to_platdata = nxp_fspi_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct nxp_fspi), + .of_to_plat = nxp_fspi_of_to_plat, + .priv_auto = sizeof(struct nxp_fspi), .probe = nxp_fspi_probe, }; diff --git a/drivers/spi/octeon_spi.c b/drivers/spi/octeon_spi.c index 7e88e5580f..6ac66d2f9a 100644 --- a/drivers/spi/octeon_spi.c +++ b/drivers/spi/octeon_spi.c @@ -81,7 +81,7 @@ struct octeon_spi { static u64 octeon_spi_set_mpicfg(struct udevice *dev) { - struct dm_spi_slave_platdata *slave = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave = dev_get_parent_plat(dev); struct udevice *bus = dev_get_parent(dev); struct octeon_spi *priv = dev_get_priv(bus); u64 mpi_cfg; @@ -593,7 +593,7 @@ static int octeon_spi_probe(struct udevice *dev) if (ret) return ret; - debug("SPI bus %s %d at %p\n", dev->name, dev->seq, priv->base); + debug("SPI bus %s %d at %p\n", dev->name, dev_seq(dev), priv->base); return 0; } @@ -611,6 +611,6 @@ U_BOOT_DRIVER(octeon_spi) = { .id = UCLASS_SPI, .of_match = octeon_spi_ids, .probe = octeon_spi_probe, - .priv_auto_alloc_size = sizeof(struct octeon_spi), + .priv_auto = sizeof(struct octeon_spi), .ops = &octeon_spi_ops, }; diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index 56cb217486..74931768c0 100644 --- a/drivers/spi/omap3_spi.c +++ b/drivers/spi/omap3_spi.c @@ -37,6 +37,8 @@ struct omap3_spi_priv { unsigned int mode; unsigned int wordlen; unsigned int pin_dir:1; + + bool bus_claimed; }; static void omap3_spi_write_chconf(struct omap3_spi_priv *priv, int val) @@ -372,18 +374,23 @@ static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv) conf |= OMAP3_MCSPI_MODULCTRL_SINGLE; writel(conf, &priv->regs->modulctrl); + + priv->bus_claimed = true; } static int omap3_spi_claim_bus(struct udevice *dev) { struct udevice *bus = dev->parent; struct omap3_spi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); priv->cs = slave_plat->cs; - priv->freq = slave_plat->max_hz; + if (!priv->freq) + priv->freq = slave_plat->max_hz; _omap3_spi_claim_bus(priv); + _omap3_spi_set_speed(priv); + _omap3_spi_set_mode(priv); return 0; } @@ -395,6 +402,8 @@ static int omap3_spi_release_bus(struct udevice *dev) writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl); + priv->bus_claimed = false; + return 0; } @@ -402,7 +411,7 @@ static int omap3_spi_set_wordlen(struct udevice *dev, unsigned int wordlen) { struct udevice *bus = dev->parent; struct omap3_spi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); priv->cs = slave_plat->cs; priv->wordlen = wordlen; @@ -414,7 +423,7 @@ static int omap3_spi_set_wordlen(struct udevice *dev, unsigned int wordlen) static int omap3_spi_probe(struct udevice *dev) { struct omap3_spi_priv *priv = dev_get_priv(dev); - struct omap3_spi_plat *plat = dev_get_platdata(dev); + struct omap3_spi_plat *plat = dev_get_plat(dev); priv->regs = plat->regs; priv->pin_dir = plat->pin_dir; @@ -440,7 +449,8 @@ static int omap3_spi_set_speed(struct udevice *dev, unsigned int speed) struct omap3_spi_priv *priv = dev_get_priv(dev); priv->freq = speed; - _omap3_spi_set_speed(priv); + if (priv->bus_claimed) + _omap3_spi_set_speed(priv); return 0; } @@ -451,7 +461,8 @@ static int omap3_spi_set_mode(struct udevice *dev, uint mode) priv->mode = mode; - _omap3_spi_set_mode(priv); + if (priv->bus_claimed) + _omap3_spi_set_mode(priv); return 0; } @@ -478,11 +489,11 @@ static struct omap2_mcspi_platform_config omap4_pdata = { .regs_offset = OMAP4_MCSPI_REG_OFFSET, }; -static int omap3_spi_ofdata_to_platdata(struct udevice *dev) +static int omap3_spi_of_to_plat(struct udevice *dev) { struct omap2_mcspi_platform_config *data = (struct omap2_mcspi_platform_config *)dev_get_driver_data(dev); - struct omap3_spi_plat *plat = dev_get_platdata(dev); + struct omap3_spi_plat *plat = dev_get_plat(dev); plat->regs = (struct mcspi *)(dev_read_addr(dev) + data->regs_offset); @@ -506,10 +517,10 @@ U_BOOT_DRIVER(omap3_spi) = { .flags = DM_FLAG_PRE_RELOC, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = omap3_spi_ids, - .ofdata_to_platdata = omap3_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct omap3_spi_plat), + .of_to_plat = omap3_spi_of_to_plat, + .plat_auto = sizeof(struct omap3_spi_plat), #endif .probe = omap3_spi_probe, .ops = &omap3_spi_ops, - .priv_auto_alloc_size = sizeof(struct omap3_spi_priv), + .priv_auto = sizeof(struct omap3_spi_priv), }; diff --git a/drivers/spi/pic32_spi.c b/drivers/spi/pic32_spi.c index 52e9eff743..34d7d3e2ac 100644 --- a/drivers/spi/pic32_spi.c +++ b/drivers/spi/pic32_spi.c @@ -236,7 +236,7 @@ static int pic32_spi_xfer(struct udevice *slave, unsigned int bitlen, const void *tx_buf, void *rx_buf, unsigned long flags) { - struct dm_spi_slave_platdata *slave_plat; + struct dm_spi_slave_plat *slave_plat; struct udevice *bus = slave->parent; struct pic32_spi_priv *priv; int len = bitlen / 8; @@ -244,10 +244,10 @@ static int pic32_spi_xfer(struct udevice *slave, unsigned int bitlen, ulong tbase; priv = dev_get_priv(bus); - slave_plat = dev_get_parent_platdata(slave); + slave_plat = dev_get_parent_plat(slave); debug("spi_xfer: bus:%i cs:%i flags:%lx\n", - bus->seq, slave_plat->cs, flags); + dev_seq(bus), slave_plat->cs, flags); debug("msg tx %p, rx %p submitted of %d byte(s)\n", tx_buf, rx_buf, len); @@ -384,7 +384,7 @@ static int pic32_spi_probe(struct udevice *bus) fdt_size_t size; int ret; - debug("%s: %d, bus: %i\n", __func__, __LINE__, bus->seq); + debug("%s: %d, bus: %i\n", __func__, __LINE__, dev_seq(bus)); addr = fdtdec_get_addr_size(gd->fdt_blob, node, "reg", &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; @@ -444,6 +444,6 @@ U_BOOT_DRIVER(pic32_spi) = { .id = UCLASS_SPI, .of_match = pic32_spi_ids, .ops = &pic32_spi_ops, - .priv_auto_alloc_size = sizeof(struct pic32_spi_priv), + .priv_auto = sizeof(struct pic32_spi_priv), .probe = pic32_spi_probe, }; diff --git a/drivers/spi/pl022_spi.c b/drivers/spi/pl022_spi.c index 32bb8c8d21..133363ea7d 100644 --- a/drivers/spi/pl022_spi.c +++ b/drivers/spi/pl022_spi.c @@ -89,7 +89,7 @@ static int pl022_is_supported(struct pl022_spi_slave *ps) static int pl022_spi_probe(struct udevice *bus) { - struct pl022_spi_pdata *plat = dev_get_platdata(bus); + struct pl022_spi_pdata *plat = dev_get_plat(bus); struct pl022_spi_slave *ps = dev_get_priv(bus); ps->base = ioremap(plat->addr, plat->size); @@ -286,9 +286,9 @@ static const struct dm_spi_ops pl022_spi_ops = { }; #if !CONFIG_IS_ENABLED(OF_PLATDATA) -static int pl022_spi_ofdata_to_platdata(struct udevice *bus) +static int pl022_spi_of_to_plat(struct udevice *bus) { - struct pl022_spi_pdata *plat = bus->platdata; + struct pl022_spi_pdata *plat = dev_get_plat(bus); const void *fdt = gd->fdt_blob; int node = dev_of_offset(bus); struct clk clkdev; @@ -316,10 +316,10 @@ U_BOOT_DRIVER(pl022_spi) = { .id = UCLASS_SPI, #if !CONFIG_IS_ENABLED(OF_PLATDATA) .of_match = pl022_spi_ids, - .ofdata_to_platdata = pl022_spi_ofdata_to_platdata, + .of_to_plat = pl022_spi_of_to_plat, #endif .ops = &pl022_spi_ops, - .platdata_auto_alloc_size = sizeof(struct pl022_spi_pdata), - .priv_auto_alloc_size = sizeof(struct pl022_spi_slave), + .plat_auto = sizeof(struct pl022_spi_pdata), + .priv_auto = sizeof(struct pl022_spi_slave), .probe = pl022_spi_probe, }; diff --git a/drivers/spi/renesas_rpc_spi.c b/drivers/spi/renesas_rpc_spi.c index d0ff918af8..105765168e 100644 --- a/drivers/spi/renesas_rpc_spi.c +++ b/drivers/spi/renesas_rpc_spi.c @@ -156,7 +156,7 @@ DECLARE_GLOBAL_DATA_PTR; -struct rpc_spi_platdata { +struct rpc_spi_plat { fdt_addr_t regs; fdt_addr_t extr; s32 freq; /* Default clock freq, -1 for none */ @@ -406,7 +406,7 @@ static int rpc_spi_bind(struct udevice *parent) static int rpc_spi_probe(struct udevice *dev) { - struct rpc_spi_platdata *plat = dev_get_platdata(dev); + struct rpc_spi_plat *plat = dev_get_plat(dev); struct rpc_spi_priv *priv = dev_get_priv(dev); priv->regs = plat->regs; @@ -417,9 +417,9 @@ static int rpc_spi_probe(struct udevice *dev) return 0; } -static int rpc_spi_ofdata_to_platdata(struct udevice *bus) +static int rpc_spi_of_to_plat(struct udevice *bus) { - struct rpc_spi_platdata *plat = dev_get_platdata(bus); + struct rpc_spi_plat *plat = dev_get_plat(bus); plat->regs = dev_read_addr_index(bus, 0); plat->extr = dev_read_addr_index(bus, 1); @@ -463,9 +463,9 @@ U_BOOT_DRIVER(rpc_spi) = { .id = UCLASS_SPI, .of_match = rpc_spi_ids, .ops = &rpc_spi_ops, - .ofdata_to_platdata = rpc_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct rpc_spi_platdata), - .priv_auto_alloc_size = sizeof(struct rpc_spi_priv), + .of_to_plat = rpc_spi_of_to_plat, + .plat_auto = sizeof(struct rpc_spi_plat), + .priv_auto = sizeof(struct rpc_spi_priv), .bind = rpc_spi_bind, .probe = rpc_spi_probe, }; diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c index c5363c2419..40bd8851b7 100644 --- a/drivers/spi/rk_spi.c +++ b/drivers/spi/rk_spi.c @@ -40,7 +40,7 @@ struct rockchip_spi_params { bool master_manages_fifo; }; -struct rockchip_spi_platdata { +struct rockchip_spi_plat { #if CONFIG_IS_ENABLED(OF_PLATDATA) struct dtd_rockchip_rk3288_spi of_plat; #endif @@ -135,7 +135,7 @@ static int rkspi_wait_till_not_busy(struct rockchip_spi *regs) static void spi_cs_activate(struct udevice *dev, uint cs) { struct udevice *bus = dev->parent; - struct rockchip_spi_platdata *plat = bus->platdata; + struct rockchip_spi_plat *plat = dev_get_plat(bus); struct rockchip_spi_priv *priv = dev_get_priv(bus); struct rockchip_spi *regs = priv->regs; @@ -161,7 +161,7 @@ static void spi_cs_activate(struct udevice *dev, uint cs) static void spi_cs_deactivate(struct udevice *dev, uint cs) { struct udevice *bus = dev->parent; - struct rockchip_spi_platdata *plat = bus->platdata; + struct rockchip_spi_plat *plat = dev_get_plat(bus); struct rockchip_spi_priv *priv = dev_get_priv(bus); struct rockchip_spi *regs = priv->regs; @@ -174,9 +174,9 @@ static void spi_cs_deactivate(struct udevice *dev, uint cs) } #if CONFIG_IS_ENABLED(OF_PLATDATA) -static int conv_of_platdata(struct udevice *dev) +static int conv_of_plat(struct udevice *dev) { - struct rockchip_spi_platdata *plat = dev->platdata; + struct rockchip_spi_plat *plat = dev_get_plat(dev); struct dtd_rockchip_rk3288_spi *dtplat = &plat->of_plat; struct rockchip_spi_priv *priv = dev_get_priv(dev); int ret; @@ -186,16 +186,15 @@ static int conv_of_platdata(struct udevice *dev) ret = clk_get_by_driver_info(dev, dtplat->clocks, &priv->clk); if (ret < 0) return ret; - dev->req_seq = 0; return 0; } #endif -static int rockchip_spi_ofdata_to_platdata(struct udevice *bus) +static int rockchip_spi_of_to_plat(struct udevice *bus) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - struct rockchip_spi_platdata *plat = dev_get_platdata(bus); + struct rockchip_spi_plat *plat = dev_get_plat(bus); struct rockchip_spi_priv *priv = dev_get_priv(bus); int ret; @@ -253,13 +252,13 @@ static int rockchip_spi_calc_modclk(ulong max_freq) static int rockchip_spi_probe(struct udevice *bus) { - struct rockchip_spi_platdata *plat = dev_get_platdata(bus); + struct rockchip_spi_plat *plat = dev_get_plat(bus); struct rockchip_spi_priv *priv = dev_get_priv(bus); int ret; debug("%s: probe\n", __func__); #if CONFIG_IS_ENABLED(OF_PLATDATA) - ret = conv_of_platdata(bus); + ret = conv_of_plat(bus); if (ret) return ret; #endif @@ -432,7 +431,7 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen, struct udevice *bus = dev->parent; struct rockchip_spi_priv *priv = dev_get_priv(bus); struct rockchip_spi *regs = priv->regs; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); int len = bitlen >> 3; const u8 *out = dout; u8 *in = din; @@ -560,10 +559,10 @@ U_BOOT_DRIVER(rockchip_rk3288_spi) = { .id = UCLASS_SPI, .of_match = rockchip_spi_ids, .ops = &rockchip_spi_ops, - .ofdata_to_platdata = rockchip_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct rockchip_spi_platdata), - .priv_auto_alloc_size = sizeof(struct rockchip_spi_priv), + .of_to_plat = rockchip_spi_of_to_plat, + .plat_auto = sizeof(struct rockchip_spi_plat), + .priv_auto = sizeof(struct rockchip_spi_priv), .probe = rockchip_spi_probe, }; -U_BOOT_DRIVER_ALIAS(rockchip_rk3288_spi, rockchip_rk3368_spi) +DM_DRIVER_ALIAS(rockchip_rk3288_spi, rockchip_rk3368_spi) diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c index 755f176861..0564d8b55e 100644 --- a/drivers/spi/sandbox_spi.c +++ b/drivers/spi/sandbox_spi.c @@ -28,21 +28,22 @@ # define CONFIG_SPI_IDLE_VAL 0xFF #endif -const char *sandbox_spi_parse_spec(const char *arg, unsigned long *bus, - unsigned long *cs) -{ - char *endp; - - *bus = simple_strtoul(arg, &endp, 0); - if (*endp != ':' || *bus >= CONFIG_SANDBOX_SPI_MAX_BUS) - return NULL; - - *cs = simple_strtoul(endp + 1, &endp, 0); - if (*endp != ':' || *cs >= CONFIG_SANDBOX_SPI_MAX_CS) - return NULL; - - return endp + 1; -} +/** + * struct sandbox_spi_priv - Sandbox SPI private data + * + * Helper struct to keep track of the sandbox SPI bus internal state. It is + * used in unit tests to verify that dm spi functions update the bus + * speed/mode properly (for instance, when jumping back and forth between spi + * slaves claiming the bus, we need to make sure that the bus speed is updated + * accordingly for each slave). + * + * @speed: Current bus speed. + * @mode: Current bus mode. + */ +struct sandbox_spi_priv { + uint speed; + uint mode; +}; __weak int sandbox_spi_get_emul(struct sandbox_state *state, struct udevice *bus, struct udevice *slave, @@ -51,6 +52,20 @@ __weak int sandbox_spi_get_emul(struct sandbox_state *state, return -ENOENT; } +uint sandbox_spi_get_speed(struct udevice *dev) +{ + struct sandbox_spi_priv *priv = dev_get_priv(dev); + + return priv->speed; +} + +uint sandbox_spi_get_mode(struct udevice *dev) +{ + struct sandbox_spi_priv *priv = dev_get_priv(dev); + + return priv->mode; +} + static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { @@ -72,7 +87,7 @@ static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen, return -EINVAL; } - busnum = bus->seq; + busnum = dev_seq(bus); cs = spi_chip_select(slave); if (busnum >= CONFIG_SANDBOX_SPI_MAX_BUS || cs >= CONFIG_SANDBOX_SPI_MAX_CS) { @@ -106,19 +121,27 @@ static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen, static int sandbox_spi_set_speed(struct udevice *bus, uint speed) { + struct sandbox_spi_priv *priv = dev_get_priv(bus); + + priv->speed = speed; + return 0; } static int sandbox_spi_set_mode(struct udevice *bus, uint mode) { + struct sandbox_spi_priv *priv = dev_get_priv(bus); + + priv->mode = mode; + return 0; } static int sandbox_cs_info(struct udevice *bus, uint cs, struct spi_cs_info *info) { - /* Always allow activity on CS 0 */ - if (cs >= 1) + /* Always allow activity on CS 0, CS 1 */ + if (cs >= 2) return -EINVAL; return 0; @@ -152,4 +175,5 @@ U_BOOT_DRIVER(sandbox_spi) = { .id = UCLASS_SPI, .of_match = sandbox_spi_ids, .ops = &sandbox_spi_ops, + .priv_auto = sizeof(struct sandbox_spi_priv), }; diff --git a/drivers/spi/sh_qspi.c b/drivers/spi/sh_qspi.c index aa1c03047e..5ba8a8ea79 100644 --- a/drivers/spi/sh_qspi.c +++ b/drivers/spi/sh_qspi.c @@ -302,7 +302,7 @@ static int sh_qspi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev->parent; - struct sh_qspi_slave *ss = dev_get_platdata(bus); + struct sh_qspi_slave *ss = dev_get_plat(bus); return sh_qspi_xfer_common(ss, bitlen, dout, din, flags); } @@ -321,16 +321,16 @@ static int sh_qspi_set_mode(struct udevice *dev, uint mode) static int sh_qspi_probe(struct udevice *dev) { - struct sh_qspi_slave *ss = dev_get_platdata(dev); + struct sh_qspi_slave *ss = dev_get_plat(dev); sh_qspi_init(ss); return 0; } -static int sh_qspi_ofdata_to_platdata(struct udevice *dev) +static int sh_qspi_of_to_plat(struct udevice *dev) { - struct sh_qspi_slave *plat = dev_get_platdata(dev); + struct sh_qspi_slave *plat = dev_get_plat(dev); plat->regs = (struct sh_qspi_regs *)dev_read_addr(dev); @@ -353,8 +353,8 @@ U_BOOT_DRIVER(sh_qspi) = { .id = UCLASS_SPI, .of_match = sh_qspi_ids, .ops = &sh_qspi_ops, - .ofdata_to_platdata = sh_qspi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct sh_qspi_slave), + .of_to_plat = sh_qspi_of_to_plat, + .plat_auto = sizeof(struct sh_qspi_slave), .probe = sh_qspi_probe, }; #endif diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c index 153bbf8b25..3425d9950a 100644 --- a/drivers/spi/soft_spi.c +++ b/drivers/spi/soft_spi.c @@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR; -struct soft_spi_platdata { +struct soft_spi_plat { struct gpio_desc cs; struct gpio_desc sclk; struct gpio_desc mosi; @@ -41,7 +41,7 @@ struct soft_spi_priv { static int soft_spi_scl(struct udevice *dev, int bit) { struct udevice *bus = dev_get_parent(dev); - struct soft_spi_platdata *plat = dev_get_platdata(bus); + struct soft_spi_plat *plat = dev_get_plat(bus); dm_gpio_set_value(&plat->sclk, bit); @@ -51,7 +51,7 @@ static int soft_spi_scl(struct udevice *dev, int bit) static int soft_spi_sda(struct udevice *dev, int bit) { struct udevice *bus = dev_get_parent(dev); - struct soft_spi_platdata *plat = dev_get_platdata(bus); + struct soft_spi_plat *plat = dev_get_plat(bus); dm_gpio_set_value(&plat->mosi, bit); @@ -62,7 +62,7 @@ static int soft_spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev_get_parent(dev); struct soft_spi_priv *priv = dev_get_priv(bus); - struct soft_spi_platdata *plat = dev_get_platdata(bus); + struct soft_spi_plat *plat = dev_get_plat(bus); int cidle = !!(priv->mode & SPI_CPOL); dm_gpio_set_value(&plat->cs, 0); @@ -75,7 +75,7 @@ static int soft_spi_cs_activate(struct udevice *dev) static int soft_spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev_get_parent(dev); - struct soft_spi_platdata *plat = dev_get_platdata(bus); + struct soft_spi_plat *plat = dev_get_plat(bus); dm_gpio_set_value(&plat->cs, 0); @@ -117,7 +117,7 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen, { struct udevice *bus = dev_get_parent(dev); struct soft_spi_priv *priv = dev_get_priv(bus); - struct soft_spi_platdata *plat = dev_get_platdata(bus); + struct soft_spi_plat *plat = dev_get_plat(bus); uchar tmpdin = 0; uchar tmpdout = 0; const u8 *txd = dout; @@ -226,9 +226,9 @@ static const struct dm_spi_ops soft_spi_ops = { .set_mode = soft_spi_set_mode, }; -static int soft_spi_ofdata_to_platdata(struct udevice *dev) +static int soft_spi_of_to_plat(struct udevice *dev) { - struct soft_spi_platdata *plat = dev->platdata; + struct soft_spi_plat *plat = dev_get_plat(dev); const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); @@ -240,7 +240,7 @@ static int soft_spi_ofdata_to_platdata(struct udevice *dev) static int soft_spi_probe(struct udevice *dev) { struct spi_slave *slave = dev_get_parent_priv(dev); - struct soft_spi_platdata *plat = dev->platdata; + struct soft_spi_plat *plat = dev_get_plat(dev); int cs_flags, clk_flags; int ret; @@ -280,8 +280,8 @@ U_BOOT_DRIVER(soft_spi) = { .id = UCLASS_SPI, .of_match = soft_spi_ids, .ops = &soft_spi_ops, - .ofdata_to_platdata = soft_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct soft_spi_platdata), - .priv_auto_alloc_size = sizeof(struct soft_spi_priv), + .of_to_plat = soft_spi_of_to_plat, + .plat_auto = sizeof(struct soft_spi_plat), + .priv_auto = sizeof(struct soft_spi_priv), .probe = soft_spi_probe, }; diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index 6f8df55fa5..cdea5405f6 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -701,7 +701,7 @@ static int qup_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev_get_parent(dev); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); unsigned int len; const u8 *txp = dout; u8 *rxp = din; @@ -798,6 +798,6 @@ U_BOOT_DRIVER(spi_qup) = { .id = UCLASS_SPI, .of_match = qup_spi_ids, .ops = &qup_spi_ops, - .priv_auto_alloc_size = sizeof(struct qup_spi_priv), + .priv_auto = sizeof(struct qup_spi_priv), .probe = qup_spi_probe, }; diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c index c7345d9042..0a00df0ac7 100644 --- a/drivers/spi/spi-sifive.c +++ b/drivers/spi/spi-sifive.c @@ -105,7 +105,7 @@ struct sifive_spi { }; static void sifive_spi_prep_device(struct sifive_spi *spi, - struct dm_spi_slave_platdata *slave_plat) + struct dm_spi_slave_plat *slave_plat) { /* Update the chip select polarity */ if (slave_plat->mode & SPI_CS_HIGH) @@ -119,7 +119,7 @@ static void sifive_spi_prep_device(struct sifive_spi *spi, } static int sifive_spi_set_cs(struct sifive_spi *spi, - struct dm_spi_slave_platdata *slave_plat) + struct dm_spi_slave_plat *slave_plat) { u32 cs_mode = SIFIVE_SPI_CSMODE_MODE_HOLD; @@ -137,7 +137,7 @@ static void sifive_spi_clear_cs(struct sifive_spi *spi) } static void sifive_spi_prep_transfer(struct sifive_spi *spi, - struct dm_spi_slave_platdata *slave_plat, + struct dm_spi_slave_plat *slave_plat, u8 *rx_ptr) { u32 cr; @@ -212,7 +212,7 @@ static int sifive_spi_xfer(struct udevice *dev, unsigned int bitlen, { struct udevice *bus = dev->parent; struct sifive_spi *spi = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); const u8 *tx_ptr = dout; u8 *rx_ptr = din; u32 remaining_len; @@ -475,6 +475,6 @@ U_BOOT_DRIVER(sifive_spi) = { .id = UCLASS_SPI, .of_match = sifive_spi_ids, .ops = &sifive_spi_ops, - .priv_auto_alloc_size = sizeof(struct sifive_spi), + .priv_auto = sizeof(struct sifive_spi), .probe = sifive_spi_probe, }; diff --git a/drivers/spi/spi-sunxi.c b/drivers/spi/spi-sunxi.c index 0844a5a0a6..1145380078 100644 --- a/drivers/spi/spi-sunxi.c +++ b/drivers/spi/spi-sunxi.c @@ -122,7 +122,7 @@ struct sun4i_spi_variant { bool has_burst_ctl; }; -struct sun4i_spi_platdata { +struct sun4i_spi_plat { struct sun4i_spi_variant *variant; u32 base; u32 max_hz; @@ -339,7 +339,7 @@ static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen, { struct udevice *bus = dev->parent; struct sun4i_spi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); u32 len = bitlen / 8; u32 rx_fifocnt; @@ -407,7 +407,7 @@ static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen, static int sun4i_spi_set_speed(struct udevice *dev, uint speed) { - struct sun4i_spi_platdata *plat = dev_get_platdata(dev); + struct sun4i_spi_plat *plat = dev_get_plat(dev); struct sun4i_spi_priv *priv = dev_get_priv(dev); unsigned int div; u32 reg; @@ -483,7 +483,7 @@ static const struct dm_spi_ops sun4i_spi_ops = { static int sun4i_spi_probe(struct udevice *bus) { - struct sun4i_spi_platdata *plat = dev_get_platdata(bus); + struct sun4i_spi_plat *plat = dev_get_plat(bus); struct sun4i_spi_priv *priv = dev_get_priv(bus); int ret; @@ -514,9 +514,9 @@ static int sun4i_spi_probe(struct udevice *bus) return 0; } -static int sun4i_spi_ofdata_to_platdata(struct udevice *bus) +static int sun4i_spi_of_to_plat(struct udevice *bus) { - struct sun4i_spi_platdata *plat = dev_get_platdata(bus); + struct sun4i_spi_plat *plat = dev_get_plat(bus); int node = dev_of_offset(bus); plat->base = dev_read_addr(bus); @@ -630,8 +630,8 @@ U_BOOT_DRIVER(sun4i_spi) = { .id = UCLASS_SPI, .of_match = sun4i_spi_ids, .ops = &sun4i_spi_ops, - .ofdata_to_platdata = sun4i_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct sun4i_spi_platdata), - .priv_auto_alloc_size = sizeof(struct sun4i_spi_priv), + .of_to_plat = sun4i_spi_of_to_plat, + .plat_auto = sizeof(struct sun4i_spi_plat), + .priv_auto = sizeof(struct sun4i_spi_priv), .probe = sun4i_spi_probe, }; diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index d5a1e3a676..3fe351f8a7 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -54,23 +54,28 @@ int dm_spi_claim_bus(struct udevice *dev) struct dm_spi_ops *ops = spi_get_ops(bus); struct dm_spi_bus *spi = dev_get_uclass_priv(bus); struct spi_slave *slave = dev_get_parent_priv(dev); - int speed; + uint speed, mode; speed = slave->max_hz; + mode = slave->mode; + if (spi->max_hz) { if (speed) - speed = min(speed, (int)spi->max_hz); + speed = min(speed, spi->max_hz); else speed = spi->max_hz; } if (!speed) speed = SPI_DEFAULT_SPEED_HZ; - if (speed != slave->speed) { + + if (speed != spi->speed || mode != spi->mode) { int ret = spi_set_speed_mode(bus, speed, slave->mode); if (ret) return log_ret(ret); - slave->speed = speed; + + spi->speed = speed; + spi->mode = mode; } return log_ret(ops->claim_bus ? ops->claim_bus(dev) : 0); @@ -158,12 +163,12 @@ int spi_write_then_read(struct spi_slave *slave, const u8 *opcode, #if !CONFIG_IS_ENABLED(OF_PLATDATA) static int spi_child_post_bind(struct udevice *dev) { - struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; - return spi_slave_ofdata_to_platdata(dev, plat); + return spi_slave_of_to_plat(dev, plat); } #endif @@ -202,7 +207,7 @@ static int spi_post_probe(struct udevice *bus) static int spi_child_pre_probe(struct udevice *dev) { - struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); struct spi_slave *slave = dev_get_parent_priv(dev); /* @@ -223,7 +228,7 @@ static int spi_child_pre_probe(struct udevice *dev) int spi_chip_select(struct udevice *dev) { - struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev); return plat ? plat->cs : -ENOENT; } @@ -259,9 +264,9 @@ int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp) for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { - struct dm_spi_slave_platdata *plat; + struct dm_spi_slave_plat *plat; - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); dev_dbg(bus, "%s: plat=%p, cs=%d\n", __func__, plat, plat->cs); if (plat->cs == cs) { *devp = dev; @@ -278,7 +283,7 @@ int spi_cs_is_valid(unsigned int busnum, unsigned int cs) struct udevice *bus; int ret; - ret = uclass_find_device_by_seq(UCLASS_SPI, busnum, false, &bus); + ret = uclass_find_device_by_seq(UCLASS_SPI, busnum, &bus); if (ret) { log_debug("%s: No bus %d\n", __func__, busnum); return ret; @@ -307,7 +312,7 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp, struct udevice *bus, *dev; int ret; - ret = uclass_find_device_by_seq(UCLASS_SPI, busnum, false, &bus); + ret = uclass_find_device_by_seq(UCLASS_SPI, busnum, &bus); if (ret) { log_debug("%s: No bus %d\n", __func__, busnum); return ret; @@ -328,7 +333,8 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, struct udevice **busp, struct spi_slave **devp) { struct udevice *bus, *dev; - struct dm_spi_slave_platdata *plat; + struct dm_spi_slave_plat *plat; + struct dm_spi_bus *bus_data; struct spi_slave *slave; bool created = false; int ret; @@ -358,7 +364,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, __func__, ret); return ret; } - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); plat->cs = cs; if (speed) { plat->max_hz = speed; @@ -386,12 +392,13 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, } slave = dev_get_parent_priv(dev); + bus_data = dev_get_uclass_priv(bus); /* * In case the operation speed is not yet established by * dm_spi_claim_bus() ensure the bus is configured properly. */ - if (!slave->speed) { + if (!bus_data->speed) { ret = spi_claim_bus(slave); if (ret) goto err; @@ -433,11 +440,9 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs, void spi_free_slave(struct spi_slave *slave) { device_remove(slave->dev, DM_REMOVE_NORMAL); - slave->dev = NULL; } -int spi_slave_ofdata_to_platdata(struct udevice *dev, - struct dm_spi_slave_platdata *plat) +int spi_slave_of_to_plat(struct udevice *dev, struct dm_spi_slave_plat *plat) { int mode = 0; int value; @@ -507,10 +512,9 @@ UCLASS_DRIVER(spi) = { #endif .post_probe = spi_post_probe, .child_pre_probe = spi_child_pre_probe, - .per_device_auto_alloc_size = sizeof(struct dm_spi_bus), - .per_child_auto_alloc_size = sizeof(struct spi_slave), - .per_child_platdata_auto_alloc_size = - sizeof(struct dm_spi_slave_platdata), + .per_device_auto = sizeof(struct dm_spi_bus), + .per_child_auto = sizeof(struct spi_slave), + .per_child_plat_auto = sizeof(struct dm_spi_slave_plat), #if !CONFIG_IS_ENABLED(OF_PLATDATA) .child_post_bind = spi_child_post_bind, #endif diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c index a53b941410..440085720a 100644 --- a/drivers/spi/stm32_qspi.c +++ b/drivers/spi/stm32_qspi.c @@ -400,7 +400,7 @@ static int stm32_qspi_probe(struct udevice *bus) static int stm32_qspi_claim_bus(struct udevice *dev) { struct stm32_qspi_priv *priv = dev_get_priv(dev->parent); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); int slave_cs = slave_plat->cs; if (slave_cs >= STM32_QSPI_MAX_CHIP) @@ -541,6 +541,6 @@ U_BOOT_DRIVER(stm32_qspi) = { .id = UCLASS_SPI, .of_match = stm32_qspi_ids, .ops = &stm32_qspi_ops, - .priv_auto_alloc_size = sizeof(struct stm32_qspi_priv), + .priv_auto = sizeof(struct stm32_qspi_priv), .probe = stm32_qspi_probe, }; diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c index 4a0833b6fa..720103d517 100644 --- a/drivers/spi/stm32_spi.c +++ b/drivers/spi/stm32_spi.c @@ -362,7 +362,7 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev_get_parent(slave); - struct dm_spi_slave_platdata *slave_plat; + struct dm_spi_slave_plat *slave_plat; struct stm32_spi_priv *priv = dev_get_priv(bus); u32 sr; u32 ifcr = 0; @@ -407,7 +407,7 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen, debug("%s: priv->tx_len=%d priv->rx_len=%d\n", __func__, priv->tx_len, priv->rx_len); - slave_plat = dev_get_parent_platdata(slave); + slave_plat = dev_get_parent_plat(slave); if (flags & SPI_XFER_BEGIN) stm32_spi_set_cs(bus, slave_plat->cs, false); @@ -615,7 +615,7 @@ U_BOOT_DRIVER(stm32_spi) = { .id = UCLASS_SPI, .of_match = stm32_spi_ids, .ops = &stm32_spi_ops, - .priv_auto_alloc_size = sizeof(struct stm32_spi_priv), + .priv_auto = sizeof(struct stm32_spi_priv), .probe = stm32_spi_probe, .remove = stm32_spi_remove, }; diff --git a/drivers/spi/tegra114_spi.c b/drivers/spi/tegra114_spi.c index 0e8198c5a0..f0256d8e66 100644 --- a/drivers/spi/tegra114_spi.c +++ b/drivers/spi/tegra114_spi.c @@ -97,9 +97,9 @@ struct tegra114_spi_priv { int last_transaction_us; }; -static int tegra114_spi_ofdata_to_platdata(struct udevice *bus) +static int tegra114_spi_of_to_plat(struct udevice *bus) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); plat->base = dev_read_addr(bus); plat->periph_id = clock_decode_periph_id(bus); @@ -124,7 +124,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus) static int tegra114_spi_probe(struct udevice *bus) { - struct tegra_spi_platdata *plat = dev_get_platdata(bus); + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra114_spi_priv *priv = dev_get_priv(bus); struct spi_regs *regs; ulong rate; @@ -181,7 +181,7 @@ static int tegra114_spi_probe(struct udevice *bus) static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra114_spi_priv *priv = dev_get_priv(bus); /* If it's too soon to do another transaction, wait */ @@ -205,7 +205,7 @@ static void spi_cs_activate(struct udevice *dev) static void spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra114_spi_priv *priv = dev_get_priv(bus); setbits_le32(&priv->regs->command1, SPI_CMD1_CS_SW_VAL); @@ -231,7 +231,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen, int ret; debug("%s: slave %u:%u dout %p din %p bitlen %u\n", - __func__, bus->seq, spi_chip_select(dev), dout, din, bitlen); + __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen); if (bitlen % 8) return -1; num_bytes = bitlen / 8; @@ -352,7 +352,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen, static int tegra114_spi_set_speed(struct udevice *bus, uint speed) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra114_spi_priv *priv = dev_get_priv(bus); if (speed > plat->frequency) @@ -393,8 +393,8 @@ U_BOOT_DRIVER(tegra114_spi) = { .id = UCLASS_SPI, .of_match = tegra114_spi_ids, .ops = &tegra114_spi_ops, - .ofdata_to_platdata = tegra114_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata), - .priv_auto_alloc_size = sizeof(struct tegra114_spi_priv), + .of_to_plat = tegra114_spi_of_to_plat, + .plat_auto = sizeof(struct tegra_spi_plat), + .priv_auto = sizeof(struct tegra114_spi_priv), .probe = tegra114_spi_probe, }; diff --git a/drivers/spi/tegra20_sflash.c b/drivers/spi/tegra20_sflash.c index 771744dfe4..4384a48ec8 100644 --- a/drivers/spi/tegra20_sflash.c +++ b/drivers/spi/tegra20_sflash.c @@ -87,9 +87,9 @@ int tegra20_sflash_cs_info(struct udevice *bus, unsigned int cs, return 0; } -static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus) +static int tegra20_sflash_of_to_plat(struct udevice *bus) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -116,7 +116,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus) static int tegra20_sflash_probe(struct udevice *bus) { - struct tegra_spi_platdata *plat = dev_get_platdata(bus); + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra20_sflash_priv *priv = dev_get_priv(bus); priv->regs = (struct spi_regs *)plat->base; @@ -173,7 +173,7 @@ static int tegra20_sflash_claim_bus(struct udevice *dev) static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra20_sflash_priv *priv = dev_get_priv(bus); /* If it's too soon to do another transaction, wait */ @@ -192,7 +192,7 @@ static void spi_cs_activate(struct udevice *dev) static void spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra20_sflash_priv *priv = dev_get_priv(bus); /* CS is negated on Tegra, so drive a 0 to get a 1 */ @@ -217,7 +217,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen, int ret; debug("%s: slave %u:%u dout %p din %p bitlen %u\n", - __func__, bus->seq, spi_chip_select(dev), dout, din, bitlen); + __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen); if (bitlen % 8) return -1; num_bytes = bitlen / 8; @@ -314,7 +314,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen, static int tegra20_sflash_set_speed(struct udevice *bus, uint speed) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra20_sflash_priv *priv = dev_get_priv(bus); if (speed > plat->frequency) @@ -353,8 +353,8 @@ U_BOOT_DRIVER(tegra20_sflash) = { .id = UCLASS_SPI, .of_match = tegra20_sflash_ids, .ops = &tegra20_sflash_ops, - .ofdata_to_platdata = tegra20_sflash_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata), - .priv_auto_alloc_size = sizeof(struct tegra20_sflash_priv), + .of_to_plat = tegra20_sflash_of_to_plat, + .plat_auto = sizeof(struct tegra_spi_plat), + .priv_auto = sizeof(struct tegra20_sflash_priv), .probe = tegra20_sflash_probe, }; diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c index f9846ee366..3057fe1a22 100644 --- a/drivers/spi/tegra20_slink.c +++ b/drivers/spi/tegra20_slink.c @@ -93,9 +93,9 @@ struct tegra_spi_slave { struct tegra30_spi_priv *ctrl; }; -static int tegra30_spi_ofdata_to_platdata(struct udevice *bus) +static int tegra30_spi_of_to_plat(struct udevice *bus) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -122,7 +122,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus) static int tegra30_spi_probe(struct udevice *bus) { - struct tegra_spi_platdata *plat = dev_get_platdata(bus); + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra30_spi_priv *priv = dev_get_priv(bus); priv->regs = (struct spi_regs *)plat->base; @@ -167,7 +167,7 @@ static int tegra30_spi_claim_bus(struct udevice *dev) static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra30_spi_priv *priv = dev_get_priv(bus); /* If it's too soon to do another transaction, wait */ @@ -186,7 +186,7 @@ static void spi_cs_activate(struct udevice *dev) static void spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra30_spi_priv *priv = dev_get_priv(bus); /* CS is negated on Tegra, so drive a 0 to get a 1 */ @@ -211,7 +211,7 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen, int ret; debug("%s: slave %u:%u dout %p din %p bitlen %u\n", - __func__, bus->seq, spi_chip_select(dev), dout, din, bitlen); + __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen); if (bitlen % 8) return -1; num_bytes = bitlen / 8; @@ -314,7 +314,7 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen, static int tegra30_spi_set_speed(struct udevice *bus, uint speed) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra30_spi_priv *priv = dev_get_priv(bus); if (speed > plat->frequency) @@ -372,8 +372,8 @@ U_BOOT_DRIVER(tegra30_spi) = { .id = UCLASS_SPI, .of_match = tegra30_spi_ids, .ops = &tegra30_spi_ops, - .ofdata_to_platdata = tegra30_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata), - .priv_auto_alloc_size = sizeof(struct tegra30_spi_priv), + .of_to_plat = tegra30_spi_of_to_plat, + .plat_auto = sizeof(struct tegra_spi_plat), + .priv_auto = sizeof(struct tegra30_spi_priv), .probe = tegra30_spi_probe, }; diff --git a/drivers/spi/tegra210_qspi.c b/drivers/spi/tegra210_qspi.c index ae16b45dcb..b464b9ccb0 100644 --- a/drivers/spi/tegra210_qspi.c +++ b/drivers/spi/tegra210_qspi.c @@ -97,9 +97,9 @@ struct tegra210_qspi_priv { int last_transaction_us; }; -static int tegra210_qspi_ofdata_to_platdata(struct udevice *bus) +static int tegra210_qspi_of_to_plat(struct udevice *bus) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); plat->base = dev_read_addr(bus); plat->periph_id = clock_decode_periph_id(bus); @@ -125,7 +125,7 @@ static int tegra210_qspi_ofdata_to_platdata(struct udevice *bus) static int tegra210_qspi_probe(struct udevice *bus) { - struct tegra_spi_platdata *plat = dev_get_platdata(bus); + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra210_qspi_priv *priv = dev_get_priv(bus); priv->regs = (struct qspi_regs *)plat->base; @@ -174,7 +174,7 @@ static int tegra210_qspi_claim_bus(struct udevice *dev) static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra210_qspi_priv *priv = dev_get_priv(bus); /* If it's too soon to do another transaction, wait */ @@ -198,7 +198,7 @@ static void spi_cs_activate(struct udevice *dev) static void spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct tegra_spi_platdata *pdata = dev_get_platdata(bus); + struct tegra_spi_plat *pdata = dev_get_plat(bus); struct tegra210_qspi_priv *priv = dev_get_priv(bus); setbits_le32(&priv->regs->command1, QSPI_CMD1_CS_SW_VAL); @@ -223,7 +223,7 @@ static int tegra210_qspi_xfer(struct udevice *dev, unsigned int bitlen, int num_bytes, tm, ret; debug("%s: slave %u:%u dout %p din %p bitlen %u\n", - __func__, bus->seq, spi_chip_select(dev), dout, din, bitlen); + __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen); if (bitlen % 8) return -1; num_bytes = bitlen / 8; @@ -380,7 +380,7 @@ static int tegra210_qspi_xfer(struct udevice *dev, unsigned int bitlen, static int tegra210_qspi_set_speed(struct udevice *bus, uint speed) { - struct tegra_spi_platdata *plat = bus->platdata; + struct tegra_spi_plat *plat = dev_get_plat(bus); struct tegra210_qspi_priv *priv = dev_get_priv(bus); if (speed > plat->frequency) @@ -422,9 +422,9 @@ U_BOOT_DRIVER(tegra210_qspi) = { .id = UCLASS_SPI, .of_match = tegra210_qspi_ids, .ops = &tegra210_qspi_ops, - .ofdata_to_platdata = tegra210_qspi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata), - .priv_auto_alloc_size = sizeof(struct tegra210_qspi_priv), - .per_child_auto_alloc_size = sizeof(struct spi_slave), + .of_to_plat = tegra210_qspi_of_to_plat, + .plat_auto = sizeof(struct tegra_spi_plat), + .priv_auto = sizeof(struct tegra210_qspi_priv), + .per_child_auto = sizeof(struct spi_slave), .probe = tegra210_qspi_probe, }; diff --git a/drivers/spi/tegra_spi.h b/drivers/spi/tegra_spi.h index e997d668cd..ab69ea42e0 100644 --- a/drivers/spi/tegra_spi.h +++ b/drivers/spi/tegra_spi.h @@ -3,7 +3,7 @@ * (C) Copyright 2014 Google, Inc */ -struct tegra_spi_platdata { +struct tegra_spi_plat { enum periph_id periph_id; int frequency; /* Default clock frequency, -1 for none */ ulong base; diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c index 5fdbb49442..76bc480f43 100644 --- a/drivers/spi/ti_qspi.c +++ b/drivers/spi/ti_qspi.c @@ -154,7 +154,7 @@ static void ti_qspi_ctrl_mode_mmap(void *ctrl_mod_mmap, int cs, bool enable) static int ti_qspi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { - struct dm_spi_slave_platdata *slave = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave = dev_get_parent_plat(dev); struct ti_qspi_priv *priv; struct udevice *bus; uint words = bitlen >> 3; /* fixed 8-bit word length */ @@ -323,7 +323,7 @@ static int ti_qspi_set_mode(struct udevice *bus, uint mode) static int ti_qspi_exec_mem_op(struct spi_slave *slave, const struct spi_mem_op *op) { - struct dm_spi_slave_platdata *slave_plat; + struct dm_spi_slave_plat *slave_plat; struct ti_qspi_priv *priv; struct udevice *bus; u32 from = 0; @@ -331,7 +331,7 @@ static int ti_qspi_exec_mem_op(struct spi_slave *slave, bus = slave->dev->parent; priv = dev_get_priv(bus); - slave_plat = dev_get_parent_platdata(slave->dev); + slave_plat = dev_get_parent_plat(slave->dev); /* Only optimize read path. */ if (!op->data.nbytes || op->data.dir != SPI_MEM_DATA_IN || @@ -355,7 +355,7 @@ static int ti_qspi_exec_mem_op(struct spi_slave *slave, static int ti_qspi_claim_bus(struct udevice *dev) { - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); struct ti_qspi_priv *priv; struct udevice *bus; @@ -384,7 +384,7 @@ static int ti_qspi_claim_bus(struct udevice *dev) static int ti_qspi_release_bus(struct udevice *dev) { - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); struct ti_qspi_priv *priv; struct udevice *bus; @@ -452,7 +452,7 @@ static void *map_syscon_chipselects(struct udevice *bus) #endif } -static int ti_qspi_ofdata_to_platdata(struct udevice *bus) +static int ti_qspi_of_to_plat(struct udevice *bus) { struct ti_qspi_priv *priv = dev_get_priv(bus); const void *blob = gd->fdt_blob; @@ -467,8 +467,8 @@ static int ti_qspi_ofdata_to_platdata(struct udevice *bus) priv->memory_map = map_physmem(mmap_addr, mmap_size, MAP_NOCACHE); priv->mmap_size = mmap_size; - priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1); - if (priv->max_hz < 0) { + priv->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0); + if (!priv->max_hz) { debug("Error: Max frequency missing\n"); return -ENODEV; } @@ -504,7 +504,7 @@ U_BOOT_DRIVER(ti_qspi) = { .id = UCLASS_SPI, .of_match = ti_qspi_ids, .ops = &ti_qspi_ops, - .ofdata_to_platdata = ti_qspi_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct ti_qspi_priv), + .of_to_plat = ti_qspi_of_to_plat, + .priv_auto = sizeof(struct ti_qspi_priv), .probe = ti_qspi_probe, }; diff --git a/drivers/spi/uniphier_spi.c b/drivers/spi/uniphier_spi.c index b6456685f8..e47ed5b221 100644 --- a/drivers/spi/uniphier_spi.c +++ b/drivers/spi/uniphier_spi.c @@ -68,7 +68,7 @@ DECLARE_GLOBAL_DATA_PTR; #define SSI_CLK 50000000 /* internal I/O clock: 50MHz */ -struct uniphier_spi_platdata { +struct uniphier_spi_plat { void __iomem *base; u32 frequency; /* input frequency */ u32 speed_hz; @@ -113,7 +113,7 @@ static void uniphier_spi_regdump(struct uniphier_spi_priv *priv) static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct uniphier_spi_platdata *plat = bus->platdata; + struct uniphier_spi_plat *plat = dev_get_plat(bus); struct uniphier_spi_priv *priv = dev_get_priv(bus); ulong delay_us; /* The delay completed so far */ u32 val; @@ -139,7 +139,7 @@ static void spi_cs_activate(struct udevice *dev) static void spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct uniphier_spi_platdata *plat = bus->platdata; + struct uniphier_spi_plat *plat = dev_get_plat(bus); struct uniphier_spi_priv *priv = dev_get_priv(bus); u32 val; @@ -279,7 +279,7 @@ static int uniphier_spi_xfer(struct udevice *dev, unsigned int bitlen, static int uniphier_spi_set_speed(struct udevice *bus, uint speed) { - struct uniphier_spi_platdata *plat = bus->platdata; + struct uniphier_spi_plat *plat = dev_get_plat(bus); struct uniphier_spi_priv *priv = dev_get_priv(bus); u32 val, ckdiv; @@ -362,9 +362,9 @@ static int uniphier_spi_set_mode(struct udevice *bus, uint mode) return 0; } -static int uniphier_spi_ofdata_to_platdata(struct udevice *bus) +static int uniphier_spi_of_to_plat(struct udevice *bus) { - struct uniphier_spi_platdata *plat = bus->platdata; + struct uniphier_spi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -383,7 +383,7 @@ static int uniphier_spi_ofdata_to_platdata(struct udevice *bus) static int uniphier_spi_probe(struct udevice *bus) { - struct uniphier_spi_platdata *plat = dev_get_platdata(bus); + struct uniphier_spi_plat *plat = dev_get_plat(bus); struct uniphier_spi_priv *priv = dev_get_priv(bus); priv->base = plat->base; @@ -411,8 +411,8 @@ U_BOOT_DRIVER(uniphier_spi) = { .id = UCLASS_SPI, .of_match = uniphier_spi_ids, .ops = &uniphier_spi_ops, - .ofdata_to_platdata = uniphier_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct uniphier_spi_platdata), - .priv_auto_alloc_size = sizeof(struct uniphier_spi_priv), + .of_to_plat = uniphier_spi_of_to_plat, + .plat_auto = sizeof(struct uniphier_spi_plat), + .priv_auto = sizeof(struct uniphier_spi_priv), .probe = uniphier_spi_probe, }; diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 47a5571aec..0274afdc6e 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c @@ -211,7 +211,7 @@ static void xilinx_spi_startup_block(struct udevice *dev, unsigned int bytes, struct udevice *bus = dev_get_parent(dev); struct xilinx_spi_priv *priv = dev_get_priv(bus); struct xilinx_spi_regs *regs = priv->regs; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); const unsigned char *txp = dout; unsigned char *rxp = din; u32 reg; @@ -244,7 +244,7 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen, struct udevice *bus = dev_get_parent(dev); struct xilinx_spi_priv *priv = dev_get_priv(bus); struct xilinx_spi_regs *regs = priv->regs; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); /* assume spi core configured to do 8 bit transfers */ unsigned int bytes = bitlen / XILSPI_MAX_XFER_BITS; const unsigned char *txp = dout; @@ -255,7 +255,7 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen, int ret; debug("spi_xfer: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", - bus->seq, slave_plat->cs, bitlen, bytes, flags); + dev_seq(bus), slave_plat->cs, bitlen, bytes, flags); if (bitlen == 0) goto done; @@ -364,6 +364,6 @@ U_BOOT_DRIVER(xilinx_spi) = { .id = UCLASS_SPI, .of_match = xilinx_spi_ids, .ops = &xilinx_spi_ops, - .priv_auto_alloc_size = sizeof(struct xilinx_spi_priv), + .priv_auto = sizeof(struct xilinx_spi_priv), .probe = xilinx_spi_probe, }; diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c index f2eddec950..845f2d2f5f 100644 --- a/drivers/spi/zynq_qspi.c +++ b/drivers/spi/zynq_qspi.c @@ -76,7 +76,7 @@ struct zynq_qspi_regs { }; /* zynq qspi platform data */ -struct zynq_qspi_platdata { +struct zynq_qspi_plat { struct zynq_qspi_regs *regs; u32 frequency; /* input frequency */ u32 speed_hz; @@ -98,9 +98,9 @@ struct zynq_qspi_priv { unsigned cs_change:1; }; -static int zynq_qspi_ofdata_to_platdata(struct udevice *bus) +static int zynq_qspi_of_to_plat(struct udevice *bus) { - struct zynq_qspi_platdata *plat = bus->platdata; + struct zynq_qspi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -171,7 +171,7 @@ static void zynq_qspi_init_hw(struct zynq_qspi_priv *priv) static int zynq_qspi_probe(struct udevice *bus) { - struct zynq_qspi_platdata *plat = dev_get_platdata(bus); + struct zynq_qspi_plat *plat = dev_get_plat(bus); struct zynq_qspi_priv *priv = dev_get_priv(bus); struct clk clk; unsigned long clock; @@ -560,7 +560,7 @@ static int zynq_qspi_xfer(struct udevice *dev, unsigned int bitlen, { struct udevice *bus = dev->parent; struct zynq_qspi_priv *priv = dev_get_priv(bus); - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); priv->cs = slave_plat->cs; priv->tx_buf = dout; @@ -568,7 +568,7 @@ static int zynq_qspi_xfer(struct udevice *dev, unsigned int bitlen, priv->len = bitlen / 8; debug("zynq_qspi_xfer: bus:%i cs:%i bitlen:%i len:%i flags:%lx\n", - bus->seq, slave_plat->cs, bitlen, priv->len, flags); + dev_seq(bus), slave_plat->cs, bitlen, priv->len, flags); /* * Festering sore. @@ -592,7 +592,7 @@ static int zynq_qspi_xfer(struct udevice *dev, unsigned int bitlen, static int zynq_qspi_set_speed(struct udevice *bus, uint speed) { - struct zynq_qspi_platdata *plat = bus->platdata; + struct zynq_qspi_plat *plat = dev_get_plat(bus); struct zynq_qspi_priv *priv = dev_get_priv(bus); struct zynq_qspi_regs *regs = priv->regs; uint32_t confr; @@ -666,8 +666,8 @@ U_BOOT_DRIVER(zynq_qspi) = { .id = UCLASS_SPI, .of_match = zynq_qspi_ids, .ops = &zynq_qspi_ops, - .ofdata_to_platdata = zynq_qspi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct zynq_qspi_platdata), - .priv_auto_alloc_size = sizeof(struct zynq_qspi_priv), + .of_to_plat = zynq_qspi_of_to_plat, + .plat_auto = sizeof(struct zynq_qspi_plat), + .priv_auto = sizeof(struct zynq_qspi_priv), .probe = zynq_qspi_probe, }; diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c index cb911c34f6..2971e55f41 100644 --- a/drivers/spi/zynq_spi.c +++ b/drivers/spi/zynq_spi.c @@ -55,7 +55,7 @@ struct zynq_spi_regs { /* zynq spi platform data */ -struct zynq_spi_platdata { +struct zynq_spi_plat { struct zynq_spi_regs *regs; u32 frequency; /* input frequency */ u32 speed_hz; @@ -73,9 +73,9 @@ struct zynq_spi_priv { u32 freq; /* required frequency */ }; -static int zynq_spi_ofdata_to_platdata(struct udevice *bus) +static int zynq_spi_of_to_plat(struct udevice *bus) { - struct zynq_spi_platdata *plat = bus->platdata; + struct zynq_spi_plat *plat = dev_get_plat(bus); const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); @@ -121,7 +121,7 @@ static void zynq_spi_init_hw(struct zynq_spi_priv *priv) static int zynq_spi_probe(struct udevice *bus) { - struct zynq_spi_platdata *plat = dev_get_platdata(bus); + struct zynq_spi_plat *plat = dev_get_plat(bus); struct zynq_spi_priv *priv = dev_get_priv(bus); struct clk clk; unsigned long clock; @@ -162,7 +162,7 @@ static int zynq_spi_probe(struct udevice *bus) static void spi_cs_activate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct zynq_spi_platdata *plat = bus->platdata; + struct zynq_spi_plat *plat = dev_get_plat(bus); struct zynq_spi_priv *priv = dev_get_priv(bus); struct zynq_spi_regs *regs = priv->regs; u32 cr; @@ -193,7 +193,7 @@ static void spi_cs_activate(struct udevice *dev) static void spi_cs_deactivate(struct udevice *dev) { struct udevice *bus = dev->parent; - struct zynq_spi_platdata *plat = bus->platdata; + struct zynq_spi_plat *plat = dev_get_plat(bus); struct zynq_spi_priv *priv = dev_get_priv(bus); struct zynq_spi_regs *regs = priv->regs; @@ -234,7 +234,7 @@ static int zynq_spi_xfer(struct udevice *dev, unsigned int bitlen, struct udevice *bus = dev->parent; struct zynq_spi_priv *priv = dev_get_priv(bus); struct zynq_spi_regs *regs = priv->regs; - struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); u32 len = bitlen / 8; u32 tx_len = len, rx_len = len, tx_tvl; const u8 *tx_buf = dout; @@ -242,7 +242,7 @@ static int zynq_spi_xfer(struct udevice *dev, unsigned int bitlen, u32 ts, status; debug("spi_xfer: bus:%i cs:%i bitlen:%i len:%i flags:%lx\n", - bus->seq, slave_plat->cs, bitlen, len, flags); + dev_seq(bus), slave_plat->cs, bitlen, len, flags); if (bitlen % 8) { debug("spi_xfer: Non byte aligned SPI transfer\n"); @@ -296,7 +296,7 @@ static int zynq_spi_xfer(struct udevice *dev, unsigned int bitlen, static int zynq_spi_set_speed(struct udevice *bus, uint speed) { - struct zynq_spi_platdata *plat = bus->platdata; + struct zynq_spi_plat *plat = dev_get_plat(bus); struct zynq_spi_priv *priv = dev_get_priv(bus); struct zynq_spi_regs *regs = priv->regs; uint32_t confr; @@ -371,8 +371,8 @@ U_BOOT_DRIVER(zynq_spi) = { .id = UCLASS_SPI, .of_match = zynq_spi_ids, .ops = &zynq_spi_ops, - .ofdata_to_platdata = zynq_spi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct zynq_spi_platdata), - .priv_auto_alloc_size = sizeof(struct zynq_spi_priv), + .of_to_plat = zynq_spi_of_to_plat, + .plat_auto = sizeof(struct zynq_spi_plat), + .priv_auto = sizeof(struct zynq_spi_priv), .probe = zynq_spi_probe, }; diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c index e0e6687037..efcbd0557f 100644 --- a/drivers/spi/zynqmp_gqspi.c +++ b/drivers/spi/zynqmp_gqspi.c @@ -156,7 +156,7 @@ struct zynqmp_qspi_dma_regs { DECLARE_GLOBAL_DATA_PTR; -struct zynqmp_qspi_platdata { +struct zynqmp_qspi_plat { struct zynqmp_qspi_regs *regs; struct zynqmp_qspi_dma_regs *dma_regs; u32 frequency; @@ -175,9 +175,9 @@ struct zynqmp_qspi_priv { unsigned int cs_change:1; }; -static int zynqmp_qspi_ofdata_to_platdata(struct udevice *bus) +static int zynqmp_qspi_of_to_plat(struct udevice *bus) { - struct zynqmp_qspi_platdata *plat = bus->platdata; + struct zynqmp_qspi_plat *plat = dev_get_plat(bus); debug("%s\n", __func__); @@ -255,7 +255,7 @@ static void zynqmp_qspi_chipselect(struct zynqmp_qspi_priv *priv, int is_on) void zynqmp_qspi_set_tapdelay(struct udevice *bus, u32 baudrateval) { - struct zynqmp_qspi_platdata *plat = bus->platdata; + struct zynqmp_qspi_plat *plat = dev_get_plat(bus); struct zynqmp_qspi_priv *priv = dev_get_priv(bus); struct zynqmp_qspi_regs *regs = priv->regs; u32 tapdlybypass = 0, lpbkdlyadj = 0, datadlyadj = 0, clk_rate; @@ -295,7 +295,7 @@ void zynqmp_qspi_set_tapdelay(struct udevice *bus, u32 baudrateval) static int zynqmp_qspi_set_speed(struct udevice *bus, uint speed) { - struct zynqmp_qspi_platdata *plat = bus->platdata; + struct zynqmp_qspi_plat *plat = dev_get_plat(bus); struct zynqmp_qspi_priv *priv = dev_get_priv(bus); struct zynqmp_qspi_regs *regs = priv->regs; u32 confr; @@ -333,7 +333,7 @@ static int zynqmp_qspi_set_speed(struct udevice *bus, uint speed) static int zynqmp_qspi_probe(struct udevice *bus) { - struct zynqmp_qspi_platdata *plat = dev_get_platdata(bus); + struct zynqmp_qspi_plat *plat = dev_get_plat(bus); struct zynqmp_qspi_priv *priv = dev_get_priv(bus); struct clk clk; unsigned long clock; @@ -429,10 +429,8 @@ static int zynqmp_qspi_fill_tx_fifo(struct zynqmp_qspi_priv *priv, u32 size) data |= GENMASK(31, 16); break; case 3: - data = *((u16 *)buf); - buf += 2; - data |= (*((u8 *)buf) << 16); - buf += 1; + data = *buf; + buf += 3; data |= GENMASK(31, 24); break; } @@ -727,8 +725,8 @@ U_BOOT_DRIVER(zynqmp_qspi) = { .id = UCLASS_SPI, .of_match = zynqmp_qspi_ids, .ops = &zynqmp_qspi_ops, - .ofdata_to_platdata = zynqmp_qspi_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct zynqmp_qspi_platdata), - .priv_auto_alloc_size = sizeof(struct zynqmp_qspi_priv), + .of_to_plat = zynqmp_qspi_of_to_plat, + .plat_auto = sizeof(struct zynqmp_qspi_plat), + .priv_auto = sizeof(struct zynqmp_qspi_priv), .probe = zynqmp_qspi_probe, }; diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 2f430aed9c..7f21443f6a 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -194,5 +194,5 @@ U_BOOT_DRIVER(msm_spmi) = { .of_match = msm_spmi_ids, .ops = &msm_spmi_ops, .probe = msm_spmi_probe, - .priv_auto_alloc_size = sizeof(struct msm_spmi_priv), + .priv_auto = sizeof(struct msm_spmi_priv), }; diff --git a/drivers/spmi/spmi-sandbox.c b/drivers/spmi/spmi-sandbox.c index 0da419c505..f6772946bc 100644 --- a/drivers/spmi/spmi-sandbox.c +++ b/drivers/spmi/spmi-sandbox.c @@ -151,5 +151,5 @@ U_BOOT_DRIVER(msm_spmi) = { .of_match = sandbox_spmi_ids, .ops = &sandbox_spmi_ops, .probe = sandbox_spmi_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_spmi_priv), + .priv_auto = sizeof(struct sandbox_spmi_priv), }; diff --git a/drivers/sysinfo/gazerbeam.c b/drivers/sysinfo/gazerbeam.c index 9e7a496655..c1fae6ccf2 100644 --- a/drivers/sysinfo/gazerbeam.c +++ b/drivers/sysinfo/gazerbeam.c @@ -260,6 +260,6 @@ U_BOOT_DRIVER(sysinfo_gazerbeam) = { .id = UCLASS_SYSINFO, .of_match = sysinfo_gazerbeam_ids, .ops = &sysinfo_gazerbeam_ops, - .priv_auto_alloc_size = sizeof(struct sysinfo_gazerbeam_priv), + .priv_auto = sizeof(struct sysinfo_gazerbeam_priv), .probe = sysinfo_gazerbeam_probe, }; diff --git a/drivers/sysinfo/sandbox.c b/drivers/sysinfo/sandbox.c index 62a1cb4ac6..d270a26aa4 100644 --- a/drivers/sysinfo/sandbox.c +++ b/drivers/sysinfo/sandbox.c @@ -102,6 +102,6 @@ U_BOOT_DRIVER(sysinfo_sandbox) = { .id = UCLASS_SYSINFO, .of_match = sysinfo_sandbox_ids, .ops = &sysinfo_sandbox_ops, - .priv_auto_alloc_size = sizeof(struct sysinfo_sandbox_priv), + .priv_auto = sizeof(struct sysinfo_sandbox_priv), .probe = sysinfo_sandbox_probe, }; diff --git a/drivers/sysreset/poweroff_gpio.c b/drivers/sysreset/poweroff_gpio.c index ac482c37f4..a5c24fd85b 100644 --- a/drivers/sysreset/poweroff_gpio.c +++ b/drivers/sysreset/poweroff_gpio.c @@ -87,6 +87,6 @@ U_BOOT_DRIVER(poweroff_gpio) = { .id = UCLASS_SYSRESET, .ops = &poweroff_gpio_ops, .probe = poweroff_gpio_probe, - .priv_auto_alloc_size = sizeof(struct poweroff_gpio_info), + .priv_auto = sizeof(struct poweroff_gpio_info), .of_match = poweroff_gpio_ids, }; diff --git a/drivers/sysreset/sysreset-ti-sci.c b/drivers/sysreset/sysreset-ti-sci.c index 7707c72bb5..81bfd67ad9 100644 --- a/drivers/sysreset/sysreset-ti-sci.c +++ b/drivers/sysreset/sysreset-ti-sci.c @@ -70,6 +70,6 @@ U_BOOT_DRIVER(ti_sci_sysreset) = { .id = UCLASS_SYSRESET, .of_match = ti_sci_sysreset_of_match, .probe = ti_sci_sysreset_probe, - .priv_auto_alloc_size = sizeof(struct ti_sci_sysreset_data), + .priv_auto = sizeof(struct ti_sci_sysreset_data), .ops = &ti_sci_sysreset_ops, }; diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index 3f5414ed1f..e69fb2255b 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -9,12 +9,13 @@ #include <common.h> #include <command.h> #include <cpu_func.h> -#include <hang.h> -#include <log.h> -#include <sysreset.h> #include <dm.h> #include <errno.h> +#include <hang.h> +#include <log.h> #include <regmap.h> +#include <spl.h> +#include <sysreset.h> #include <dm/device-internal.h> #include <dm/lists.h> #include <dm/root.h> @@ -101,7 +102,10 @@ void sysreset_walk_halt(enum sysreset_t type) mdelay(100); /* Still no reset? Give up */ - log_err("System reset not supported on this platform\n"); + if (spl_phase() <= PHASE_SPL) + log_err("no sysreset\n"); + else + log_err("System reset not supported on this platform\n"); hang(); } diff --git a/drivers/sysreset/sysreset_gpio.c b/drivers/sysreset/sysreset_gpio.c index d7280eeda8..680b759eb3 100644 --- a/drivers/sysreset/sysreset_gpio.c +++ b/drivers/sysreset/sysreset_gpio.c @@ -55,6 +55,6 @@ U_BOOT_DRIVER(gpio_reboot) = { .name = "gpio_restart", .of_match = led_gpio_ids, .ops = &gpio_reboot_ops, - .priv_auto_alloc_size = sizeof(struct gpio_reboot_priv), + .priv_auto = sizeof(struct gpio_reboot_priv), .probe = gpio_reboot_probe, }; diff --git a/drivers/sysreset/sysreset_octeon.c b/drivers/sysreset/sysreset_octeon.c index a05dac3226..ebdea6ab66 100644 --- a/drivers/sysreset/sysreset_octeon.c +++ b/drivers/sysreset/sysreset_octeon.c @@ -45,7 +45,7 @@ static const struct udevice_id octeon_sysreset_ids[] = { U_BOOT_DRIVER(sysreset_octeon) = { .id = UCLASS_SYSRESET, .name = "octeon_sysreset", - .priv_auto_alloc_size = sizeof(struct octeon_sysreset_data), + .priv_auto = sizeof(struct octeon_sysreset_data), .ops = &octeon_sysreset, .probe = octeon_sysreset_probe, .of_match = octeon_sysreset_ids, diff --git a/drivers/sysreset/sysreset_resetctl.c b/drivers/sysreset/sysreset_resetctl.c index b8203ba605..c039521eb4 100644 --- a/drivers/sysreset/sysreset_resetctl.c +++ b/drivers/sysreset/sysreset_resetctl.c @@ -43,6 +43,6 @@ U_BOOT_DRIVER(resetctl_reboot) = { .name = "resetctl_reboot", .of_match = resetctl_reboot_ids, .ops = &resetctl_reboot_ops, - .priv_auto_alloc_size = sizeof(struct resetctl_reboot_priv), + .priv_auto = sizeof(struct resetctl_reboot_priv), .probe = resetctl_reboot_probe, }; diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 7026a48c4b..08685823e9 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -47,10 +47,10 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) /* * If we have a device tree, the device we created from platform data - * (see the U_BOOT_DEVICE() declaration below) should not do anything. + * (see the U_BOOT_DRVINFO() declaration below) should not do anything. * If we are that device, return an error. */ - if (state->fdt_fname && !dev_of_valid(dev)) + if (state->fdt_fname && !dev_has_ofnode(dev)) return -ENODEV; switch (type) { @@ -135,7 +135,7 @@ U_BOOT_DRIVER(warm_sysreset_sandbox) = { #if !CONFIG_IS_ENABLED(OF_PLATDATA) /* This is here in case we don't have a device tree */ -U_BOOT_DEVICE(sysreset_sandbox_non_fdt) = { +U_BOOT_DRVINFO(sysreset_sandbox_non_fdt) = { .name = "sysreset_sandbox", }; #endif diff --git a/drivers/sysreset/sysreset_socfpga.c b/drivers/sysreset/sysreset_socfpga.c index 67cec6563a..e38296ac3f 100644 --- a/drivers/sysreset/sysreset_socfpga.c +++ b/drivers/sysreset/sysreset_socfpga.c @@ -51,7 +51,7 @@ static struct sysreset_ops socfpga_sysreset = { U_BOOT_DRIVER(sysreset_socfpga) = { .id = UCLASS_SYSRESET, .name = "socfpga_sysreset", - .priv_auto_alloc_size = sizeof(struct socfpga_sysreset_data), + .priv_auto = sizeof(struct socfpga_sysreset_data), .ops = &socfpga_sysreset, .probe = socfpga_sysreset_probe, }; diff --git a/drivers/sysreset/sysreset_sti.c b/drivers/sysreset/sysreset_sti.c index 43e161c65d..29e88dbcd1 100644 --- a/drivers/sysreset/sysreset_sti.c +++ b/drivers/sysreset/sysreset_sti.c @@ -79,5 +79,5 @@ U_BOOT_DRIVER(sysreset_sti) = { .ops = &sti_sysreset, .probe = sti_sysreset_probe, .of_match = sti_sysreset_ids, - .priv_auto_alloc_size = sizeof(struct sti_sysreset_priv), + .priv_auto = sizeof(struct sti_sysreset_priv), }; diff --git a/drivers/sysreset/sysreset_syscon.c b/drivers/sysreset/sysreset_syscon.c index 1c47486614..28fdfb0978 100644 --- a/drivers/sysreset/sysreset_syscon.c +++ b/drivers/sysreset/sysreset_syscon.c @@ -87,6 +87,6 @@ U_BOOT_DRIVER(syscon_reboot) = { .id = UCLASS_SYSRESET, .of_match = syscon_reboot_ids, .probe = syscon_reboot_probe, - .priv_auto_alloc_size = sizeof(struct syscon_reboot_priv), + .priv_auto = sizeof(struct syscon_reboot_priv), .ops = &syscon_reboot_ops, }; diff --git a/drivers/sysreset/sysreset_watchdog.c b/drivers/sysreset/sysreset_watchdog.c index d500d41326..0dc2d8b9b6 100644 --- a/drivers/sysreset/sysreset_watchdog.c +++ b/drivers/sysreset/sysreset_watchdog.c @@ -54,6 +54,6 @@ U_BOOT_DRIVER(wdt_reboot) = { .id = UCLASS_SYSRESET, .of_match = wdt_reboot_ids, .ops = &wdt_reboot_ops, - .priv_auto_alloc_size = sizeof(struct wdt_reboot_priv), + .priv_auto = sizeof(struct wdt_reboot_priv), .probe = wdt_reboot_probe, }; diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c index 7682ffbd29..8042f3994f 100644 --- a/drivers/sysreset/sysreset_x86.c +++ b/drivers/sysreset/sysreset_x86.c @@ -13,10 +13,7 @@ #include <acpi/acpi_s3.h> #include <asm/io.h> #include <asm/processor.h> - -struct x86_sysreset_platdata { - struct udevice *pch; -}; +#include <asm/sysreset.h> /* * Power down the machine by using the power management sleep control @@ -30,7 +27,7 @@ struct x86_sysreset_platdata { */ int pch_sysreset_power_off(struct udevice *dev) { - struct x86_sysreset_platdata *plat = dev_get_platdata(dev); + struct x86_sysreset_plat *plat = dev_get_plat(dev); struct pch_pmbase_info pm; u32 reg32; int ret; @@ -130,7 +127,7 @@ void __efi_runtime EFIAPI efi_reset_system( static int x86_sysreset_probe(struct udevice *dev) { - struct x86_sysreset_platdata *plat = dev_get_platdata(dev); + struct x86_sysreset_plat *plat = dev_get_plat(dev); /* Locate the PCH if there is one. It isn't essential */ uclass_first_device(UCLASS_PCH, &plat->pch); @@ -154,5 +151,5 @@ U_BOOT_DRIVER(x86_reset) = { .of_match = x86_sysreset_ids, .ops = &x86_sysreset_ops, .probe = x86_sysreset_probe, - .platdata_auto_alloc_size = sizeof(struct x86_sysreset_platdata), + .plat_auto = sizeof(struct x86_sysreset_plat), }; diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 66ade37cd4..b898c32edc 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -297,7 +297,7 @@ static u32 call_err_to_res(u32 call_err) static u32 do_call_with_arg(struct udevice *dev, struct optee_msg_arg *arg) { - struct optee_pdata *pdata = dev_get_platdata(dev); + struct optee_pdata *pdata = dev_get_plat(dev); struct rpc_param param = { .a0 = OPTEE_SMC_CALL_WITH_ARG }; void *page_list = NULL; @@ -592,7 +592,7 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev) const char *method; debug("optee: looking for conduit method in DT.\n"); - method = ofnode_get_property(dev->node, "method", NULL); + method = ofnode_get_property(dev_ofnode(dev), "method", NULL); if (!method) { debug("optee: missing \"method\" property\n"); return ERR_PTR(-ENXIO); @@ -607,9 +607,9 @@ static optee_invoke_fn *get_invoke_func(struct udevice *dev) return ERR_PTR(-EINVAL); } -static int optee_ofdata_to_platdata(struct udevice *dev) +static int optee_of_to_plat(struct udevice *dev) { - struct optee_pdata *pdata = dev_get_platdata(dev); + struct optee_pdata *pdata = dev_get_plat(dev); pdata->invoke_fn = get_invoke_func(dev); if (IS_ERR(pdata->invoke_fn)) @@ -620,7 +620,7 @@ static int optee_ofdata_to_platdata(struct udevice *dev) static int optee_probe(struct udevice *dev) { - struct optee_pdata *pdata = dev_get_platdata(dev); + struct optee_pdata *pdata = dev_get_plat(dev); u32 sec_caps; if (!is_optee_api(pdata->invoke_fn)) { @@ -658,9 +658,9 @@ U_BOOT_DRIVER(optee) = { .name = "optee", .id = UCLASS_TEE, .of_match = optee_match, - .ofdata_to_platdata = optee_ofdata_to_platdata, + .of_to_plat = optee_of_to_plat, .probe = optee_probe, .ops = &optee_ops, - .platdata_auto_alloc_size = sizeof(struct optee_pdata), - .priv_auto_alloc_size = sizeof(struct optee_private), + .plat_auto = sizeof(struct optee_pdata), + .priv_auto = sizeof(struct optee_private), }; diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c index 4b91e7db1b..e1ba027fd6 100644 --- a/drivers/tee/sandbox.c +++ b/drivers/tee/sandbox.c @@ -385,7 +385,7 @@ U_BOOT_DRIVER(sandbox_tee) = { .id = UCLASS_TEE, .of_match = sandbox_tee_match, .ops = &sandbox_tee_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_tee_state), + .priv_auto = sizeof(struct sandbox_tee_state), .probe = sandbox_tee_probe, .remove = sandbox_tee_remove, }; diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c index 112e216883..2cc6b6c407 100644 --- a/drivers/tee/tee-uclass.c +++ b/drivers/tee/tee-uclass.c @@ -205,7 +205,7 @@ static int tee_pre_remove(struct udevice *dev) UCLASS_DRIVER(tee) = { .id = UCLASS_TEE, .name = "tee", - .per_device_auto_alloc_size = sizeof(struct tee_uclass_priv), + .per_device_auto = sizeof(struct tee_uclass_priv), .pre_probe = tee_pre_probe, .pre_remove = tee_pre_remove, }; diff --git a/drivers/thermal/imx_scu_thermal.c b/drivers/thermal/imx_scu_thermal.c index 83ec753802..b785be7bd0 100644 --- a/drivers/thermal/imx_scu_thermal.c +++ b/drivers/thermal/imx_scu_thermal.c @@ -33,7 +33,7 @@ static int read_temperature(struct udevice *dev, int *temp) sc_rsrc_t *sensor_rsrc = (sc_rsrc_t *)dev_get_driver_data(dev); - struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); + struct imx_sc_thermal_plat *pdata = dev_get_plat(dev); if (!temp) return -EINVAL; @@ -52,7 +52,7 @@ static int read_temperature(struct udevice *dev, int *temp) int imx_sc_thermal_get_temp(struct udevice *dev, int *temp) { - struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); + struct imx_sc_thermal_plat *pdata = dev_get_plat(dev); int cpu_temp = 0; int ret; @@ -89,7 +89,7 @@ static int imx_sc_thermal_probe(struct udevice *dev) static int imx_sc_thermal_bind(struct udevice *dev) { - struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); + struct imx_sc_thermal_plat *pdata = dev_get_plat(dev); int reg, ret; int offset; const char *name; @@ -126,9 +126,9 @@ static int imx_sc_thermal_bind(struct udevice *dev) return 0; } -static int imx_sc_thermal_ofdata_to_platdata(struct udevice *dev) +static int imx_sc_thermal_of_to_plat(struct udevice *dev) { - struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev); + struct imx_sc_thermal_plat *pdata = dev_get_plat(dev); struct fdtdec_phandle_args args; const char *type; int ret; @@ -210,7 +210,7 @@ U_BOOT_DRIVER(imx_sc_thermal) = { .of_match = imx_sc_thermal_ids, .bind = imx_sc_thermal_bind, .probe = imx_sc_thermal_probe, - .ofdata_to_platdata = imx_sc_thermal_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct imx_sc_thermal_plat), + .of_to_plat = imx_sc_thermal_of_to_plat, + .plat_auto = sizeof(struct imx_sc_thermal_plat), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 101bd5ef2d..2f6343e7a1 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -52,7 +52,7 @@ static int read_cpu_temperature(struct udevice *dev) { int temperature; unsigned int reg, n_meas; - const struct imx_thermal_plat *pdata = dev_get_platdata(dev); + const struct imx_thermal_plat *pdata = dev_get_plat(dev); struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; struct thermal_data *priv = dev_get_priv(dev); u32 fuse = priv->fuse; @@ -237,7 +237,7 @@ static int imx_thermal_probe(struct udevice *dev) { unsigned int fuse = ~0; - const struct imx_thermal_plat *pdata = dev_get_platdata(dev); + const struct imx_thermal_plat *pdata = dev_get_plat(dev); struct thermal_data *priv = dev_get_priv(dev); /* Read Temperature calibration data fuse */ @@ -274,6 +274,6 @@ U_BOOT_DRIVER(imx_thermal) = { .id = UCLASS_THERMAL, .ops = &imx_thermal_ops, .probe = imx_thermal_probe, - .priv_auto_alloc_size = sizeof(struct thermal_data), + .priv_auto = sizeof(struct thermal_data), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/thermal/imx_tmu.c b/drivers/thermal/imx_tmu.c index 936068c6cb..1bd0340410 100644 --- a/drivers/thermal/imx_tmu.c +++ b/drivers/thermal/imx_tmu.c @@ -126,7 +126,7 @@ struct imx_tmu_plat { static int read_temperature(struct udevice *dev, int *temp) { - struct imx_tmu_plat *pdata = dev_get_platdata(dev); + struct imx_tmu_plat *pdata = dev_get_plat(dev); ulong drv_data = dev_get_driver_data(dev); u32 val; u32 retry = 10; @@ -175,7 +175,7 @@ static int read_temperature(struct udevice *dev, int *temp) int imx_tmu_get_temp(struct udevice *dev, int *temp) { - struct imx_tmu_plat *pdata = dev_get_platdata(dev); + struct imx_tmu_plat *pdata = dev_get_plat(dev); int cpu_tmp = 0; int ret; @@ -206,7 +206,7 @@ static int imx_tmu_calibration(struct udevice *dev) int i, val, len, ret; u32 range[4]; const fdt32_t *calibration; - struct imx_tmu_plat *pdata = dev_get_platdata(dev); + struct imx_tmu_plat *pdata = dev_get_plat(dev); ulong drv_data = dev_get_driver_data(dev); debug("%s\n", __func__); @@ -248,7 +248,7 @@ void __weak imx_tmu_arch_init(void *reg_base) static void imx_tmu_init(struct udevice *dev) { - struct imx_tmu_plat *pdata = dev_get_platdata(dev); + struct imx_tmu_plat *pdata = dev_get_plat(dev); ulong drv_data = dev_get_driver_data(dev); debug("%s\n", __func__); @@ -282,7 +282,7 @@ static void imx_tmu_init(struct udevice *dev) static int imx_tmu_enable_msite(struct udevice *dev) { - struct imx_tmu_plat *pdata = dev_get_platdata(dev); + struct imx_tmu_plat *pdata = dev_get_plat(dev); ulong drv_data = dev_get_driver_data(dev); u32 reg; @@ -338,7 +338,7 @@ static int imx_tmu_enable_msite(struct udevice *dev) static int imx_tmu_bind(struct udevice *dev) { - struct imx_tmu_plat *pdata = dev_get_platdata(dev); + struct imx_tmu_plat *pdata = dev_get_plat(dev); int ret; ofnode node, offset; const char *name; @@ -370,7 +370,7 @@ static int imx_tmu_bind(struct udevice *dev) static int imx_tmu_parse_fdt(struct udevice *dev) { - struct imx_tmu_plat *pdata = dev_get_platdata(dev), *p_parent_data; + struct imx_tmu_plat *pdata = dev_get_plat(dev), *p_parent_data; struct ofnode_phandle_args args; ofnode trips_np; int ret; @@ -385,7 +385,7 @@ static int imx_tmu_parse_fdt(struct udevice *dev) return 0; } - p_parent_data = dev_get_platdata(dev->parent); + p_parent_data = dev_get_plat(dev->parent); if (p_parent_data->zone_node) pdata->regs = p_parent_data->regs; @@ -430,7 +430,7 @@ static int imx_tmu_parse_fdt(struct udevice *dev) static int imx_tmu_probe(struct udevice *dev) { - struct imx_tmu_plat *pdata = dev_get_platdata(dev); + struct imx_tmu_plat *pdata = dev_get_plat(dev); int ret; ret = imx_tmu_parse_fdt(dev); @@ -463,6 +463,6 @@ U_BOOT_DRIVER(imx_tmu) = { .of_match = imx_tmu_ids, .bind = imx_tmu_bind, .probe = imx_tmu_probe, - .platdata_auto_alloc_size = sizeof(struct imx_tmu_plat), + .plat_auto = sizeof(struct imx_tmu_plat), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/thermal/ti-bandgap.c b/drivers/thermal/ti-bandgap.c index 8b332f116c..0b533d4c42 100644 --- a/drivers/thermal/ti-bandgap.c +++ b/drivers/thermal/ti-bandgap.c @@ -194,5 +194,5 @@ U_BOOT_DRIVER(ti_bandgap_thermal) = { .ops = &ti_thermal_ops, .probe = ti_bandgap_probe, .of_match = of_ti_bandgap_match, - .priv_auto_alloc_size = sizeof(struct ti_bandgap), + .priv_auto = sizeof(struct ti_bandgap), }; diff --git a/drivers/timer/ag101p_timer.c b/drivers/timer/ag101p_timer.c index 23ad5b2b67..27cf9b0247 100644 --- a/drivers/timer/ag101p_timer.c +++ b/drivers/timer/ag101p_timer.c @@ -58,13 +58,13 @@ struct atftmr_timer_regs { u32 int_mask; /* 0x38 */ }; -struct atftmr_timer_platdata { +struct atftmr_timer_plat { struct atftmr_timer_regs *regs; }; static u64 atftmr_timer_get_count(struct udevice *dev) { - struct atftmr_timer_platdata *plat = dev->platdata; + struct atftmr_timer_plat *plat = dev_get_plat(dev); struct atftmr_timer_regs *const regs = plat->regs; u32 val; val = readl(®s->t3_counter); @@ -73,7 +73,7 @@ static u64 atftmr_timer_get_count(struct udevice *dev) static int atftmr_timer_probe(struct udevice *dev) { - struct atftmr_timer_platdata *plat = dev->platdata; + struct atftmr_timer_plat *plat = dev_get_plat(dev); struct atftmr_timer_regs *const regs = plat->regs; u32 cr; writel(0, ®s->t3_load); @@ -88,9 +88,9 @@ static int atftmr_timer_probe(struct udevice *dev) return 0; } -static int atftme_timer_ofdata_to_platdata(struct udevice *dev) +static int atftme_timer_of_to_plat(struct udevice *dev) { - struct atftmr_timer_platdata *plat = dev_get_platdata(dev); + struct atftmr_timer_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct atftmr_timer_regs), MAP_NOCACHE); @@ -110,8 +110,8 @@ U_BOOT_DRIVER(altera_timer) = { .name = "ag101p_timer", .id = UCLASS_TIMER, .of_match = ag101p_timer_ids, - .ofdata_to_platdata = atftme_timer_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct atftmr_timer_platdata), + .of_to_plat = atftme_timer_of_to_plat, + .plat_auto = sizeof(struct atftmr_timer_plat), .probe = atftmr_timer_probe, .ops = &ag101p_timer_ops, }; diff --git a/drivers/timer/altera_timer.c b/drivers/timer/altera_timer.c index ccc164ee17..040dc65f48 100644 --- a/drivers/timer/altera_timer.c +++ b/drivers/timer/altera_timer.c @@ -28,13 +28,13 @@ struct altera_timer_regs { u32 snaph; /* Snapshot high */ }; -struct altera_timer_platdata { +struct altera_timer_plat { struct altera_timer_regs *regs; }; static u64 altera_timer_get_count(struct udevice *dev) { - struct altera_timer_platdata *plat = dev->platdata; + struct altera_timer_plat *plat = dev_get_plat(dev); struct altera_timer_regs *const regs = plat->regs; u32 val; @@ -49,7 +49,7 @@ static u64 altera_timer_get_count(struct udevice *dev) static int altera_timer_probe(struct udevice *dev) { - struct altera_timer_platdata *plat = dev->platdata; + struct altera_timer_plat *plat = dev_get_plat(dev); struct altera_timer_regs *const regs = plat->regs; writel(0, ®s->status); @@ -63,9 +63,9 @@ static int altera_timer_probe(struct udevice *dev) return 0; } -static int altera_timer_ofdata_to_platdata(struct udevice *dev) +static int altera_timer_of_to_plat(struct udevice *dev) { - struct altera_timer_platdata *plat = dev_get_platdata(dev); + struct altera_timer_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_timer_regs), @@ -87,8 +87,8 @@ U_BOOT_DRIVER(altera_timer) = { .name = "altera_timer", .id = UCLASS_TIMER, .of_match = altera_timer_ids, - .ofdata_to_platdata = altera_timer_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct altera_timer_platdata), + .of_to_plat = altera_timer_of_to_plat, + .plat_auto = sizeof(struct altera_timer_plat), .probe = altera_timer_probe, .ops = &altera_timer_ops, }; diff --git a/drivers/timer/andes_plmt_timer.c b/drivers/timer/andes_plmt_timer.c index cec86718c7..db2cf86f63 100644 --- a/drivers/timer/andes_plmt_timer.c +++ b/drivers/timer/andes_plmt_timer.c @@ -12,6 +12,7 @@ #include <dm.h> #include <timer.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <linux/err.h> /* mtime register */ @@ -19,7 +20,7 @@ static u64 andes_plmt_get_count(struct udevice *dev) { - return readq((void __iomem *)MTIME_REG(dev->priv)); + return readq((void __iomem *)MTIME_REG(dev_get_priv(dev))); } static const struct timer_ops andes_plmt_ops = { @@ -28,8 +29,8 @@ static const struct timer_ops andes_plmt_ops = { static int andes_plmt_probe(struct udevice *dev) { - dev->priv = dev_read_addr_ptr(dev); - if (!dev->priv) + dev_set_priv(dev, dev_read_addr_ptr(dev)); + if (!dev_get_priv(dev)) return -EINVAL; return timer_timebase_fallback(dev); diff --git a/drivers/timer/arc_timer.c b/drivers/timer/arc_timer.c index 2dea9f40cb..904950457c 100644 --- a/drivers/timer/arc_timer.c +++ b/drivers/timer/arc_timer.c @@ -105,5 +105,5 @@ U_BOOT_DRIVER(arc_timer) = { .of_match = arc_timer_ids, .probe = arc_timer_probe, .ops = &arc_timer_ops, - .priv_auto_alloc_size = sizeof(struct arc_timer_priv), + .priv_auto = sizeof(struct arc_timer_priv), }; diff --git a/drivers/timer/ast_timer.c b/drivers/timer/ast_timer.c index 35369a4087..78adc96cc5 100644 --- a/drivers/timer/ast_timer.c +++ b/drivers/timer/ast_timer.c @@ -58,7 +58,7 @@ static u64 ast_timer_get_count(struct udevice *dev) return AST_TMC_RELOAD_VAL - readl(&priv->tmc->status); } -static int ast_timer_ofdata_to_platdata(struct udevice *dev) +static int ast_timer_of_to_plat(struct udevice *dev) { struct ast_timer_priv *priv = dev_get_priv(dev); @@ -86,7 +86,7 @@ U_BOOT_DRIVER(ast_timer) = { .id = UCLASS_TIMER, .of_match = ast_timer_ids, .probe = ast_timer_probe, - .priv_auto_alloc_size = sizeof(struct ast_timer_priv), - .ofdata_to_platdata = ast_timer_ofdata_to_platdata, + .priv_auto = sizeof(struct ast_timer_priv), + .of_to_plat = ast_timer_of_to_plat, .ops = &ast_timer_ops, }; diff --git a/drivers/timer/atcpit100_timer.c b/drivers/timer/atcpit100_timer.c index fcb8a45358..fbc7fac1bb 100644 --- a/drivers/timer/atcpit100_timer.c +++ b/drivers/timer/atcpit100_timer.c @@ -64,13 +64,13 @@ struct atctmr_timer_regs { u32 int_mask; /* 0x38 */ }; -struct atcpit_timer_platdata { +struct atcpit_timer_plat { u32 *regs; }; static u64 atcpit_timer_get_count(struct udevice *dev) { - struct atcpit_timer_platdata *plat = dev_get_platdata(dev); + struct atcpit_timer_plat *plat = dev_get_plat(dev); u32 val; val = ~(REG32_TMR(CH_CNT(1))+0xffffffff); return timer_conv_64(val); @@ -78,16 +78,16 @@ static u64 atcpit_timer_get_count(struct udevice *dev) static int atcpit_timer_probe(struct udevice *dev) { - struct atcpit_timer_platdata *plat = dev_get_platdata(dev); + struct atcpit_timer_plat *plat = dev_get_plat(dev); REG32_TMR(CH_REL(1)) = 0xffffffff; REG32_TMR(CH_CTL(1)) = APB_CLK|TMR_32; REG32_TMR(CH_EN) |= CH_TMR_EN(1 , 0); return 0; } -static int atcpit_timer_ofdata_to_platdata(struct udevice *dev) +static int atcpit_timer_of_to_plat(struct udevice *dev) { - struct atcpit_timer_platdata *plat = dev_get_platdata(dev); + struct atcpit_timer_plat *plat = dev_get_plat(dev); plat->regs = map_physmem(dev_read_addr(dev), 0x100 , MAP_NOCACHE); return 0; } @@ -105,8 +105,8 @@ U_BOOT_DRIVER(atcpit100_timer) = { .name = "atcpit100_timer", .id = UCLASS_TIMER, .of_match = atcpit_timer_ids, - .ofdata_to_platdata = atcpit_timer_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct atcpit_timer_platdata), + .of_to_plat = atcpit_timer_of_to_plat, + .plat_auto = sizeof(struct atcpit_timer_plat), .probe = atcpit_timer_probe, .ops = &atcpit_timer_ops, }; diff --git a/drivers/timer/atmel_pit_timer.c b/drivers/timer/atmel_pit_timer.c index 9f0ad1d703..3178e58884 100644 --- a/drivers/timer/atmel_pit_timer.c +++ b/drivers/timer/atmel_pit_timer.c @@ -21,13 +21,13 @@ struct atmel_pit_regs { u32 value_image; }; -struct atmel_pit_platdata { +struct atmel_pit_plat { struct atmel_pit_regs *regs; }; static u64 atmel_pit_get_count(struct udevice *dev) { - struct atmel_pit_platdata *plat = dev_get_platdata(dev); + struct atmel_pit_plat *plat = dev_get_plat(dev); struct atmel_pit_regs *const regs = plat->regs; u32 val = readl(®s->value_image); @@ -36,7 +36,7 @@ static u64 atmel_pit_get_count(struct udevice *dev) static int atmel_pit_probe(struct udevice *dev) { - struct atmel_pit_platdata *plat = dev_get_platdata(dev); + struct atmel_pit_plat *plat = dev_get_plat(dev); struct atmel_pit_regs *const regs = plat->regs; struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct clk clk; @@ -58,9 +58,9 @@ static int atmel_pit_probe(struct udevice *dev) return 0; } -static int atmel_pit_ofdata_to_platdata(struct udevice *dev) +static int atmel_pit_of_to_plat(struct udevice *dev) { - struct atmel_pit_platdata *plat = dev_get_platdata(dev); + struct atmel_pit_plat *plat = dev_get_plat(dev); plat->regs = dev_read_addr_ptr(dev); @@ -80,8 +80,8 @@ U_BOOT_DRIVER(atmel_pit) = { .name = "atmel_pit", .id = UCLASS_TIMER, .of_match = atmel_pit_ids, - .ofdata_to_platdata = atmel_pit_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct atmel_pit_platdata), + .of_to_plat = atmel_pit_of_to_plat, + .plat_auto = sizeof(struct atmel_pit_plat), .probe = atmel_pit_probe, .ops = &atmel_pit_ops, }; diff --git a/drivers/timer/cadence-ttc.c b/drivers/timer/cadence-ttc.c index bebb2c2e90..3cac2ec422 100644 --- a/drivers/timer/cadence-ttc.c +++ b/drivers/timer/cadence-ttc.c @@ -84,7 +84,7 @@ static int cadence_ttc_probe(struct udevice *dev) return 0; } -static int cadence_ttc_ofdata_to_platdata(struct udevice *dev) +static int cadence_ttc_of_to_plat(struct udevice *dev) { struct cadence_ttc_priv *priv = dev_get_priv(dev); @@ -109,8 +109,8 @@ U_BOOT_DRIVER(cadence_ttc) = { .name = "cadence_ttc", .id = UCLASS_TIMER, .of_match = cadence_ttc_ids, - .ofdata_to_platdata = cadence_ttc_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct cadence_ttc_priv), + .of_to_plat = cadence_ttc_of_to_plat, + .priv_auto = sizeof(struct cadence_ttc_priv), .probe = cadence_ttc_probe, .ops = &cadence_ttc_ops, }; diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c index 68bc258131..9aed5dd217 100644 --- a/drivers/timer/dw-apb-timer.c +++ b/drivers/timer/dw-apb-timer.c @@ -66,7 +66,7 @@ static int dw_apb_timer_probe(struct udevice *dev) return 0; } -static int dw_apb_timer_ofdata_to_platdata(struct udevice *dev) +static int dw_apb_timer_of_to_plat(struct udevice *dev) { struct dw_apb_timer_priv *priv = dev_get_priv(dev); @@ -97,7 +97,7 @@ U_BOOT_DRIVER(dw_apb_timer) = { .ops = &dw_apb_timer_ops, .probe = dw_apb_timer_probe, .of_match = dw_apb_timer_ids, - .ofdata_to_platdata = dw_apb_timer_ofdata_to_platdata, + .of_to_plat = dw_apb_timer_of_to_plat, .remove = dw_apb_timer_remove, - .priv_auto_alloc_size = sizeof(struct dw_apb_timer_priv), + .priv_auto = sizeof(struct dw_apb_timer_priv), }; diff --git a/drivers/timer/mchp-pit64b-timer.c b/drivers/timer/mchp-pit64b-timer.c index ad962098b3..c9806d7eee 100644 --- a/drivers/timer/mchp-pit64b-timer.c +++ b/drivers/timer/mchp-pit64b-timer.c @@ -100,7 +100,7 @@ U_BOOT_DRIVER(mchp_pit64b) = { .name = "mchp-pit64b", .id = UCLASS_TIMER, .of_match = mchp_pit64b_ids, - .priv_auto_alloc_size = sizeof(struct mchp_pit64b_priv), + .priv_auto = sizeof(struct mchp_pit64b_priv), .probe = mchp_pit64b_probe, .ops = &mchp_pit64b_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c index 6139252a73..2f2b8be3dc 100644 --- a/drivers/timer/mpc83xx_timer.c +++ b/drivers/timer/mpc83xx_timer.c @@ -206,7 +206,7 @@ static u64 mpc83xx_timer_get_count(struct udevice *dev) static int mpc83xx_timer_probe(struct udevice *dev) { - struct timer_dev_priv *uc_priv = dev->uclass_priv; + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct clk clock; int ret; @@ -244,5 +244,5 @@ U_BOOT_DRIVER(mpc83xx_timer) = { .of_match = mpc83xx_timer_ids, .probe = mpc83xx_timer_probe, .ops = &mpc83xx_timer_ops, - .priv_auto_alloc_size = sizeof(struct mpc83xx_timer_priv), + .priv_auto = sizeof(struct mpc83xx_timer_priv), }; diff --git a/drivers/timer/mtk_timer.c b/drivers/timer/mtk_timer.c index 74e9ea34ff..448a76a7e1 100644 --- a/drivers/timer/mtk_timer.c +++ b/drivers/timer/mtk_timer.c @@ -78,7 +78,7 @@ U_BOOT_DRIVER(mtk_timer) = { .name = "mtk_timer", .id = UCLASS_TIMER, .of_match = mtk_timer_ids, - .priv_auto_alloc_size = sizeof(struct mtk_timer_priv), + .priv_auto = sizeof(struct mtk_timer_priv), .probe = mtk_timer_probe, .ops = &mtk_timer_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/timer/nomadik-mtu-timer.c b/drivers/timer/nomadik-mtu-timer.c index d7f7ca4eff..417b419d46 100644 --- a/drivers/timer/nomadik-mtu-timer.c +++ b/drivers/timer/nomadik-mtu-timer.c @@ -107,7 +107,7 @@ U_BOOT_DRIVER(nomadik_mtu) = { .name = "nomadik_mtu", .id = UCLASS_TIMER, .of_match = nomadik_mtu_ids, - .priv_auto_alloc_size = sizeof(struct nomadik_mtu_priv), + .priv_auto = sizeof(struct nomadik_mtu_priv), .probe = nomadik_mtu_probe, .ops = &nomadik_mtu_ops, }; diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c index 4eecb3e64d..721e385fd1 100644 --- a/drivers/timer/omap-timer.c +++ b/drivers/timer/omap-timer.c @@ -19,8 +19,6 @@ #define TCLR_PRE_EN BIT(5) /* Pre-scaler enable */ #define TCLR_PTV_SHIFT (2) /* Pre-scaler shift value */ -#define TIMER_CLOCK (V_SCLK / (2 << CONFIG_SYS_PTV)) - struct omap_gptimer_regs { unsigned int tidr; /* offset 0x00 */ unsigned char res1[12]; @@ -61,7 +59,9 @@ static int omap_timer_probe(struct udevice *dev) struct omap_timer_priv *priv = dev_get_priv(dev); if (!uc_priv->clock_rate) - uc_priv->clock_rate = TIMER_CLOCK; + uc_priv->clock_rate = V_SCLK; + + uc_priv->clock_rate /= (2 << CONFIG_SYS_PTV); /* start the counter ticking up, reload value on overflow */ writel(0, &priv->regs->tldr); @@ -73,7 +73,7 @@ static int omap_timer_probe(struct udevice *dev) return 0; } -static int omap_timer_ofdata_to_platdata(struct udevice *dev) +static int omap_timer_of_to_plat(struct udevice *dev) { struct omap_timer_priv *priv = dev_get_priv(dev); @@ -99,8 +99,8 @@ U_BOOT_DRIVER(omap_timer) = { .name = "omap_timer", .id = UCLASS_TIMER, .of_match = omap_timer_ids, - .ofdata_to_platdata = omap_timer_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct omap_timer_priv), + .of_to_plat = omap_timer_of_to_plat, + .priv_auto = sizeof(struct omap_timer_priv), .probe = omap_timer_probe, .ops = &omap_timer_ops, }; diff --git a/drivers/timer/ostm_timer.c b/drivers/timer/ostm_timer.c index bb0636a071..99bd36f9f2 100644 --- a/drivers/timer/ostm_timer.c +++ b/drivers/timer/ostm_timer.c @@ -63,7 +63,7 @@ static int ostm_probe(struct udevice *dev) return 0; } -static int ostm_ofdata_to_platdata(struct udevice *dev) +static int ostm_of_to_plat(struct udevice *dev) { struct ostm_priv *priv = dev_get_priv(dev); @@ -87,6 +87,6 @@ U_BOOT_DRIVER(ostm_timer) = { .ops = &ostm_ops, .probe = ostm_probe, .of_match = ostm_ids, - .ofdata_to_platdata = ostm_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct ostm_priv), + .of_to_plat = ostm_of_to_plat, + .priv_auto = sizeof(struct ostm_priv), }; diff --git a/drivers/timer/rockchip_timer.c b/drivers/timer/rockchip_timer.c index 53cdf09810..8d3eceb8d8 100644 --- a/drivers/timer/rockchip_timer.c +++ b/drivers/timer/rockchip_timer.c @@ -97,7 +97,7 @@ static u64 rockchip_timer_get_count(struct udevice *dev) return ~0ull - cntr; } -static int rockchip_clk_ofdata_to_platdata(struct udevice *dev) +static int rockchip_clk_of_to_plat(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct rockchip_timer_priv *priv = dev_get_priv(dev); @@ -139,7 +139,7 @@ static int rockchip_timer_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_PLATDATA) struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct rockchip_timer_priv *priv = dev_get_priv(dev); - struct rockchip_timer_plat *plat = dev_get_platdata(dev); + struct rockchip_timer_plat *plat = dev_get_plat(dev); priv->timer = map_sysmem(plat->dtd.reg[0], plat->dtd.reg[1]); uc_priv->clock_rate = plat->dtd.clock_frequency; @@ -165,9 +165,9 @@ U_BOOT_DRIVER(rockchip_rk3368_timer) = { .of_match = rockchip_timer_ids, .probe = rockchip_timer_probe, .ops = &rockchip_timer_ops, - .priv_auto_alloc_size = sizeof(struct rockchip_timer_priv), + .priv_auto = sizeof(struct rockchip_timer_priv), #if CONFIG_IS_ENABLED(OF_PLATDATA) - .platdata_auto_alloc_size = sizeof(struct rockchip_timer_plat), + .plat_auto = sizeof(struct rockchip_timer_plat), #endif - .ofdata_to_platdata = rockchip_clk_ofdata_to_platdata, + .of_to_plat = rockchip_clk_of_to_plat, }; diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c index 135c0f38a4..2075cd4edd 100644 --- a/drivers/timer/sandbox_timer.c +++ b/drivers/timer/sandbox_timer.c @@ -65,6 +65,6 @@ U_BOOT_DRIVER(sandbox_timer) = { }; /* This is here in case we don't have a device tree */ -U_BOOT_DEVICE(sandbox_timer_non_fdt) = { +U_BOOT_DRVINFO(sandbox_timer_non_fdt) = { .name = "sandbox_timer", }; diff --git a/drivers/timer/sifive_clint_timer.c b/drivers/timer/sifive_clint_timer.c index 00ce0f08d6..de23b85404 100644 --- a/drivers/timer/sifive_clint_timer.c +++ b/drivers/timer/sifive_clint_timer.c @@ -9,6 +9,7 @@ #include <dm.h> #include <timer.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <linux/err.h> /* mtime register */ @@ -16,7 +17,7 @@ static u64 sifive_clint_get_count(struct udevice *dev) { - return readq((void __iomem *)MTIME_REG(dev->priv)); + return readq((void __iomem *)MTIME_REG(dev_get_priv(dev))); } static const struct timer_ops sifive_clint_ops = { @@ -25,8 +26,8 @@ static const struct timer_ops sifive_clint_ops = { static int sifive_clint_probe(struct udevice *dev) { - dev->priv = dev_read_addr_ptr(dev); - if (!dev->priv) + dev_set_priv(dev, dev_read_addr_ptr(dev)); + if (!dev_get_priv(dev)) return -EINVAL; return timer_timebase_fallback(dev); diff --git a/drivers/timer/sti-timer.c b/drivers/timer/sti-timer.c index 9d95f562fa..87444a0650 100644 --- a/drivers/timer/sti-timer.c +++ b/drivers/timer/sti-timer.c @@ -79,7 +79,7 @@ U_BOOT_DRIVER(sti_timer) = { .name = "sti_timer", .id = UCLASS_TIMER, .of_match = sti_timer_ids, - .priv_auto_alloc_size = sizeof(struct sti_timer_priv), + .priv_auto = sizeof(struct sti_timer_priv), .probe = sti_timer_probe, .ops = &sti_timer_ops, }; diff --git a/drivers/timer/stm32_timer.c b/drivers/timer/stm32_timer.c index 2f5f8f43b9..215334f1b8 100644 --- a/drivers/timer/stm32_timer.c +++ b/drivers/timer/stm32_timer.c @@ -129,7 +129,7 @@ U_BOOT_DRIVER(stm32_timer) = { .name = "stm32_timer", .id = UCLASS_TIMER, .of_match = stm32_timer_ids, - .priv_auto_alloc_size = sizeof(struct stm32_timer_priv), + .priv_auto = sizeof(struct stm32_timer_priv), .probe = stm32_timer_probe, .ops = &stm32_timer_ops, }; diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 62d0e860e8..da1a72f025 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -40,7 +40,7 @@ int notrace timer_get_count(struct udevice *dev, u64 *count) unsigned long notrace timer_get_rate(struct udevice *dev) { - struct timer_dev_priv *uc_priv = dev->uclass_priv; + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); return uc_priv->clock_rate; } @@ -54,7 +54,7 @@ static int timer_pre_probe(struct udevice *dev) ulong ret; /* It is possible that a timer device has a null ofnode */ - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; err = clk_get_by_index(dev, 0, &timer_clk); @@ -90,7 +90,7 @@ static int timer_post_probe(struct udevice *dev) int timer_timebase_fallback(struct udevice *dev) { struct udevice *cpu; - struct cpu_platdata *cpu_plat; + struct cpu_plat *cpu_plat; struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); /* Did we get our clock rate from the device tree? */ @@ -103,7 +103,7 @@ int timer_timebase_fallback(struct udevice *dev) if (!cpu) return -ENODEV; - cpu_plat = dev_get_parent_platdata(cpu); + cpu_plat = dev_get_parent_plat(cpu); if (!cpu_plat) return -ENODEV; @@ -176,5 +176,5 @@ UCLASS_DRIVER(timer) = { .pre_probe = timer_pre_probe, .flags = DM_UC_FLAG_SEQ_ALIAS, .post_probe = timer_post_probe, - .per_device_auto_alloc_size = sizeof(struct timer_dev_priv), + .per_device_auto = sizeof(struct timer_dev_priv), }; diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c index e3677704b3..706d52b830 100644 --- a/drivers/timer/tsc_timer.c +++ b/drivers/timer/tsc_timer.c @@ -477,15 +477,17 @@ static const struct timer_ops tsc_timer_ops = { .get_count = tsc_timer_get_count, }; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) static const struct udevice_id tsc_timer_ids[] = { { .compatible = "x86,tsc-timer", }, { } }; +#endif U_BOOT_DRIVER(x86_tsc_timer) = { .name = "x86_tsc_timer", .id = UCLASS_TIMER, - .of_match = tsc_timer_ids, + .of_match = of_match_ptr(tsc_timer_ids), .probe = tsc_timer_probe, .ops = &tsc_timer_ops, }; diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index a761e3d52f..ce61b72d22 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -547,7 +547,7 @@ static int claim_locality(struct udevice *dev, int loc) static int cr50_i2c_get_desc(struct udevice *dev, char *buf, int size) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct cr50_priv *priv = dev_get_priv(dev); return snprintf(buf, size, "cr50 TPM 2.0 (i2c %02x id %x) irq=%d", @@ -637,7 +637,7 @@ enum { LONG_TIMEOUT_MS = 2000, }; -static int cr50_i2c_ofdata_to_platdata(struct udevice *dev) +static int cr50_i2c_of_to_plat(struct udevice *dev) { struct tpm_chip_priv *upriv = dev_get_uclass_priv(dev); struct cr50_priv *priv = dev_get_priv(dev); @@ -725,10 +725,10 @@ U_BOOT_DRIVER(cr50_i2c) = { .id = UCLASS_TPM, .of_match = cr50_i2c_ids, .ops = &cr50_i2c_ops, - .ofdata_to_platdata = cr50_i2c_ofdata_to_platdata, + .of_to_plat = cr50_i2c_of_to_plat, .probe = cr50_i2c_probe, .remove = cr50_i2c_cleanup, - .priv_auto_alloc_size = sizeof(struct cr50_priv), + .priv_auto = sizeof(struct cr50_priv), ACPI_OPS_PTR(&cr50_acpi_ops) .flags = DM_FLAG_OS_PREPARE, }; diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c index 6ea795bc0c..beb0fa3f93 100644 --- a/drivers/tpm/tpm-uclass.c +++ b/drivers/tpm/tpm-uclass.c @@ -141,5 +141,5 @@ UCLASS_DRIVER(tpm) = { #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .post_bind = dm_scan_fdt_dev, #endif - .per_device_auto_alloc_size = sizeof(struct tpm_chip_priv), + .per_device_auto = sizeof(struct tpm_chip_priv), }; diff --git a/drivers/tpm/tpm2_ftpm_tee.c b/drivers/tpm/tpm2_ftpm_tee.c index 3197e0ebcd..53e59f42b4 100644 --- a/drivers/tpm/tpm2_ftpm_tee.c +++ b/drivers/tpm/tpm2_ftpm_tee.c @@ -247,5 +247,5 @@ U_BOOT_DRIVER(ftpm_tee) = { .probe = ftpm_tee_probe, .remove = ftpm_tee_remove, .flags = DM_FLAG_OS_PREPARE, - .priv_auto_alloc_size = sizeof(struct ftpm_tee_private), + .priv_auto = sizeof(struct ftpm_tee_private), }; diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c index 41a15bd49f..c74bacfd71 100644 --- a/drivers/tpm/tpm2_tis_sandbox.c +++ b/drivers/tpm/tpm2_tis_sandbox.c @@ -625,5 +625,5 @@ U_BOOT_DRIVER(sandbox_tpm2) = { .of_match = sandbox_tpm2_ids, .ops = &sandbox_tpm2_ops, .probe = sandbox_tpm2_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_tpm2), + .priv_auto = sizeof(struct sandbox_tpm2), }; diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c index 0045bedf0c..4b33ac8fd3 100644 --- a/drivers/tpm/tpm2_tis_spi.c +++ b/drivers/tpm/tpm2_tis_spi.c @@ -686,5 +686,5 @@ U_BOOT_DRIVER(tpm_tis_spi) = { .ops = &tpm_tis_spi_ops, .probe = tpm_tis_spi_probe, .remove = tpm_tis_spi_remove, - .priv_auto_alloc_size = sizeof(struct tpm_chip), + .priv_auto = sizeof(struct tpm_chip), }; diff --git a/drivers/tpm/tpm_tis_infineon.c b/drivers/tpm/tpm_tis_infineon.c index f47813e76d..f414e5657d 100644 --- a/drivers/tpm/tpm_tis_infineon.c +++ b/drivers/tpm/tpm_tis_infineon.c @@ -633,5 +633,5 @@ U_BOOT_DRIVER(tpm_tis_i2c) = { .of_match = tpm_tis_i2c_ids, .ops = &tpm_tis_i2c_ops, .probe = tpm_tis_i2c_probe, - .priv_auto_alloc_size = sizeof(struct tpm_chip), + .priv_auto = sizeof(struct tpm_chip), }; diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c index 2dd374cf77..003c0d8816 100644 --- a/drivers/tpm/tpm_tis_lpc.c +++ b/drivers/tpm/tpm_tis_lpc.c @@ -475,5 +475,5 @@ U_BOOT_DRIVER(tpm_tis_lpc) = { .of_match = tpm_tis_lpc_ids, .ops = &tpm_tis_lpc_ops, .probe = tpm_tis_lpc_probe, - .priv_auto_alloc_size = sizeof(struct tpm_tis_lpc_priv), + .priv_auto = sizeof(struct tpm_tis_lpc_priv), }; diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c index e167d0a2fe..67139cea3b 100644 --- a/drivers/tpm/tpm_tis_sandbox.c +++ b/drivers/tpm/tpm_tis_sandbox.c @@ -361,5 +361,5 @@ U_BOOT_DRIVER(google_sandbox_tpm) = { .of_match = sandbox_tpm_ids, .ops = &sandbox_tpm_ops, .probe = sandbox_tpm_probe, - .priv_auto_alloc_size = sizeof(struct tpm_state), + .priv_auto = sizeof(struct tpm_state), }; diff --git a/drivers/tpm/tpm_tis_st33zp24_i2c.c b/drivers/tpm/tpm_tis_st33zp24_i2c.c index a253ee1502..e0eeabb933 100644 --- a/drivers/tpm/tpm_tis_st33zp24_i2c.c +++ b/drivers/tpm/tpm_tis_st33zp24_i2c.c @@ -542,5 +542,5 @@ U_BOOT_DRIVER(st33zp24_i2c) = { .probe = st33zp24_i2c_probe, .remove = st33zp24_i2c_remove, .ops = &st33zp24_i2c_tpm_ops, - .priv_auto_alloc_size = sizeof(struct tpm_chip), + .priv_auto = sizeof(struct tpm_chip), }; diff --git a/drivers/tpm/tpm_tis_st33zp24_spi.c b/drivers/tpm/tpm_tis_st33zp24_spi.c index ef54e3b7b2..f0de8a65b0 100644 --- a/drivers/tpm/tpm_tis_st33zp24_spi.c +++ b/drivers/tpm/tpm_tis_st33zp24_spi.c @@ -116,7 +116,7 @@ static int st33zp24_spi_write(struct udevice *dev, u8 tpm_register, { int total_length = 0, ret; struct spi_slave *slave = dev_get_parent_priv(dev); - struct st33zp24_spi_phy *phy = dev_get_platdata(dev); + struct st33zp24_spi_phy *phy = dev_get_plat(dev); u8 *tx_buf = (u8 *)phy->tx_buf; u8 *rx_buf = phy->rx_buf; @@ -167,7 +167,7 @@ static u8 st33zp24_spi_read8_reg(struct udevice *dev, u8 tpm_register, { int total_length = 0, ret; struct spi_slave *slave = dev_get_parent_priv(dev); - struct st33zp24_spi_phy *phy = dev_get_platdata(dev); + struct st33zp24_spi_phy *phy = dev_get_plat(dev); u8 *tx_buf = (u8 *)phy->tx_buf; u8 *rx_buf = phy->rx_buf; @@ -223,7 +223,7 @@ static int st33zp24_spi_evaluate_latency(struct udevice *dev) { int latency = 1, status = 0; u8 data = 0; - struct st33zp24_spi_phy *phy = dev_get_platdata(dev); + struct st33zp24_spi_phy *phy = dev_get_plat(dev); while (!status && latency < MAX_SPI_LATENCY) { phy->latency = latency; @@ -562,7 +562,7 @@ static int st33zp24_spi_cleanup(struct udevice *dev) static int st33zp24_spi_init(struct udevice *dev) { struct tpm_chip *chip = dev_get_priv(dev); - struct st33zp24_spi_phy *phy = dev_get_platdata(dev); + struct st33zp24_spi_phy *phy = dev_get_plat(dev); chip->is_open = 1; @@ -670,6 +670,6 @@ U_BOOT_DRIVER(st33zp24_spi_spi) = { .probe = st33zp24_spi_probe, .remove = st33zp24_spi_remove, .ops = &st33zp24_spi_tpm_ops, - .priv_auto_alloc_size = sizeof(struct tpm_chip), - .platdata_auto_alloc_size = sizeof(struct st33zp24_spi_phy), + .priv_auto = sizeof(struct tpm_chip), + .plat_auto = sizeof(struct st33zp24_spi_phy), }; diff --git a/drivers/ufs/ufs-uclass.c b/drivers/ufs/ufs-uclass.c index 920bfa64e1..034d14fd8d 100644 --- a/drivers/ufs/ufs-uclass.c +++ b/drivers/ufs/ufs-uclass.c @@ -12,5 +12,5 @@ UCLASS_DRIVER(ufs) = { .id = UCLASS_UFS, .name = "ufs", - .per_device_auto_alloc_size = sizeof(struct ufs_hba), + .per_device_auto = sizeof(struct ufs_hba), }; diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c index 92b7e9fd7c..13e730b883 100644 --- a/drivers/ufs/ufs.c +++ b/drivers/ufs/ufs.c @@ -1865,7 +1865,7 @@ int ufs_start(struct ufs_hba *hba) int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops) { struct ufs_hba *hba = dev_get_uclass_priv(ufs_dev); - struct scsi_platdata *scsi_plat; + struct scsi_plat *scsi_plat; struct udevice *scsi_dev; int err; @@ -1873,7 +1873,7 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops) if (!scsi_dev) return -ENODEV; - scsi_plat = dev_get_uclass_platdata(scsi_dev); + scsi_plat = dev_get_uclass_plat(scsi_dev); scsi_plat->max_id = UFSHCD_MAX_ID; scsi_plat->max_lun = UFS_MAX_LUNS; scsi_plat->max_bytes_per_req = UFS_MAX_BYTES; diff --git a/drivers/usb/cdns3/cdns3-ti.c b/drivers/usb/cdns3/cdns3-ti.c index cd7b2113ac..7b205c5656 100644 --- a/drivers/usb/cdns3/cdns3-ti.c +++ b/drivers/usb/cdns3/cdns3-ti.c @@ -87,7 +87,7 @@ static inline void cdns_ti_writel(struct cdns_ti *data, u32 offset, u32 value) static int cdns_ti_probe(struct udevice *dev) { - struct cdns_ti *data = dev_get_platdata(dev); + struct cdns_ti *data = dev_get_plat(dev); struct clk usb2_refclk; int modestrap_mode; unsigned long rate; @@ -167,7 +167,7 @@ static int cdns_ti_probe(struct udevice *dev) static int cdns_ti_remove(struct udevice *dev) { - struct cdns_ti *data = dev_get_platdata(dev); + struct cdns_ti *data = dev_get_plat(dev); u32 reg; /* put device back to RESET*/ @@ -190,6 +190,6 @@ U_BOOT_DRIVER(cdns_ti) = { .bind = cdns3_bind, .probe = cdns_ti_probe, .remove = cdns_ti_remove, - .platdata_auto_alloc_size = sizeof(struct cdns_ti), + .plat_auto = sizeof(struct cdns_ti), .flags = DM_FLAG_OS_PREPARE, }; diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index ea86a25060..798a21793f 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -110,7 +110,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns) enum usb_dr_mode dr_mode; int ret = 0; - dr_mode = usb_get_dr_mode(dev->node); + dr_mode = usb_get_dr_mode(dev_ofnode(dev)); cdns->role = USB_ROLE_NONE; /* @@ -393,7 +393,7 @@ int cdns3_bind(struct udevice *parent) ofnode node; int ret; - node = ofnode_by_compatible(parent->node, "cdns,usb3"); + node = ofnode_by_compatible(dev_ofnode(parent), "cdns,usb3"); if (!ofnode_valid(node)) { ret = -ENODEV; goto fail; @@ -461,7 +461,7 @@ U_BOOT_DRIVER(cdns_usb3_peripheral) = { .of_match = cdns3_ids, .probe = cdns3_gadget_probe, .remove = cdns3_gadget_remove, - .priv_auto_alloc_size = sizeof(struct cdns3_gadget_priv), + .priv_auto = sizeof(struct cdns3_gadget_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif @@ -492,7 +492,7 @@ U_BOOT_DRIVER(cdns_usb3_host) = { .of_match = cdns3_ids, .probe = cdns3_host_probe, .remove = cdns3_host_remove, - .priv_auto_alloc_size = sizeof(struct cdns3_host_priv), + .priv_auto = sizeof(struct cdns3_host_priv), .ops = &xhci_usb_ops, .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 2e003530a1..dfd7cf683f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -905,7 +905,7 @@ void dwc3_of_parse(struct dwc3 *dwc) */ hird_threshold = 12; - dwc->hsphy_mode = usb_get_phy_mode(dev->node); + dwc->hsphy_mode = usb_get_phy_mode(dev_ofnode(dev)); dwc->has_lpm_erratum = dev_read_bool(dev, "snps,has-lpm-erratum"); diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 222358d395..30f835e1e3 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -53,9 +53,9 @@ static int dwc3_generic_probe(struct udevice *dev, struct dwc3_generic_priv *priv) { int rc; - struct dwc3_generic_plat *plat = dev_get_platdata(dev); + struct dwc3_generic_plat *plat = dev_get_plat(dev); struct dwc3 *dwc3 = &priv->dwc3; - struct dwc3_glue_data *glue = dev_get_platdata(dev->parent); + struct dwc3_glue_data *glue = dev_get_plat(dev->parent); dwc3->dev = dev; dwc3->maximum_speed = plat->maximum_speed; @@ -105,10 +105,10 @@ static int dwc3_generic_remove(struct udevice *dev, return 0; } -static int dwc3_generic_ofdata_to_platdata(struct udevice *dev) +static int dwc3_generic_of_to_plat(struct udevice *dev) { - struct dwc3_generic_plat *plat = dev_get_platdata(dev); - ofnode node = dev->node; + struct dwc3_generic_plat *plat = dev_get_plat(dev); + ofnode node = dev_ofnode(dev); plat->base = dev_read_addr(dev); @@ -155,11 +155,11 @@ static int dwc3_generic_peripheral_remove(struct udevice *dev) U_BOOT_DRIVER(dwc3_generic_peripheral) = { .name = "dwc3-generic-peripheral", .id = UCLASS_USB_GADGET_GENERIC, - .ofdata_to_platdata = dwc3_generic_ofdata_to_platdata, + .of_to_plat = dwc3_generic_of_to_plat, .probe = dwc3_generic_peripheral_probe, .remove = dwc3_generic_peripheral_remove, - .priv_auto_alloc_size = sizeof(struct dwc3_generic_priv), - .platdata_auto_alloc_size = sizeof(struct dwc3_generic_plat), + .priv_auto = sizeof(struct dwc3_generic_priv), + .plat_auto = sizeof(struct dwc3_generic_plat), }; #endif @@ -197,11 +197,11 @@ static int dwc3_generic_host_remove(struct udevice *dev) U_BOOT_DRIVER(dwc3_generic_host) = { .name = "dwc3-generic-host", .id = UCLASS_USB, - .ofdata_to_platdata = dwc3_generic_ofdata_to_platdata, + .of_to_plat = dwc3_generic_of_to_plat, .probe = dwc3_generic_host_probe, .remove = dwc3_generic_host_remove, - .priv_auto_alloc_size = sizeof(struct dwc3_generic_host_priv), - .platdata_auto_alloc_size = sizeof(struct dwc3_generic_plat), + .priv_auto = sizeof(struct dwc3_generic_host_priv), + .plat_auto = sizeof(struct dwc3_generic_plat), .ops = &xhci_usb_ops, .flags = DM_FLAG_ALLOC_PRIV_DMA, }; @@ -238,7 +238,7 @@ enum dwc3_omap_utmi_mode { u32 utmi_mode; u32 utmi_status_offset = USBOTGSS_UTMI_OTG_STATUS; - struct dwc3_glue_data *glue = dev_get_platdata(dev); + struct dwc3_glue_data *glue = dev_get_plat(dev); void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); if (device_is_compatible(dev, "ti,am437x-dwc3")) @@ -301,7 +301,7 @@ static int dwc3_glue_bind(struct udevice *parent) ofnode node; int ret; - ofnode_for_each_subnode(node, parent->node) { + ofnode_for_each_subnode(node, dev_ofnode(parent)) { const char *name = ofnode_get_name(node); enum usb_dr_mode dr_mode; struct udevice *dev; @@ -390,7 +390,7 @@ static int dwc3_glue_clk_init(struct udevice *dev, static int dwc3_glue_probe(struct udevice *dev) { struct dwc3_glue_ops *ops = (struct dwc3_glue_ops *)dev_get_driver_data(dev); - struct dwc3_glue_data *glue = dev_get_platdata(dev); + struct dwc3_glue_data *glue = dev_get_plat(dev); struct udevice *child = NULL; int index = 0; int ret; @@ -418,7 +418,7 @@ static int dwc3_glue_probe(struct udevice *dev) while (child) { enum usb_dr_mode dr_mode; - dr_mode = usb_get_dr_mode(child->node); + dr_mode = usb_get_dr_mode(dev_ofnode(child)); device_find_next_child(&child); if (ops && ops->select_dr_mode) ops->select_dr_mode(dev, index, dr_mode); @@ -430,7 +430,7 @@ static int dwc3_glue_probe(struct udevice *dev) static int dwc3_glue_remove(struct udevice *dev) { - struct dwc3_glue_data *glue = dev_get_platdata(dev); + struct dwc3_glue_data *glue = dev_get_plat(dev); reset_release_bulk(&glue->resets); @@ -460,6 +460,6 @@ U_BOOT_DRIVER(dwc3_generic_wrapper) = { .bind = dwc3_glue_bind, .probe = dwc3_glue_probe, .remove = dwc3_glue_remove, - .platdata_auto_alloc_size = sizeof(struct dwc3_glue_data), + .plat_auto = sizeof(struct dwc3_glue_data), }; diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index 6f0bac2a00..bd8bf227c8 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -258,7 +258,7 @@ static int dwc3_meson_g12a_usb_init(struct dwc3_meson_g12a *priv) int dwc3_meson_g12a_force_mode(struct udevice *dev, enum usb_dr_mode mode) { - struct dwc3_meson_g12a *priv = dev_get_platdata(dev); + struct dwc3_meson_g12a *priv = dev_get_plat(dev); if (!priv) return -EINVAL; @@ -356,7 +356,7 @@ static int dwc3_meson_g12a_clk_init(struct dwc3_meson_g12a *priv) static int dwc3_meson_g12a_probe(struct udevice *dev) { - struct dwc3_meson_g12a *priv = dev_get_platdata(dev); + struct dwc3_meson_g12a *priv = dev_get_plat(dev); int ret, i; priv->dev = dev; @@ -392,7 +392,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev) } #endif - priv->otg_mode = usb_get_dr_mode(dev->node); + priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev)); ret = dwc3_meson_g12a_usb_init(priv); if (ret) @@ -431,7 +431,7 @@ err_phy_init: static int dwc3_meson_g12a_remove(struct udevice *dev) { - struct dwc3_meson_g12a *priv = dev_get_platdata(dev); + struct dwc3_meson_g12a *priv = dev_get_plat(dev); int i; reset_release_all(&priv->reset, 1); @@ -466,6 +466,6 @@ U_BOOT_DRIVER(dwc3_generic_wrapper) = { .of_match = dwc3_meson_g12a_ids, .probe = dwc3_meson_g12a_probe, .remove = dwc3_meson_g12a_remove, - .platdata_auto_alloc_size = sizeof(struct dwc3_meson_g12a), + .plat_auto = sizeof(struct dwc3_meson_g12a), }; diff --git a/drivers/usb/dwc3/dwc3-meson-gxl.c b/drivers/usb/dwc3/dwc3-meson-gxl.c index 92ee0866f7..08467d6210 100644 --- a/drivers/usb/dwc3/dwc3-meson-gxl.c +++ b/drivers/usb/dwc3/dwc3-meson-gxl.c @@ -196,7 +196,7 @@ static int dwc3_meson_gxl_usb_init(struct dwc3_meson_gxl *priv) int dwc3_meson_gxl_force_mode(struct udevice *dev, enum usb_dr_mode mode) { - struct dwc3_meson_gxl *priv = dev_get_platdata(dev); + struct dwc3_meson_gxl *priv = dev_get_plat(dev); if (!priv) return -EINVAL; @@ -295,7 +295,7 @@ static int dwc3_meson_gxl_clk_init(struct dwc3_meson_gxl *priv) static int dwc3_meson_gxl_probe(struct udevice *dev) { - struct dwc3_meson_gxl *priv = dev_get_platdata(dev); + struct dwc3_meson_gxl *priv = dev_get_plat(dev); int ret, i; priv->dev = dev; @@ -338,7 +338,7 @@ static int dwc3_meson_gxl_probe(struct udevice *dev) if (ret) return ret; - priv->otg_mode = usb_get_dr_mode(dev->node); + priv->otg_mode = usb_get_dr_mode(dev_ofnode(dev)); if (priv->otg_mode == USB_DR_MODE_PERIPHERAL) priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL; @@ -384,7 +384,7 @@ err_phy_init: static int dwc3_meson_gxl_remove(struct udevice *dev) { - struct dwc3_meson_gxl *priv = dev_get_platdata(dev); + struct dwc3_meson_gxl *priv = dev_get_plat(dev); int i; reset_release_all(&priv->reset, 1); @@ -420,6 +420,6 @@ U_BOOT_DRIVER(dwc3_generic_wrapper) = { .of_match = dwc3_meson_gxl_ids, .probe = dwc3_meson_gxl_probe, .remove = dwc3_meson_gxl_remove, - .platdata_auto_alloc_size = sizeof(struct dwc3_meson_gxl), + .plat_auto = sizeof(struct dwc3_meson_gxl), }; diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c index 9c305f46e9..edabc1b3a7 100644 --- a/drivers/usb/emul/sandbox_flash.c +++ b/drivers/usb/emul/sandbox_flash.c @@ -297,7 +297,7 @@ static int handle_ufi_command(struct sandbox_flash_plat *plat, static int sandbox_flash_bulk(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buff, int len) { - struct sandbox_flash_plat *plat = dev_get_platdata(dev); + struct sandbox_flash_plat *plat = dev_get_plat(dev); struct sandbox_flash_priv *priv = dev_get_priv(dev); int ep = usb_pipeendpoint(pipe); struct umass_bbb_cbw *cbw = buff; @@ -366,9 +366,9 @@ err: return 0; } -static int sandbox_flash_ofdata_to_platdata(struct udevice *dev) +static int sandbox_flash_of_to_plat(struct udevice *dev) { - struct sandbox_flash_plat *plat = dev_get_platdata(dev); + struct sandbox_flash_plat *plat = dev_get_plat(dev); plat->pathname = dev_read_string(dev, "sandbox,filepath"); @@ -377,7 +377,7 @@ static int sandbox_flash_ofdata_to_platdata(struct udevice *dev) static int sandbox_flash_bind(struct udevice *dev) { - struct sandbox_flash_plat *plat = dev_get_platdata(dev); + struct sandbox_flash_plat *plat = dev_get_plat(dev); struct usb_string *fs; fs = plat->flash_strings; @@ -393,7 +393,7 @@ static int sandbox_flash_bind(struct udevice *dev) static int sandbox_flash_probe(struct udevice *dev) { - struct sandbox_flash_plat *plat = dev_get_platdata(dev); + struct sandbox_flash_plat *plat = dev_get_plat(dev); struct sandbox_flash_priv *priv = dev_get_priv(dev); priv->fd = os_open(plat->pathname, OS_O_RDONLY); @@ -419,8 +419,8 @@ U_BOOT_DRIVER(usb_sandbox_flash) = { .of_match = sandbox_usb_flash_ids, .bind = sandbox_flash_bind, .probe = sandbox_flash_probe, - .ofdata_to_platdata = sandbox_flash_ofdata_to_platdata, + .of_to_plat = sandbox_flash_of_to_plat, .ops = &sandbox_usb_flash_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_flash_priv), - .platdata_auto_alloc_size = sizeof(struct sandbox_flash_plat), + .priv_auto = sizeof(struct sandbox_flash_priv), + .plat_auto = sizeof(struct sandbox_flash_plat), }; diff --git a/drivers/usb/emul/sandbox_hub.c b/drivers/usb/emul/sandbox_hub.c index 21bf3bda48..041ec3772a 100644 --- a/drivers/usb/emul/sandbox_hub.c +++ b/drivers/usb/emul/sandbox_hub.c @@ -13,8 +13,8 @@ /* We only support up to 8 */ #define SANDBOX_NUM_PORTS 4 -struct sandbox_hub_platdata { - struct usb_dev_platdata plat; +struct sandbox_hub_plat { + struct usb_dev_plat plat; int port; /* Port number (numbered from 0) */ }; @@ -129,9 +129,9 @@ static struct udevice *hub_find_device(struct udevice *hub, int port, for (device_find_first_child(hub, &dev); dev; device_find_next_child(&dev)) { - struct sandbox_hub_platdata *plat; + struct sandbox_hub_plat *plat; - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); if (plat->port == port) { gen_desc = plat->plat.desc_list; gen_desc = usb_emul_find_descriptor(gen_desc, @@ -304,8 +304,8 @@ static int sandbox_hub_bind(struct udevice *dev) static int sandbox_child_post_bind(struct udevice *dev) { - struct sandbox_hub_platdata *plat = dev_get_parent_platdata(dev); - struct usb_emul_platdata *emul = dev_get_uclass_platdata(dev); + struct sandbox_hub_plat *plat = dev_get_parent_plat(dev); + struct usb_emul_plat *emul = dev_get_uclass_plat(dev); plat->port = dev_read_u32_default(dev, "reg", -1); emul->port1 = plat->port + 1; @@ -328,8 +328,7 @@ U_BOOT_DRIVER(usb_sandbox_hub) = { .of_match = sandbox_usb_hub_ids, .bind = sandbox_hub_bind, .ops = &sandbox_usb_hub_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_hub_priv), - .per_child_platdata_auto_alloc_size = - sizeof(struct sandbox_hub_platdata), + .priv_auto = sizeof(struct sandbox_hub_priv), + .per_child_plat_auto = sizeof(struct sandbox_hub_plat), .child_post_bind = sandbox_child_post_bind, }; diff --git a/drivers/usb/emul/sandbox_keyb.c b/drivers/usb/emul/sandbox_keyb.c index f562fb7eca..5ec1e98e4e 100644 --- a/drivers/usb/emul/sandbox_keyb.c +++ b/drivers/usb/emul/sandbox_keyb.c @@ -202,7 +202,7 @@ static int sandbox_keyb_interrupt(struct udevice *dev, struct usb_device *udev, static int sandbox_keyb_bind(struct udevice *dev) { - struct sandbox_keyb_plat *plat = dev_get_platdata(dev); + struct sandbox_keyb_plat *plat = dev_get_plat(dev); struct usb_string *fs; fs = plat->keyb_strings; @@ -241,6 +241,6 @@ U_BOOT_DRIVER(usb_sandbox_keyb) = { .bind = sandbox_keyb_bind, .probe = sandbox_keyb_probe, .ops = &sandbox_usb_keyb_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_keyb_priv), - .platdata_auto_alloc_size = sizeof(struct sandbox_keyb_plat), + .priv_auto = sizeof(struct sandbox_keyb_priv), + .plat_auto = sizeof(struct sandbox_keyb_plat), }; diff --git a/drivers/usb/emul/usb-emul-uclass.c b/drivers/usb/emul/usb-emul-uclass.c index e3419e2fd4..f5d98b917d 100644 --- a/drivers/usb/emul/usb-emul-uclass.c +++ b/drivers/usb/emul/usb-emul-uclass.c @@ -75,7 +75,7 @@ struct usb_generic_descriptor **usb_emul_find_descriptor( return ptr; } -static int usb_emul_get_descriptor(struct usb_dev_platdata *plat, int value, +static int usb_emul_get_descriptor(struct usb_dev_plat *plat, int value, void *buffer, int length) { struct usb_generic_descriptor **ptr; @@ -115,7 +115,7 @@ static int usb_emul_find_devnum(int devnum, int port1, struct udevice **emulp) if (ret) return ret; uclass_foreach_dev(dev, uc) { - struct usb_dev_platdata *udev = dev_get_parent_platdata(dev); + struct usb_dev_plat *udev = dev_get_parent_plat(dev); /* * devnum is initialzied to zero at the beginning of the @@ -126,7 +126,7 @@ static int usb_emul_find_devnum(int devnum, int port1, struct udevice **emulp) * emulator device. */ if (!devnum) { - struct usb_emul_platdata *plat; + struct usb_emul_plat *plat; /* * If the parent is sandbox USB controller, we are @@ -140,7 +140,7 @@ static int usb_emul_find_devnum(int devnum, int port1, struct udevice **emulp) return 0; } - plat = dev_get_uclass_platdata(dev); + plat = dev_get_uclass_plat(dev); if (plat->port1 == port1) { debug("%s: Found emulator '%s', port %d\n", __func__, dev->name, port1); @@ -169,7 +169,7 @@ int usb_emul_find(struct udevice *bus, ulong pipe, int port1, int usb_emul_find_for_dev(struct udevice *dev, struct udevice **emulp) { - struct usb_dev_platdata *udev = dev_get_parent_platdata(dev); + struct usb_dev_plat *udev = dev_get_parent_plat(dev); return usb_emul_find_devnum(udev->devnum, 0, emulp); } @@ -179,11 +179,11 @@ int usb_emul_control(struct udevice *emul, struct usb_device *udev, struct devrequest *setup) { struct dm_usb_ops *ops = usb_get_emul_ops(emul); - struct usb_dev_platdata *plat; + struct usb_dev_plat *plat; int ret; /* We permit getting the descriptor before we are probed */ - plat = dev_get_parent_platdata(emul); + plat = dev_get_parent_plat(emul); if (!ops->control) return -ENOSYS; debug("%s: dev=%s\n", __func__, emul->name); @@ -262,7 +262,7 @@ int usb_emul_int(struct udevice *emul, struct usb_device *udev, int usb_emul_setup_device(struct udevice *dev, struct usb_string *strings, void **desc_list) { - struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); + struct usb_dev_plat *plat = dev_get_parent_plat(dev); struct usb_generic_descriptor **ptr; struct usb_config_descriptor *cdesc; int upto; @@ -298,7 +298,7 @@ UCLASS_DRIVER(usb_emul) = { .id = UCLASS_USB_EMUL, .name = "usb_emul", .post_bind = dm_scan_fdt_dev, - .per_device_platdata_auto_alloc_size = sizeof(struct usb_emul_platdata), - .per_child_auto_alloc_size = sizeof(struct usb_device), - .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), + .per_device_plat_auto = sizeof(struct usb_emul_plat), + .per_child_auto = sizeof(struct usb_device), + .per_child_plat_auto = sizeof(struct usb_dev_plat), }; diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c index ac4a27fff2..674f78e214 100644 --- a/drivers/usb/eth/asix.c +++ b/drivers/usb/eth/asix.c @@ -743,7 +743,7 @@ int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss, #ifdef CONFIG_DM_ETH static int asix_eth_start(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct asix_private *priv = dev_get_priv(dev); return asix_init_common(&priv->ueth, pdata->enetaddr); @@ -825,7 +825,7 @@ static int asix_free_pkt(struct udevice *dev, uchar *packet, int packet_len) int asix_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct asix_private *priv = dev_get_priv(dev); if (priv->flags & FLAG_TYPE_AX88172) @@ -836,7 +836,7 @@ int asix_write_hwaddr(struct udevice *dev) static int asix_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct asix_private *priv = dev_get_priv(dev); struct ueth_data *ss = &priv->ueth; int ret; @@ -876,8 +876,8 @@ U_BOOT_DRIVER(asix_eth) = { .id = UCLASS_ETH, .probe = asix_eth_probe, .ops = &asix_eth_ops, - .priv_auto_alloc_size = sizeof(struct asix_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct asix_private), + .plat_auto = sizeof(struct eth_pdata), }; static const struct usb_device_id asix_eth_id_table[] = { diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c index c142b8b19b..4742a95af9 100644 --- a/drivers/usb/eth/asix88179.c +++ b/drivers/usb/eth/asix88179.c @@ -857,7 +857,7 @@ static int ax88179_free_pkt(struct udevice *dev, uchar *packet, int packet_len) int ax88179_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct asix_private *priv = dev_get_priv(dev); struct ueth_data *ueth = &priv->ueth; @@ -866,7 +866,7 @@ int ax88179_write_hwaddr(struct udevice *dev) static int ax88179_eth_probe(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct asix_private *priv = dev_get_priv(dev); struct usb_device *usb_dev; int ret; @@ -902,8 +902,8 @@ U_BOOT_DRIVER(ax88179_eth) = { .id = UCLASS_ETH, .probe = ax88179_eth_probe, .ops = &ax88179_eth_ops, - .priv_auto_alloc_size = sizeof(struct asix_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct asix_private), + .plat_auto = sizeof(struct eth_pdata), }; static const struct usb_device_id ax88179_eth_id_table[] = { diff --git a/drivers/usb/eth/lan75xx.c b/drivers/usb/eth/lan75xx.c index 46b92e8d68..4effbc5c87 100644 --- a/drivers/usb/eth/lan75xx.c +++ b/drivers/usb/eth/lan75xx.c @@ -133,7 +133,7 @@ static int lan75xx_basic_reset(struct usb_device *udev, int lan75xx_write_hwaddr(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); unsigned char *enetaddr = pdata->enetaddr; u32 addr_lo = get_unaligned_le32(&enetaddr[0]); u32 addr_hi = (u32)get_unaligned_le16(&enetaddr[4]); @@ -242,7 +242,7 @@ static int lan75xx_eth_start(struct udevice *dev) int lan75xx_read_rom_hwaddr(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int ret; /* @@ -261,7 +261,7 @@ static int lan75xx_eth_probe(struct udevice *dev) struct usb_device *udev = dev_get_parent_priv(dev); struct lan7x_private *priv = dev_get_priv(dev); struct ueth_data *ueth = &priv->ueth; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int ret; /* Do a reset in order to get the MAC address from HW */ @@ -304,8 +304,8 @@ U_BOOT_DRIVER(lan75xx_eth) = { .probe = lan75xx_eth_probe, .remove = lan7x_eth_remove, .ops = &lan75xx_eth_ops, - .priv_auto_alloc_size = sizeof(struct lan7x_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct lan7x_private), + .plat_auto = sizeof(struct eth_pdata), }; static const struct usb_device_id lan75xx_eth_id_table[] = { diff --git a/drivers/usb/eth/lan78xx.c b/drivers/usb/eth/lan78xx.c index e34ad2603f..37912a1d04 100644 --- a/drivers/usb/eth/lan78xx.c +++ b/drivers/usb/eth/lan78xx.c @@ -306,7 +306,7 @@ static int lan78xx_basic_reset(struct usb_device *udev, int lan78xx_write_hwaddr(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); unsigned char *enetaddr = pdata->enetaddr; u32 addr_lo = get_unaligned_le32(&enetaddr[0]); u32 addr_hi = (u32)get_unaligned_le16(&enetaddr[4]); @@ -410,7 +410,7 @@ static int lan78xx_eth_start(struct udevice *dev) int lan78xx_read_rom_hwaddr(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct lan7x_private *priv = dev_get_priv(dev); int ret; @@ -426,7 +426,7 @@ static int lan78xx_eth_probe(struct udevice *dev) struct usb_device *udev = dev_get_parent_priv(dev); struct lan7x_private *priv = dev_get_priv(dev); struct ueth_data *ueth = &priv->ueth; - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int ret; /* Do a reset in order to get the MAC address from HW */ @@ -466,8 +466,8 @@ U_BOOT_DRIVER(lan78xx_eth) = { .probe = lan78xx_eth_probe, .remove = lan7x_eth_remove, .ops = &lan78xx_eth_ops, - .priv_auto_alloc_size = sizeof(struct lan7x_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct lan7x_private), + .plat_auto = sizeof(struct eth_pdata), }; static const struct usb_device_id lan78xx_eth_id_table[] = { diff --git a/drivers/usb/eth/mcs7830.c b/drivers/usb/eth/mcs7830.c index c829a436a3..783ab62f6b 100644 --- a/drivers/usb/eth/mcs7830.c +++ b/drivers/usb/eth/mcs7830.c @@ -893,7 +893,7 @@ static int mcs7830_free_pkt(struct udevice *dev, uchar *packet, int packet_len) int mcs7830_write_hwaddr(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); return mcs7830_write_mac_common(udev, pdata->enetaddr); } @@ -902,7 +902,7 @@ static int mcs7830_eth_probe(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); struct mcs7830_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct ueth_data *ueth = &priv->ueth; if (mcs7830_basic_reset(udev, priv)) @@ -928,8 +928,8 @@ U_BOOT_DRIVER(mcs7830_eth) = { .id = UCLASS_ETH, .probe = mcs7830_eth_probe, .ops = &mcs7830_eth_ops, - .priv_auto_alloc_size = sizeof(struct mcs7830_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct mcs7830_private), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c index 5f309192b4..4677da9f29 100644 --- a/drivers/usb/eth/r8152.c +++ b/drivers/usb/eth/r8152.c @@ -1792,7 +1792,7 @@ static int r8152_free_pkt(struct udevice *dev, uchar *packet, int packet_len) static int r8152_write_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct r8152 *tp = dev_get_priv(dev); unsigned char enetaddr[8] = { 0 }; @@ -1810,7 +1810,7 @@ static int r8152_write_hwaddr(struct udevice *dev) int r8152_read_rom_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct r8152 *tp = dev_get_priv(dev); debug("** %s (%d)\n", __func__, __LINE__); @@ -1821,7 +1821,7 @@ int r8152_read_rom_hwaddr(struct udevice *dev) static int r8152_eth_probe(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct r8152 *tp = dev_get_priv(dev); struct ueth_data *ueth = &tp->ueth; int ret; @@ -1860,8 +1860,8 @@ U_BOOT_DRIVER(r8152_eth) = { .id = UCLASS_ETH, .probe = r8152_eth_probe, .ops = &r8152_eth_ops, - .priv_auto_alloc_size = sizeof(struct r8152), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct r8152), + .plat_auto = sizeof(struct eth_pdata), }; static const struct usb_device_id r8152_eth_id_table[] = { diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c index b293a808a3..283c52c16a 100644 --- a/drivers/usb/eth/smsc95xx.c +++ b/drivers/usb/eth/smsc95xx.c @@ -937,7 +937,7 @@ static int smsc95xx_eth_start(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); struct smsc95xx_private *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); /* Driver-model Ethernet ensures we have this */ priv->have_hwaddr = 1; @@ -1020,7 +1020,7 @@ static int smsc95xx_free_pkt(struct udevice *dev, uchar *packet, int packet_len) int smsc95xx_write_hwaddr(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); struct smsc95xx_private *priv = dev_get_priv(dev); return smsc95xx_write_hwaddr_common(udev, priv, pdata->enetaddr); @@ -1029,7 +1029,7 @@ int smsc95xx_write_hwaddr(struct udevice *dev) int smsc95xx_read_rom_hwaddr(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int ret; ret = smsc95xx_init_mac_address(pdata->enetaddr, udev); @@ -1062,8 +1062,8 @@ U_BOOT_DRIVER(smsc95xx_eth) = { .id = UCLASS_ETH, .probe = smsc95xx_eth_probe, .ops = &smsc95xx_eth_ops, - .priv_auto_alloc_size = sizeof(struct smsc95xx_private), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct smsc95xx_private), + .plat_auto = sizeof(struct eth_pdata), }; static const struct usb_device_id smsc95xx_eth_id_table[] = { diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index 8a8e2179e4..e3871e381e 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -980,48 +980,47 @@ static void dwc2_phy_shutdown(struct udevice *dev, struct phy_bulk *phys) generic_phy_exit_bulk(phys); } -static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev) +static int dwc2_udc_otg_of_to_plat(struct udevice *dev) { - struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev); + struct dwc2_plat_otg_data *plat = dev_get_plat(dev); ulong drvdata; void (*set_params)(struct dwc2_plat_otg_data *data); int ret; - if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL && - usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) { + if (usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_PERIPHERAL && + usb_get_dr_mode(dev_ofnode(dev)) != USB_DR_MODE_OTG) { dev_dbg(dev, "Invalid mode\n"); return -ENODEV; } - platdata->regs_otg = dev_read_addr(dev); + plat->regs_otg = dev_read_addr(dev); - platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0); - platdata->np_tx_fifo_sz = dev_read_u32_default(dev, - "g-np-tx-fifo-size", 0); + plat->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0); + plat->np_tx_fifo_sz = dev_read_u32_default(dev, "g-np-tx-fifo-size", 0); - platdata->tx_fifo_sz_nb = + plat->tx_fifo_sz_nb = dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32); - if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS) - platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS; - if (platdata->tx_fifo_sz_nb) { + if (plat->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS) + plat->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS; + if (plat->tx_fifo_sz_nb) { ret = dev_read_u32_array(dev, "g-tx-fifo-size", - platdata->tx_fifo_sz_array, - platdata->tx_fifo_sz_nb); + plat->tx_fifo_sz_array, + plat->tx_fifo_sz_nb); if (ret) return ret; } - platdata->force_b_session_valid = + plat->force_b_session_valid = dev_read_bool(dev, "u-boot,force-b-session-valid"); - platdata->force_vbus_detection = + plat->force_vbus_detection = dev_read_bool(dev, "u-boot,force-vbus-detection"); - /* force platdata according compatible */ + /* force plat according compatible */ drvdata = dev_get_driver_data(dev); if (drvdata) { set_params = (void *)drvdata; - set_params(platdata); + set_params(plat); } return 0; @@ -1091,10 +1090,10 @@ static int dwc2_udc_otg_clk_init(struct udevice *dev, static int dwc2_udc_otg_probe(struct udevice *dev) { - struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev); + struct dwc2_plat_otg_data *plat = dev_get_plat(dev); struct dwc2_priv_data *priv = dev_get_priv(dev); struct dwc2_usbotg_reg *usbotg_reg = - (struct dwc2_usbotg_reg *)platdata->regs_otg; + (struct dwc2_usbotg_reg *)plat->regs_otg; int ret; ret = dwc2_udc_otg_clk_init(dev, &priv->clks); @@ -1109,10 +1108,10 @@ static int dwc2_udc_otg_probe(struct udevice *dev) if (ret) return ret; - if (platdata->activate_stm_id_vb_detection) { + if (plat->activate_stm_id_vb_detection) { if (CONFIG_IS_ENABLED(DM_REGULATOR) && - (!platdata->force_b_session_valid || - platdata->force_vbus_detection)) { + (!plat->force_b_session_valid || + plat->force_vbus_detection)) { ret = device_get_supply_regulator(dev, "usb33d-supply", &priv->usb33d_supply); if (ret) { @@ -1126,8 +1125,8 @@ static int dwc2_udc_otg_probe(struct udevice *dev) } } - if (platdata->force_b_session_valid && - !platdata->force_vbus_detection) { + if (plat->force_b_session_valid && + !plat->force_vbus_detection) { /* Override VBUS detection: enable then value*/ setbits_le32(&usbotg_reg->gotgctl, VB_VALOEN); setbits_le32(&usbotg_reg->gotgctl, VB_VALOVAL); @@ -1136,7 +1135,7 @@ static int dwc2_udc_otg_probe(struct udevice *dev) setbits_le32(&usbotg_reg->ggpio, GGPIO_STM32_OTG_GCCFG_VBDEN); } - if (platdata->force_b_session_valid) { + if (plat->force_b_session_valid) { /* Override B session bits: enable then value */ setbits_le32(&usbotg_reg->gotgctl, A_VALOEN | B_VALOEN); setbits_le32(&usbotg_reg->gotgctl, @@ -1148,7 +1147,7 @@ static int dwc2_udc_otg_probe(struct udevice *dev) } } - ret = dwc2_udc_probe(platdata); + ret = dwc2_udc_probe(plat); if (ret) return ret; @@ -1186,18 +1185,18 @@ U_BOOT_DRIVER(dwc2_udc_otg) = { .name = "dwc2-udc-otg", .id = UCLASS_USB_GADGET_GENERIC, .of_match = dwc2_udc_otg_ids, - .ofdata_to_platdata = dwc2_udc_otg_ofdata_to_platdata, + .of_to_plat = dwc2_udc_otg_of_to_plat, .probe = dwc2_udc_otg_probe, .remove = dwc2_udc_otg_remove, - .platdata_auto_alloc_size = sizeof(struct dwc2_plat_otg_data), - .priv_auto_alloc_size = sizeof(struct dwc2_priv_data), + .plat_auto = sizeof(struct dwc2_plat_otg_data), + .priv_auto = sizeof(struct dwc2_priv_data), }; int dwc2_udc_B_session_valid(struct udevice *dev) { - struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev); + struct dwc2_plat_otg_data *plat = dev_get_plat(dev); struct dwc2_usbotg_reg *usbotg_reg = - (struct dwc2_usbotg_reg *)platdata->regs_otg; + (struct dwc2_usbotg_reg *)plat->regs_otg; return readl(&usbotg_reg->gotgctl) & B_SESSION_VALID; } diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index a8e8bfc04b..16922ff15c 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -1860,10 +1860,18 @@ static int rndis_control_ack(struct eth_device *net) static int rndis_control_ack(struct udevice *net) #endif { - struct ether_priv *priv = (struct ether_priv *)net->priv; - struct eth_dev *dev = &priv->ethdev; - int length; - struct usb_request *resp = dev->stat_req; + struct ether_priv *priv; + struct eth_dev *dev; + int length; + struct usb_request *resp; + +#ifndef CONFIG_DM_ETH + priv = (struct ether_priv *)net->priv; +#else + priv = dev_get_priv(net); +#endif + dev = &priv->ethdev; + resp = dev->stat_req; /* in case RNDIS calls this after disconnect */ if (!dev->status) { @@ -2009,7 +2017,7 @@ static int eth_bind(struct usb_gadget *gadget) int gcnum; u8 tmp[7]; #ifdef CONFIG_DM_ETH - struct eth_pdata *pdata = dev_get_platdata(l_priv->netdev); + struct eth_pdata *pdata = dev_get_plat(l_priv->netdev); #endif /* these flags are only ever cleared; compiler take note */ @@ -2646,7 +2654,7 @@ static void usb_eth_stop(struct udevice *dev) static int usb_eth_probe(struct udevice *dev) { struct ether_priv *priv = dev_get_priv(dev); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); priv->netdev = dev; l_priv = priv; @@ -2691,8 +2699,8 @@ U_BOOT_DRIVER(eth_usb) = { .id = UCLASS_ETH, .probe = usb_eth_probe, .ops = &usb_eth_ops, - .priv_auto_alloc_size = sizeof(struct ether_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct ether_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif /* CONFIG_DM_ETH */ diff --git a/drivers/usb/gadget/max3420_udc.c b/drivers/usb/gadget/max3420_udc.c index b38b9dc68f..a16095f892 100644 --- a/drivers/usb/gadget/max3420_udc.c +++ b/drivers/usb/gadget/max3420_udc.c @@ -819,14 +819,14 @@ int dm_usb_gadget_handle_interrupts(struct udevice *dev) static int max3420_udc_probe(struct udevice *dev) { struct max3420_udc *udc = dev_get_priv(dev); - struct dm_spi_slave_platdata *slave_pdata; + struct dm_spi_slave_plat *slave_pdata; struct udevice *bus = dev->parent; - int busnum = bus->seq; + int busnum = dev_seq(bus); unsigned int cs; uint speed, mode; struct udevice *spid; - slave_pdata = dev_get_parent_platdata(dev); + slave_pdata = dev_get_parent_plat(dev); cs = slave_pdata->cs; speed = slave_pdata->max_hz; mode = slave_pdata->mode; @@ -871,5 +871,5 @@ U_BOOT_DRIVER(max3420_generic_udc) = { .of_match = max3420_ids, .probe = max3420_udc_probe, .remove = max3420_udc_remove, - .priv_auto_alloc_size = sizeof(struct max3420_udc), + .priv_auto = sizeof(struct max3420_udc), }; diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index f1d13b1c1d..ec643e9f45 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -1326,7 +1326,7 @@ static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev, nonblock); } -static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) +static int dwc2_usb_of_to_plat(struct udevice *dev) { struct dwc2_priv *priv = dev_get_priv(dev); @@ -1473,11 +1473,11 @@ U_BOOT_DRIVER(usb_dwc2) = { .name = "dwc2_usb", .id = UCLASS_USB, .of_match = dwc2_usb_ids, - .ofdata_to_platdata = dwc2_usb_ofdata_to_platdata, + .of_to_plat = dwc2_usb_of_to_plat, .probe = dwc2_usb_probe, .remove = dwc2_usb_remove, .ops = &dwc2_usb_ops, - .priv_auto_alloc_size = sizeof(struct dwc2_priv), + .priv_auto = sizeof(struct dwc2_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/usb/host/dwc3-octeon-glue.c b/drivers/usb/host/dwc3-octeon-glue.c index c3cac9c5ab..742e156cbb 100644 --- a/drivers/usb/host/dwc3-octeon-glue.c +++ b/drivers/usb/host/dwc3-octeon-glue.c @@ -366,7 +366,7 @@ static int octeon_dwc3_glue_bind(struct udevice *dev) /* Find snps,dwc3 node from subnode */ dwc3_node = ofnode_null(); - ofnode_for_each_subnode(node, dev->node) { + ofnode_for_each_subnode(node, dev_ofnode(dev)) { if (ofnode_device_is_compatible(node, "snps,dwc3")) dwc3_node = node; } diff --git a/drivers/usb/host/dwc3-of-simple.c b/drivers/usb/host/dwc3-of-simple.c index e4abc6f3b9..66b3e96b00 100644 --- a/drivers/usb/host/dwc3-of-simple.c +++ b/drivers/usb/host/dwc3-of-simple.c @@ -64,7 +64,7 @@ static int dwc3_of_simple_clk_init(struct udevice *dev, static int dwc3_of_simple_probe(struct udevice *dev) { - struct dwc3_of_simple *simple = dev_get_platdata(dev); + struct dwc3_of_simple *simple = dev_get_plat(dev); int ret; ret = dwc3_of_simple_clk_init(dev, simple); @@ -80,7 +80,7 @@ static int dwc3_of_simple_probe(struct udevice *dev) static int dwc3_of_simple_remove(struct udevice *dev) { - struct dwc3_of_simple *simple = dev_get_platdata(dev); + struct dwc3_of_simple *simple = dev_get_plat(dev); reset_release_bulk(&simple->resets); @@ -102,6 +102,6 @@ U_BOOT_DRIVER(dwc3_of_simple) = { .of_match = dwc3_of_simple_ids, .probe = dwc3_of_simple_probe, .remove = dwc3_of_simple_remove, - .platdata_auto_alloc_size = sizeof(struct dwc3_of_simple), + .plat_auto = sizeof(struct dwc3_of_simple), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c index 9dec087738..1234399f33 100644 --- a/drivers/usb/host/dwc3-sti-glue.c +++ b/drivers/usb/host/dwc3-sti-glue.c @@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR; /* - * struct sti_dwc3_glue_platdata - dwc3 STi glue driver private structure + * struct sti_dwc3_glue_plat - dwc3 STi glue driver private structure * @syscfg_base: addr for the glue syscfg * @glue_base: addr for the glue registers * @syscfg_offset: usb syscfg control offset @@ -32,7 +32,7 @@ DECLARE_GLOBAL_DATA_PTR; * @softreset_ctl: reset controller for softreset signal * @mode: drd static host/device config */ -struct sti_dwc3_glue_platdata { +struct sti_dwc3_glue_plat { phys_addr_t syscfg_base; phys_addr_t glue_base; phys_addr_t syscfg_offset; @@ -41,7 +41,7 @@ struct sti_dwc3_glue_platdata { enum usb_dr_mode mode; }; -static int sti_dwc3_glue_drd_init(struct sti_dwc3_glue_platdata *plat) +static int sti_dwc3_glue_drd_init(struct sti_dwc3_glue_plat *plat) { unsigned long val; @@ -77,7 +77,7 @@ static int sti_dwc3_glue_drd_init(struct sti_dwc3_glue_platdata *plat) return 0; } -static void sti_dwc3_glue_init(struct sti_dwc3_glue_platdata *plat) +static void sti_dwc3_glue_init(struct sti_dwc3_glue_plat *plat) { unsigned long reg; @@ -100,15 +100,16 @@ static void sti_dwc3_glue_init(struct sti_dwc3_glue_platdata *plat) setbits_le32(plat->glue_base + CLKRST_CTRL, SW_PIPEW_RESET_N); } -static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev) +static int sti_dwc3_glue_of_to_plat(struct udevice *dev) { - struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev); + struct sti_dwc3_glue_plat *plat = dev_get_plat(dev); struct udevice *syscon; struct regmap *regmap; int ret; u32 reg[4]; - ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg)); + ret = ofnode_read_u32_array(dev_ofnode(dev), "reg", reg, + ARRAY_SIZE(reg)); if (ret) { pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret); return ret; @@ -150,11 +151,11 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev) static int sti_dwc3_glue_bind(struct udevice *dev) { - struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev); + struct sti_dwc3_glue_plat *plat = dev_get_plat(dev); ofnode node, dwc3_node; /* Find snps,dwc3 node from subnode */ - ofnode_for_each_subnode(node, dev->node) { + ofnode_for_each_subnode(node, dev_ofnode(dev)) { if (ofnode_device_is_compatible(node, "snps,dwc3")) dwc3_node = node; } @@ -175,7 +176,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev) static int sti_dwc3_glue_probe(struct udevice *dev) { - struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev); + struct sti_dwc3_glue_plat *plat = dev_get_plat(dev); int ret; /* deassert both powerdown and softreset */ @@ -216,7 +217,7 @@ softreset_err: static int sti_dwc3_glue_remove(struct udevice *dev) { - struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev); + struct sti_dwc3_glue_plat *plat = dev_get_plat(dev); int ret; /* assert both powerdown and softreset */ @@ -242,10 +243,10 @@ U_BOOT_DRIVER(dwc3_sti_glue) = { .name = "dwc3_sti_glue", .id = UCLASS_NOP, .of_match = sti_dwc3_glue_ids, - .ofdata_to_platdata = sti_dwc3_glue_ofdata_to_platdata, + .of_to_plat = sti_dwc3_glue_of_to_plat, .probe = sti_dwc3_glue_probe, .remove = sti_dwc3_glue_remove, .bind = sti_dwc3_glue_bind, - .platdata_auto_alloc_size = sizeof(struct sti_dwc3_glue_platdata), + .plat_auto = sizeof(struct sti_dwc3_glue_plat), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 3b208e8eb2..fba3595e10 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -124,8 +124,8 @@ U_BOOT_DRIVER(ehci_atmel) = { .probe = ehci_atmel_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_atmel_priv), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_atmel_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 6a37c5d982..fda04c4933 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -26,8 +26,8 @@ /* Declare global data pointer */ DECLARE_GLOBAL_DATA_PTR; -struct exynos_ehci_platdata { - struct usb_platdata usb_plat; +struct exynos_ehci_plat { + struct usb_plat usb_plat; fdt_addr_t hcd_base; fdt_addr_t phy_base; struct gpio_desc vbus_gpio; @@ -43,9 +43,9 @@ struct exynos_ehci { struct ehci_hccr *hcd; }; -static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +static int ehci_usb_of_to_plat(struct udevice *dev) { - struct exynos_ehci_platdata *plat = dev_get_platdata(dev); + struct exynos_ehci_plat *plat = dev_get_plat(dev); const void *blob = gd->fdt_blob; unsigned int node; int depth; @@ -214,7 +214,7 @@ static void reset_usb_phy(struct exynos_usb_phy *usb) static int ehci_usb_probe(struct udevice *dev) { - struct exynos_ehci_platdata *plat = dev_get_platdata(dev); + struct exynos_ehci_plat *plat = dev_get_plat(dev); struct exynos_ehci *ctx = dev_get_priv(dev); struct ehci_hcor *hcor; @@ -254,11 +254,11 @@ U_BOOT_DRIVER(usb_ehci) = { .name = "ehci_exynos", .id = UCLASS_USB, .of_match = ehci_usb_ids, - .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .of_to_plat = ehci_usb_of_to_plat, .probe = ehci_usb_probe, .remove = ehci_usb_remove, .ops = &ehci_usb_ops, - .priv_auto_alloc_size = sizeof(struct exynos_ehci), - .platdata_auto_alloc_size = sizeof(struct exynos_ehci_platdata), + .priv_auto = sizeof(struct exynos_ehci), + .plat_auto = sizeof(struct exynos_ehci_plat), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 5423d10abe..8e79bdd847 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -58,7 +58,7 @@ static int usb_phy_clk_valid(struct usb_ehci *ehci) } #if CONFIG_IS_ENABLED(DM_USB) -static int ehci_fsl_ofdata_to_platdata(struct udevice *dev) +static int ehci_fsl_of_to_plat(struct udevice *dev) { struct ehci_fsl_priv *priv = dev_get_priv(dev); const void *prop; @@ -141,12 +141,12 @@ U_BOOT_DRIVER(ehci_fsl) = { .name = "ehci_fsl", .id = UCLASS_USB, .of_match = ehci_usb_ids, - .ofdata_to_platdata = ehci_fsl_ofdata_to_platdata, + .of_to_plat = ehci_fsl_of_to_plat, .probe = ehci_fsl_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_fsl_priv), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_fsl_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #else diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c index c93a7051a7..4c28a69b98 100644 --- a/drivers/usb/host/ehci-generic.c +++ b/drivers/usb/host/ehci-generic.c @@ -221,6 +221,6 @@ U_BOOT_DRIVER(ehci_generic) = { .probe = ehci_usb_probe, .remove = ehci_usb_remove, .ops = &ehci_usb_ops, - .priv_auto_alloc_size = sizeof(struct generic_ehci), + .priv_auto = sizeof(struct generic_ehci), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 62414bb110..3ecbfd032f 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -152,8 +152,8 @@ U_BOOT_DRIVER(ehci_mvebu) = { .probe = ehci_mvebu_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_mvebu_priv), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_mvebu_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index dd92808ff7..d160cf019d 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -47,7 +47,7 @@ static int ehci_usb_probe(struct udevice *dev) { struct msm_ehci_priv *p = dev_get_priv(dev); struct usb_ehci *ehci = p->ehci; - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); struct ehci_hccr *hccr; struct ehci_hcor *hcor; int ret; @@ -101,7 +101,7 @@ static int ehci_usb_remove(struct udevice *dev) return 0; } -static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +static int ehci_usb_of_to_plat(struct udevice *dev) { struct msm_ehci_priv *priv = dev_get_priv(dev); @@ -140,11 +140,11 @@ U_BOOT_DRIVER(usb_ehci) = { .name = "ehci_msm", .id = UCLASS_USB, .of_match = ehci_usb_ids, - .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .of_to_plat = ehci_usb_of_to_plat, .probe = ehci_usb_probe, .remove = ehci_usb_remove, .ops = &ehci_usb_ops, - .priv_auto_alloc_size = sizeof(struct msm_ehci_priv), - .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto = sizeof(struct msm_ehci_priv), + .plat_auto = sizeof(struct usb_plat), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-mx5.c b/drivers/usb/host/ehci-mx5.c index caafa68899..0af02ba273 100644 --- a/drivers/usb/host/ehci-mx5.c +++ b/drivers/usb/host/ehci-mx5.c @@ -285,9 +285,9 @@ static const struct ehci_ops mx5_ehci_ops = { .powerup_fixup = mx5_ehci_powerup_fixup, }; -static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +static int ehci_usb_of_to_plat(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); const char *mode; mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "dr_mode", NULL); @@ -305,7 +305,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) static int ehci_usb_probe(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); struct usb_ehci *ehci = dev_read_addr_ptr(dev); struct ehci_mx5_priv_data *priv = dev_get_priv(dev); enum usb_init_type type = plat->init_type; @@ -321,7 +321,7 @@ static int ehci_usb_probe(struct udevice *dev) mdelay(1); priv->ehci = ehci; - priv->portnr = dev->seq; + priv->portnr = dev_seq(dev); priv->init_type = type; ret = device_get_supply_regulator(dev, "vbus-supply", @@ -363,12 +363,12 @@ U_BOOT_DRIVER(usb_mx5) = { .name = "ehci_mx5", .id = UCLASS_USB, .of_match = mx5_usb_ids, - .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .of_to_plat = ehci_usb_of_to_plat, .probe = ehci_usb_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_mx5_priv_data), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_mx5_priv_data), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif /* !CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 37b59758bb..ef3a63afa4 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -472,7 +472,7 @@ static const struct ehci_ops mx6_ehci_ops = { static int ehci_usb_phy_mode(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); void *__iomem addr = dev_read_addr_ptr(dev); void *__iomem phy_ctrl, *__iomem phy_status; const void *blob = gd->fdt_blob; @@ -518,12 +518,12 @@ static int ehci_usb_phy_mode(struct udevice *dev) return 0; } -static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +static int ehci_usb_of_to_plat(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); enum usb_dr_mode dr_mode; - dr_mode = usb_get_dr_mode(dev->node); + dr_mode = usb_get_dr_mode(dev_ofnode(dev)); switch (dr_mode) { case USB_DR_MODE_HOST: @@ -569,17 +569,23 @@ static int ehci_usb_bind(struct udevice *dev) * With these changes in place, the ad-hoc indexing goes away and * the driver is fully converted to DT probing. */ - u32 controller_spacing = is_mx7() ? 0x10000 : 0x200; - fdt_addr_t addr = devfdt_get_addr_index(dev, 0); - dev->req_seq = (addr - USB_BASE_ADDR) / controller_spacing; + /* + * FIXME: This cannot work with the new sequence numbers. + * Please complete the DM conversion. + * + * u32 controller_spacing = is_mx7() ? 0x10000 : 0x200; + * fdt_addr_t addr = devfdt_get_addr_index(dev, 0); + * + * dev->req_seq = (addr - USB_BASE_ADDR) / controller_spacing; + */ return 0; } static int ehci_usb_probe(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); struct usb_ehci *ehci = dev_read_addr_ptr(dev); struct ehci_mx6_priv_data *priv = dev_get_priv(dev); enum usb_init_type type = plat->init_type; @@ -596,7 +602,7 @@ static int ehci_usb_probe(struct udevice *dev) } priv->ehci = ehci; - priv->portnr = dev->seq; + priv->portnr = dev_seq(dev); priv->init_type = type; #if CONFIG_IS_ENABLED(DM_REGULATOR) @@ -645,13 +651,13 @@ U_BOOT_DRIVER(usb_mx6) = { .name = "ehci_mx6", .id = UCLASS_USB, .of_match = mx6_usb_ids, - .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .of_to_plat = ehci_usb_of_to_plat, .bind = ehci_usb_bind, .probe = ehci_usb_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_mx6_priv_data), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_mx6_priv_data), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 82b99eeef1..12c422d811 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -366,9 +366,9 @@ struct ehci_omap_priv_data { int nports; }; -static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +static int ehci_usb_of_to_plat(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); plat->init_type = USB_INIT_HOST; @@ -377,13 +377,13 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) static int omap_ehci_probe(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); struct ehci_omap_priv_data *priv = dev_get_priv(dev); struct ehci_hccr *hccr; struct ehci_hcor *hcor; priv->ehci = dev_read_addr_ptr(dev); - priv->portnr = dev->seq; + priv->portnr = dev_seq(dev); priv->init_type = plat->init_type; hccr = (struct ehci_hccr *)&priv->ehci->hccapbase; @@ -402,9 +402,9 @@ U_BOOT_DRIVER(usb_omap_ehci) = { .id = UCLASS_USB, .of_match = omap_ehci_dt_ids, .probe = omap_ehci_probe, - .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_omap_priv_data), + .of_to_plat = ehci_usb_of_to_plat, + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_omap_priv_data), .remove = ehci_deregister, .ops = &ehci_usb_ops, .flags = DM_FLAG_ALLOC_PRIV_DMA, diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 7dd5c33c13..4f711de7d8 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -163,8 +163,8 @@ U_BOOT_DRIVER(ehci_pci) = { .remove = ehci_pci_remove, .of_match = ehci_pci_ids, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_pci_priv), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_pci_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index d81f4a03f1..b02ee89c3e 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -812,7 +812,7 @@ static const struct ehci_ops tegra_ehci_ops = { .powerup_fixup = tegra_ehci_powerup_fixup, }; -static int ehci_usb_ofdata_to_platdata(struct udevice *dev) +static int ehci_usb_of_to_plat(struct udevice *dev) { struct fdt_usb *priv = dev_get_priv(dev); int ret; @@ -828,7 +828,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) static int ehci_usb_probe(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); struct fdt_usb *priv = dev_get_priv(dev); struct ehci_hccr *hccr; struct ehci_hcor *hcor; @@ -861,11 +861,11 @@ U_BOOT_DRIVER(usb_ehci) = { .name = "ehci_tegra", .id = UCLASS_USB, .of_match = ehci_usb_ids, - .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, + .of_to_plat = ehci_usb_of_to_plat, .probe = ehci_usb_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct fdt_usb), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct fdt_usb), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 2768d40974..25f76c9fa9 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -215,14 +215,14 @@ struct ehci_vf_priv_data { u32 portnr; }; -static int vf_usb_ofdata_to_platdata(struct udevice *dev) +static int vf_usb_of_to_plat(struct udevice *dev) { struct ehci_vf_priv_data *priv = dev_get_priv(dev); const void *dt_blob = gd->fdt_blob; int node = dev_of_offset(dev); const char *mode; - priv->portnr = dev->seq; + priv->portnr = dev_seq(dev); priv->ehci = dev_read_addr_ptr(dev); mode = fdt_getprop(dt_blob, node, "dr_mode", NULL); @@ -296,23 +296,21 @@ static const struct ehci_ops vf_ehci_ops = { static int vf_usb_bind(struct udevice *dev) { - static int num_controllers; - /* * Without this hack, if we return ENODEV for USB Controller 0, on * probe for the next controller, USB Controller 1 will be given a * sequence number of 0. This conflicts with our requirement of * sequence numbers while initialising the peripherals. + * + * FIXME: Check that this still works OK with the new sequence numbers */ - dev->req_seq = num_controllers; - num_controllers++; return 0; } static int ehci_usb_probe(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); struct ehci_vf_priv_data *priv = dev_get_priv(dev); struct usb_ehci *ehci = priv->ehci; struct ehci_hccr *hccr; @@ -354,9 +352,9 @@ U_BOOT_DRIVER(usb_ehci) = { .probe = ehci_usb_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .ofdata_to_platdata = vf_usb_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct ehci_vf_priv_data), + .of_to_plat = vf_usb_of_to_plat, + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct ehci_vf_priv_data), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/usb/host/ehci-zynq.c b/drivers/usb/host/ehci-zynq.c index 80f1d6fd97..f7e458cb15 100644 --- a/drivers/usb/host/ehci-zynq.c +++ b/drivers/usb/host/ehci-zynq.c @@ -21,7 +21,7 @@ struct zynq_ehci_priv { struct usb_ehci *ehci; }; -static int ehci_zynq_ofdata_to_platdata(struct udevice *dev) +static int ehci_zynq_of_to_plat(struct udevice *dev) { struct zynq_ehci_priv *priv = dev_get_priv(dev); @@ -34,7 +34,7 @@ static int ehci_zynq_ofdata_to_platdata(struct udevice *dev) static int ehci_zynq_probe(struct udevice *dev) { - struct usb_platdata *plat = dev_get_platdata(dev); + struct usb_plat *plat = dev_get_plat(dev); struct zynq_ehci_priv *priv = dev_get_priv(dev); struct ehci_hccr *hccr; struct ehci_hcor *hcor; @@ -81,11 +81,11 @@ U_BOOT_DRIVER(ehci_zynq) = { .name = "ehci_zynq", .id = UCLASS_USB, .of_match = ehci_zynq_ids, - .ofdata_to_platdata = ehci_zynq_ofdata_to_platdata, + .of_to_plat = ehci_zynq_of_to_plat, .probe = ehci_zynq_probe, .remove = ehci_deregister, .ops = &ehci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct zynq_ehci_priv), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct zynq_ehci_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index aa1eba262a..33c4a911a0 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c @@ -174,7 +174,7 @@ U_BOOT_DRIVER(ohci_generic) = { .probe = ohci_da8xx_probe, .remove = ohci_da8xx_remove, .ops = &ohci_usb_ops, - .priv_auto_alloc_size = sizeof(struct da8xx_ohci), + .priv_auto = sizeof(struct da8xx_ohci), .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_OS_PREPARE, }; #endif diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c index ac9b7e1e3c..163f0ef17b 100644 --- a/drivers/usb/host/ohci-generic.c +++ b/drivers/usb/host/ohci-generic.c @@ -198,6 +198,6 @@ U_BOOT_DRIVER(ohci_generic) = { .probe = ohci_usb_probe, .remove = ohci_usb_remove, .ops = &ohci_usb_ops, - .priv_auto_alloc_size = sizeof(struct generic_ohci), + .priv_auto = sizeof(struct generic_ohci), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 4c1c778672..6ddc9da704 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -39,8 +39,8 @@ U_BOOT_DRIVER(ohci_pci) = { .remove = ohci_pci_remove, .of_match = ohci_pci_ids, .ops = &ohci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(ohci_t), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(ohci_t), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 37aa2c55f2..f1fc93f3d4 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c @@ -805,7 +805,7 @@ static int r8a66597_submit_bulk_msg(struct udevice *udev, return ret; } -static int r8a66597_usb_ofdata_to_platdata(struct udevice *dev) +static int r8a66597_usb_of_to_plat(struct udevice *dev) { struct r8a66597 *priv = dev_get_priv(dev); fdt_addr_t addr; @@ -890,10 +890,10 @@ U_BOOT_DRIVER(usb_r8a66597) = { .name = "r8a66597_usb", .id = UCLASS_USB, .of_match = r8a66597_usb_ids, - .ofdata_to_platdata = r8a66597_usb_ofdata_to_platdata, + .of_to_plat = r8a66597_usb_of_to_plat, .probe = r8a66597_usb_probe, .remove = r8a66597_usb_remove, .ops = &r8a66597_usb_ops, - .priv_auto_alloc_size = sizeof(struct r8a66597), + .priv_auto = sizeof(struct r8a66597), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c index beb62ebc0c..d7cc92aa54 100644 --- a/drivers/usb/host/usb-sandbox.c +++ b/drivers/usb/host/usb-sandbox.c @@ -23,7 +23,7 @@ static void usbmon_trace(struct udevice *bus, ulong pipe, type = (pipe & USB_PIPE_TYPE_MASK) >> USB_PIPE_TYPE_SHIFT; debug("0 0 S %c%c:%d:%03ld:%ld", types[type], pipe & USB_DIR_IN ? 'i' : 'o', - bus->seq, + dev_seq(bus), (pipe & USB_PIPE_DEV_MASK) >> USB_PIPE_DEV_SHIFT, (pipe & USB_PIPE_EP_MASK) >> USB_PIPE_EP_SHIFT); if (setup) { @@ -155,5 +155,5 @@ U_BOOT_DRIVER(usb_sandbox) = { .of_match = sandbox_usb_ids, .probe = sandbox_usb_probe, .ops = &sandbox_usb_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_usb_ctrl), + .priv_auto = sizeof(struct sandbox_usb_ctrl), }; diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 8773824e05..e3b616c326 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -60,7 +60,7 @@ int submit_control_msg(struct usb_device *udev, unsigned long pipe, { struct udevice *bus = udev->controller_dev; struct dm_usb_ops *ops = usb_get_ops(bus); - struct usb_uclass_priv *uc_priv = bus->uclass->priv; + struct usb_uclass_priv *uc_priv = uclass_get_priv(bus->uclass); int err; if (!ops->control) @@ -184,7 +184,7 @@ int usb_stop(void) if (ret) return ret; - uc_priv = uc->priv; + uc_priv = uclass_get_priv(uc); uclass_foreach_dev(bus, uc) { ret = device_remove(bus, DM_REMOVE_NORMAL); @@ -263,7 +263,7 @@ int usb_init(void) if (ret) return ret; - uc_priv = uc->priv; + uc_priv = uclass_get_priv(uc); uclass_foreach_dev(bus, uc) { /* init low_level USB */ @@ -389,19 +389,19 @@ struct usb_device *usb_get_dev_index(struct udevice *bus, int index) int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) { - struct usb_platdata *plat; + struct usb_plat *plat; struct udevice *dev; int ret; /* Find the old device and remove it */ - ret = uclass_find_device_by_seq(UCLASS_USB, 0, true, &dev); + ret = uclass_find_device_by_seq(UCLASS_USB, 0, &dev); if (ret) return ret; ret = device_remove(dev, DM_REMOVE_NORMAL); if (ret) return ret; - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); plat->init_type = USB_INIT_DEVICE; ret = device_probe(dev); if (ret) @@ -417,7 +417,7 @@ int usb_remove_ehci_gadget(struct ehci_ctrl **ctlrp) int ret; /* Find the old device and remove it */ - ret = uclass_find_device_by_seq(UCLASS_USB, 0, true, &dev); + ret = uclass_find_device_by_seq(UCLASS_USB, 0, &dev); if (ret) return ret; ret = device_remove(dev, DM_REMOVE_NORMAL); @@ -517,7 +517,7 @@ static ofnode usb_get_ofnode(struct udevice *hub, int port) ofnode node; u32 reg; - if (!dev_has_of_node(hub)) + if (!dev_has_ofnode(hub)) return ofnode_null(); /* @@ -566,7 +566,7 @@ static int usb_find_and_bind_driver(struct udevice *parent, const struct usb_device_id *id; struct udevice *dev; const struct driver *drv; - struct usb_dev_platdata *plat; + struct usb_dev_plat *plat; for (id = entry->match; id->match_flags; id++) { if (!usb_match_one_id(desc, iface, id)) @@ -575,19 +575,19 @@ static int usb_find_and_bind_driver(struct udevice *parent, drv = entry->driver; /* * We could pass the descriptor to the driver as - * platdata (instead of NULL) and allow its bind() + * plat (instead of NULL) and allow its bind() * method to return -ENOENT if it doesn't support this * device. That way we could continue the search to * find another driver. For now this doesn't seem * necesssary, so just bind the first match. */ - ret = device_bind_ofnode(parent, drv, drv->name, NULL, - node, &dev); + ret = device_bind(parent, drv, drv->name, NULL, node, + &dev); if (ret) goto error; debug("%s: Match found: %s\n", __func__, drv->name); dev->driver_data = id->driver_info; - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); plat->id = *id; *devp = dev; return 0; @@ -622,7 +622,7 @@ static int usb_find_child(struct udevice *parent, for (device_find_first_child(parent, &dev); dev; device_find_next_child(&dev)) { - struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); + struct usb_dev_plat *plat = dev_get_parent_plat(dev); /* If this device is already in use, skip it */ if (device_active(dev)) @@ -643,7 +643,7 @@ int usb_scan_device(struct udevice *parent, int port, { struct udevice *dev; bool created = false; - struct usb_dev_platdata *plat; + struct usb_dev_plat *plat; struct usb_bus_priv *priv; struct usb_device *parent_udev; int ret; @@ -701,13 +701,13 @@ int usb_scan_device(struct udevice *parent, int port, return ret; ret = usb_find_and_bind_driver(parent, &udev->descriptor, iface, - udev->controller_dev->seq, + dev_seq(udev->controller_dev), udev->devnum, port, &dev); if (ret) return ret; created = true; } - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); debug("%s: Probing '%s', plat=%p\n", __func__, dev->name, plat); plat->devnum = udev->devnum; plat->udev = udev; @@ -770,10 +770,10 @@ int usb_detect_change(void) static int usb_child_post_bind(struct udevice *dev) { - struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); + struct usb_dev_plat *plat = dev_get_parent_plat(dev); int val; - if (!dev_of_valid(dev)) + if (!dev_has_ofnode(dev)) return 0; /* We only support matching a few things */ @@ -809,7 +809,7 @@ struct udevice *usb_get_bus(struct udevice *dev) int usb_child_pre_probe(struct udevice *dev) { struct usb_device *udev = dev_get_parent_priv(dev); - struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); + struct usb_dev_plat *plat = dev_get_parent_plat(dev); int ret; if (plat->udev) { @@ -849,12 +849,12 @@ UCLASS_DRIVER(usb) = { .name = "usb", .flags = DM_UC_FLAG_SEQ_ALIAS, .post_bind = dm_scan_fdt_dev, - .priv_auto_alloc_size = sizeof(struct usb_uclass_priv), - .per_child_auto_alloc_size = sizeof(struct usb_device), - .per_device_auto_alloc_size = sizeof(struct usb_bus_priv), + .priv_auto = sizeof(struct usb_uclass_priv), + .per_child_auto = sizeof(struct usb_device), + .per_device_auto = sizeof(struct usb_bus_priv), .child_post_bind = usb_child_post_bind, .child_pre_probe = usb_child_pre_probe, - .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), + .per_child_plat_auto = sizeof(struct usb_dev_plat), }; UCLASS_DRIVER(usb_dev_generic) = { diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c index ee65f51c5d..27c4bbfcba 100644 --- a/drivers/usb/host/xhci-brcm.c +++ b/drivers/usb/host/xhci-brcm.c @@ -22,7 +22,7 @@ #define USBAXI_SA_UA_MASK (USBAXI_UA_MASK | USBAXI_SA_MASK) #define USBAXI_SA_UA_VAL (USBAXI_UA_VAL | USBAXI_SA_VAL) -struct brcm_xhci_platdata { +struct brcm_xhci_plat { unsigned int arcache; unsigned int awcache; void __iomem *hc_base; @@ -30,7 +30,7 @@ struct brcm_xhci_platdata { static int xhci_brcm_probe(struct udevice *dev) { - struct brcm_xhci_platdata *plat = dev_get_platdata(dev); + struct brcm_xhci_plat *plat = dev_get_plat(dev); struct xhci_hcor *hcor; struct xhci_hccr *hcd; int len, ret = 0; @@ -71,7 +71,7 @@ static int xhci_brcm_probe(struct udevice *dev) static int xhci_brcm_deregister(struct udevice *dev) { - struct brcm_xhci_platdata *plat = dev_get_platdata(dev); + struct brcm_xhci_plat *plat = dev_get_plat(dev); /* Restore the default values for AXI read and write attributes */ writel(plat->awcache, plat->hc_base + DRD2U3H_XHC_REGS_AXIWRA); @@ -92,7 +92,7 @@ U_BOOT_DRIVER(usb_xhci) = { .remove = xhci_brcm_deregister, .ops = &xhci_usb_ops, .of_match = xhci_brcm_ids, - .platdata_auto_alloc_size = sizeof(struct brcm_xhci_platdata), - .priv_auto_alloc_size = sizeof(struct xhci_ctrl), + .plat_auto = sizeof(struct brcm_xhci_plat), + .priv_auto = sizeof(struct xhci_ctrl), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index 045de2ffde..3e0ae80cec 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -20,7 +20,7 @@ #include <linux/usb/dwc3.h> #include <linux/usb/otg.h> -struct xhci_dwc3_platdata { +struct xhci_dwc3_plat { struct phy_bulk phys; }; @@ -117,7 +117,7 @@ static int xhci_dwc3_probe(struct udevice *dev) struct xhci_hccr *hccr; struct dwc3 *dwc3_reg; enum usb_dr_mode dr_mode; - struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); + struct xhci_dwc3_plat *plat = dev_get_plat(dev); const char *phy; u32 reg; int ret; @@ -155,7 +155,7 @@ static int xhci_dwc3_probe(struct udevice *dev) writel(reg, &dwc3_reg->g_usb2phycfg[0]); - dr_mode = usb_get_dr_mode(dev->node); + dr_mode = usb_get_dr_mode(dev_ofnode(dev)); if (dr_mode == USB_DR_MODE_UNKNOWN) /* by default set dual role mode to HOST */ dr_mode = USB_DR_MODE_HOST; @@ -167,7 +167,7 @@ static int xhci_dwc3_probe(struct udevice *dev) static int xhci_dwc3_remove(struct udevice *dev) { - struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); + struct xhci_dwc3_plat *plat = dev_get_plat(dev); dwc3_shutdown_phy(dev, &plat->phys); @@ -186,8 +186,8 @@ U_BOOT_DRIVER(xhci_dwc3) = { .probe = xhci_dwc3_probe, .remove = xhci_dwc3_remove, .ops = &xhci_usb_ops, - .priv_auto_alloc_size = sizeof(struct xhci_ctrl), - .platdata_auto_alloc_size = sizeof(struct xhci_dwc3_platdata), + .priv_auto = sizeof(struct xhci_ctrl), + .plat_auto = sizeof(struct xhci_dwc3_plat), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #endif diff --git a/drivers/usb/host/xhci-exynos5.c b/drivers/usb/host/xhci-exynos5.c index 6fb7a7f6e0..9893a8ccce 100644 --- a/drivers/usb/host/xhci-exynos5.c +++ b/drivers/usb/host/xhci-exynos5.c @@ -34,7 +34,7 @@ /* Declare global data pointer */ DECLARE_GLOBAL_DATA_PTR; -struct exynos_xhci_platdata { +struct exynos_xhci_plat { fdt_addr_t hcd_base; fdt_addr_t phy_base; struct gpio_desc vbus_gpio; @@ -45,16 +45,16 @@ struct exynos_xhci_platdata { * for the usb controller. */ struct exynos_xhci { - struct usb_platdata usb_plat; + struct usb_plat usb_plat; struct xhci_ctrl ctrl; struct exynos_usb3_phy *usb3_phy; struct xhci_hccr *hcd; struct dwc3 *dwc3_reg; }; -static int xhci_usb_ofdata_to_platdata(struct udevice *dev) +static int xhci_usb_of_to_plat(struct udevice *dev) { - struct exynos_xhci_platdata *plat = dev_get_platdata(dev); + struct exynos_xhci_plat *plat = dev_get_plat(dev); const void *blob = gd->fdt_blob; unsigned int node; int depth; @@ -205,7 +205,7 @@ static void exynos_xhci_core_exit(struct exynos_xhci *exynos) static int xhci_usb_probe(struct udevice *dev) { - struct exynos_xhci_platdata *plat = dev_get_platdata(dev); + struct exynos_xhci_plat *plat = dev_get_plat(dev); struct exynos_xhci *ctx = dev_get_priv(dev); struct xhci_hcor *hcor; int ret; @@ -251,11 +251,11 @@ U_BOOT_DRIVER(usb_xhci) = { .name = "xhci_exynos", .id = UCLASS_USB, .of_match = xhci_usb_ids, - .ofdata_to_platdata = xhci_usb_ofdata_to_platdata, + .of_to_plat = xhci_usb_of_to_plat, .probe = xhci_usb_probe, .remove = xhci_usb_remove, .ops = &xhci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct exynos_xhci_platdata), - .priv_auto_alloc_size = sizeof(struct exynos_xhci), + .plat_auto = sizeof(struct exynos_xhci_plat), + .priv_auto = sizeof(struct exynos_xhci), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index 0a2da70e20..f062f12ade 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -169,8 +169,8 @@ U_BOOT_DRIVER(xhci_fsl) = { .probe = xhci_fsl_probe, .remove = xhci_fsl_remove, .ops = &xhci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct xhci_fsl_priv), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct xhci_fsl_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; #else diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index f62e232d21..d301acc9a8 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -300,6 +300,6 @@ U_BOOT_DRIVER(usb_xhci) = { .remove = xhci_mtk_remove, .ops = &xhci_usb_ops, .bind = dm_scan_fdt_dev, - .priv_auto_alloc_size = sizeof(struct mtk_xhci), + .priv_auto = sizeof(struct mtk_xhci), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c index f2e338f6fb..46b89de85d 100644 --- a/drivers/usb/host/xhci-mvebu.c +++ b/drivers/usb/host/xhci-mvebu.c @@ -15,7 +15,7 @@ #include <usb/xhci.h> -struct mvebu_xhci_platdata { +struct mvebu_xhci_plat { fdt_addr_t hcd_base; }; @@ -25,7 +25,7 @@ struct mvebu_xhci_platdata { */ struct mvebu_xhci { struct xhci_ctrl ctrl; /* Needs to come first in this struct! */ - struct usb_platdata usb_plat; + struct usb_plat usb_plat; struct xhci_hccr *hcd; }; @@ -40,7 +40,7 @@ __weak int board_xhci_enable(fdt_addr_t base) static int xhci_usb_probe(struct udevice *dev) { - struct mvebu_xhci_platdata *plat = dev_get_platdata(dev); + struct mvebu_xhci_plat *plat = dev_get_plat(dev); struct mvebu_xhci *ctx = dev_get_priv(dev); struct xhci_hcor *hcor; int len, ret; @@ -65,9 +65,9 @@ static int xhci_usb_probe(struct udevice *dev) return xhci_register(dev, ctx->hcd, hcor); } -static int xhci_usb_ofdata_to_platdata(struct udevice *dev) +static int xhci_usb_of_to_plat(struct udevice *dev) { - struct mvebu_xhci_platdata *plat = dev_get_platdata(dev); + struct mvebu_xhci_plat *plat = dev_get_plat(dev); /* * Get the base address for XHCI controller from the device node @@ -92,11 +92,11 @@ U_BOOT_DRIVER(usb_xhci) = { .name = "xhci_mvebu", .id = UCLASS_USB, .of_match = xhci_usb_ids, - .ofdata_to_platdata = xhci_usb_ofdata_to_platdata, + .of_to_plat = xhci_usb_of_to_plat, .probe = xhci_usb_probe, .remove = xhci_deregister, .ops = &xhci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct mvebu_xhci_platdata), - .priv_auto_alloc_size = sizeof(struct mvebu_xhci), + .plat_auto = sizeof(struct mvebu_xhci_plat), + .priv_auto = sizeof(struct mvebu_xhci), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 9fb6d2f763..2b445f21b5 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -59,8 +59,8 @@ U_BOOT_DRIVER(xhci_pci) = { .remove = xhci_deregister, .of_match = xhci_pci_ids, .ops = &xhci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct xhci_ctrl), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct xhci_ctrl), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index 5379dba566..5fc7afb7d2 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -29,7 +29,7 @@ #define RCAR_USB3_DL_CTRL_FW_SUCCESS BIT(4) #define RCAR_USB3_DL_CTRL_FW_SET_DATA0 BIT(8) -struct rcar_xhci_platdata { +struct rcar_xhci_plat { fdt_addr_t hcd_base; struct clk clk; }; @@ -40,7 +40,7 @@ struct rcar_xhci_platdata { */ struct rcar_xhci { struct xhci_ctrl ctrl; /* Needs to come first in this struct! */ - struct usb_platdata usb_plat; + struct usb_plat usb_plat; struct xhci_hccr *hcd; }; @@ -76,7 +76,7 @@ static int xhci_rcar_download_fw(struct rcar_xhci *ctx, const u32 *fw_data, static int xhci_rcar_probe(struct udevice *dev) { - struct rcar_xhci_platdata *plat = dev_get_platdata(dev); + struct rcar_xhci_plat *plat = dev_get_plat(dev); struct rcar_xhci *ctx = dev_get_priv(dev); struct xhci_hcor *hcor; int len, ret; @@ -122,7 +122,7 @@ err_clk: static int xhci_rcar_deregister(struct udevice *dev) { int ret; - struct rcar_xhci_platdata *plat = dev_get_platdata(dev); + struct rcar_xhci_plat *plat = dev_get_plat(dev); ret = xhci_deregister(dev); @@ -132,9 +132,9 @@ static int xhci_rcar_deregister(struct udevice *dev) return ret; } -static int xhci_rcar_ofdata_to_platdata(struct udevice *dev) +static int xhci_rcar_of_to_plat(struct udevice *dev) { - struct rcar_xhci_platdata *plat = dev_get_platdata(dev); + struct rcar_xhci_plat *plat = dev_get_plat(dev); plat->hcd_base = dev_read_addr(dev); if (plat->hcd_base == FDT_ADDR_T_NONE) { @@ -160,8 +160,8 @@ U_BOOT_DRIVER(usb_xhci) = { .remove = xhci_rcar_deregister, .ops = &xhci_usb_ops, .of_match = xhci_rcar_ids, - .ofdata_to_platdata = xhci_rcar_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct rcar_xhci_platdata), - .priv_auto_alloc_size = sizeof(struct rcar_xhci), + .of_to_plat = xhci_rcar_of_to_plat, + .plat_auto = sizeof(struct rcar_xhci_plat), + .priv_auto = sizeof(struct rcar_xhci), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index 28136f88f4..2f5cc9b148 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -802,7 +802,7 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) mtu->ippc_base = ssusb->ippc_base; mtu->mac_base = ssusb->mac_base; mtu->ssusb = ssusb; - mtu->max_speed = usb_get_maximum_speed(dev->node); + mtu->max_speed = usb_get_maximum_speed(dev_ofnode(dev)); mtu->force_vbus = dev_read_bool(dev, "mediatek,force-vbus"); ret = mtu3_hw_init(mtu); diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index 3795e695e8..b097471f3d 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -173,7 +173,7 @@ static int get_ssusb_rscs(struct udevice *dev, struct ssusb_mtk *ssusb) return -ENODEV; } - ssusb->dr_mode = usb_get_dr_mode(child->node); + ssusb->dr_mode = usb_get_dr_mode(dev_ofnode(child)); if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN || ssusb->dr_mode == USB_DR_MODE_OTG) @@ -257,7 +257,7 @@ U_BOOT_DRIVER(mtu3_peripheral) = { .of_match = ssusb_of_match, .probe = mtu3_gadget_probe, .remove = mtu3_gadget_remove, - .priv_auto_alloc_size = sizeof(struct mtu3), + .priv_auto = sizeof(struct mtu3), }; #endif @@ -298,7 +298,7 @@ U_BOOT_DRIVER(mtu3_host) = { .of_match = ssusb_of_match, .probe = mtu3_host_probe, .remove = mtu3_host_remove, - .priv_auto_alloc_size = sizeof(struct mtu3_host), + .priv_auto = sizeof(struct mtu3_host), .ops = &xhci_usb_ops, .flags = DM_FLAG_ALLOC_PRIV_DMA, }; @@ -313,7 +313,7 @@ static int mtu3_glue_bind(struct udevice *parent) ofnode node; int ret; - node = ofnode_by_compatible(parent->node, "mediatek,ssusb"); + node = ofnode_by_compatible(dev_ofnode(parent), "mediatek,ssusb"); if (!ofnode_valid(node)) return -ENODEV; @@ -365,5 +365,5 @@ U_BOOT_DRIVER(mtu3) = { .bind = mtu3_glue_bind, .probe = mtu3_probe, .remove = mtu3_remove, - .priv_auto_alloc_size = sizeof(struct ssusb_mtk), + .priv_auto = sizeof(struct ssusb_mtk), }; diff --git a/drivers/usb/musb-new/da8xx.c b/drivers/usb/musb-new/da8xx.c index 67488ddb50..f42803533d 100644 --- a/drivers/usb/musb-new/da8xx.c +++ b/drivers/usb/musb-new/da8xx.c @@ -247,7 +247,7 @@ const struct musb_platform_ops da8xx_ops = { .disable = da8xx_musb_disable, }; -struct da8xx_musb_platdata { +struct da8xx_musb_plat { void *base; void *ctrl_mod_base; struct musb_hdrc_platform_data plat; @@ -256,45 +256,45 @@ struct da8xx_musb_platdata { struct phy phy; }; -static int da8xx_musb_ofdata_to_platdata(struct udevice *dev) +static int da8xx_musb_of_to_plat(struct udevice *dev) { - struct da8xx_musb_platdata *platdata = dev_get_platdata(dev); + struct da8xx_musb_plat *plat = dev_get_plat(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); - platdata->base = (void *)dev_read_addr_ptr(dev); - platdata->musb_config.multipoint = 1; - platdata->musb_config.dyn_fifo = 1; - platdata->musb_config.num_eps = 5; - platdata->musb_config.ram_bits = 10; - platdata->plat.power = fdtdec_get_int(fdt, node, "power", 50); - platdata->otg_board_data.interface_type = MUSB_INTERFACE_UTMI; - platdata->plat.mode = MUSB_HOST; - platdata->otg_board_data.dev = dev; - platdata->plat.config = &platdata->musb_config; - platdata->plat.platform_ops = &da8xx_ops; - platdata->plat.board_data = &platdata->otg_board_data; - platdata->otg_board_data.clear_irq = da8xx_musb_clear_irq; - platdata->otg_board_data.reset = da8xx_musb_reset; + plat->base = (void *)dev_read_addr_ptr(dev); + plat->musb_config.multipoint = 1; + plat->musb_config.dyn_fifo = 1; + plat->musb_config.num_eps = 5; + plat->musb_config.ram_bits = 10; + plat->plat.power = fdtdec_get_int(fdt, node, "power", 50); + plat->otg_board_data.interface_type = MUSB_INTERFACE_UTMI; + plat->plat.mode = MUSB_HOST; + plat->otg_board_data.dev = dev; + plat->plat.config = &plat->musb_config; + plat->plat.platform_ops = &da8xx_ops; + plat->plat.board_data = &plat->otg_board_data; + plat->otg_board_data.clear_irq = da8xx_musb_clear_irq; + plat->otg_board_data.reset = da8xx_musb_reset; return 0; } static int da8xx_musb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); - struct da8xx_musb_platdata *platdata = dev_get_platdata(dev); + struct da8xx_musb_plat *plat = dev_get_plat(dev); struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct omap_musb_board_data *otg_board_data; int ret; void *base = dev_read_addr_ptr(dev); /* Get the phy info from the device tree */ - ret = generic_phy_get_by_name(dev, "usb-phy", &platdata->phy); + ret = generic_phy_get_by_name(dev, "usb-phy", &plat->phy); if (ret) return ret; /* Initialize the phy */ - ret = generic_phy_init(&platdata->phy); + ret = generic_phy_init(&plat->phy); if (ret) return ret; @@ -302,14 +302,14 @@ static int da8xx_musb_probe(struct udevice *dev) lpsc_on(33); /* Enable phy */ - generic_phy_power_on(&platdata->phy); + generic_phy_power_on(&plat->phy); priv->desc_before_addr = true; - otg_board_data = &platdata->otg_board_data; + otg_board_data = &plat->otg_board_data; - host->host = musb_init_controller(&platdata->plat, + host->host = musb_init_controller(&plat->plat, (struct device *)otg_board_data, - platdata->base); + plat->base); if (!host->host) { ret = -ENODEV; goto shutdown; /* Shutdown what we started */ @@ -321,7 +321,7 @@ static int da8xx_musb_probe(struct udevice *dev) return 0; shutdown: /* Turn off the phy if we fail */ - generic_phy_power_off(&platdata->phy); + generic_phy_power_off(&plat->phy); lpsc_disable(33); return ret; } @@ -344,10 +344,10 @@ U_BOOT_DRIVER(da8xx_musb) = { .name = "da8xx-musb", .id = UCLASS_USB, .of_match = da8xx_musb_ids, - .ofdata_to_platdata = da8xx_musb_ofdata_to_platdata, + .of_to_plat = da8xx_musb_of_to_plat, .probe = da8xx_musb_probe, .remove = da8xx_musb_remove, .ops = &musb_usb_ops, - .platdata_auto_alloc_size = sizeof(struct da8xx_musb_platdata), - .priv_auto_alloc_size = sizeof(struct musb_host_data), + .plat_auto = sizeof(struct da8xx_musb_plat), + .priv_auto = sizeof(struct musb_host_data), }; diff --git a/drivers/usb/musb-new/mt85xx.c b/drivers/usb/musb-new/mt85xx.c index 8f0561eeba..730045cf9a 100644 --- a/drivers/usb/musb-new/mt85xx.c +++ b/drivers/usb/musb-new/mt85xx.c @@ -414,6 +414,6 @@ U_BOOT_DRIVER(mtk_musb) = { #ifdef CONFIG_USB_MUSB_HOST .ops = &musb_usb_ops, #endif - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct mtk_musb_glue), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct mtk_musb_glue), }; diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index da63cc2c22..3fdcaeaa5d 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -141,7 +141,7 @@ const struct musb_platform_ops omap2430_ops = { #if CONFIG_IS_ENABLED(DM_USB) -struct omap2430_musb_platdata { +struct omap2430_musb_plat { void *base; void *ctrl_mod_base; struct musb_hdrc_platform_data plat; @@ -149,69 +149,65 @@ struct omap2430_musb_platdata { struct omap_musb_board_data otg_board_data; }; -static int omap2430_musb_ofdata_to_platdata(struct udevice *dev) +static int omap2430_musb_of_to_plat(struct udevice *dev) { - struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); + struct omap2430_musb_plat *plat = dev_get_plat(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); - platdata->base = (void *)dev_read_addr_ptr(dev); + plat->base = (void *)dev_read_addr_ptr(dev); - platdata->musb_config.multipoint = fdtdec_get_int(fdt, node, - "multipoint", - -1); - if (platdata->musb_config.multipoint < 0) { + plat->musb_config.multipoint = fdtdec_get_int(fdt, node, "multipoint", + -1); + if (plat->musb_config.multipoint < 0) { pr_err("MUSB multipoint DT entry missing\n"); return -ENOENT; } - platdata->musb_config.dyn_fifo = 1; - platdata->musb_config.num_eps = fdtdec_get_int(fdt, node, - "num-eps", -1); - if (platdata->musb_config.num_eps < 0) { + plat->musb_config.dyn_fifo = 1; + plat->musb_config.num_eps = fdtdec_get_int(fdt, node, "num-eps", -1); + if (plat->musb_config.num_eps < 0) { pr_err("MUSB num-eps DT entry missing\n"); return -ENOENT; } - platdata->musb_config.ram_bits = fdtdec_get_int(fdt, node, - "ram-bits", -1); - if (platdata->musb_config.ram_bits < 0) { + plat->musb_config.ram_bits = fdtdec_get_int(fdt, node, "ram-bits", -1); + if (plat->musb_config.ram_bits < 0) { pr_err("MUSB ram-bits DT entry missing\n"); return -ENOENT; } - platdata->plat.power = fdtdec_get_int(fdt, node, - "power", -1); - if (platdata->plat.power < 0) { + plat->plat.power = fdtdec_get_int(fdt, node, "power", -1); + if (plat->plat.power < 0) { pr_err("MUSB power DT entry missing\n"); return -ENOENT; } - platdata->otg_board_data.interface_type = fdtdec_get_int(fdt, node, - "interface-type", -1); - if (platdata->otg_board_data.interface_type < 0) { + plat->otg_board_data.interface_type = fdtdec_get_int(fdt, node, + "interface-type", + -1); + if (plat->otg_board_data.interface_type < 0) { pr_err("MUSB interface-type DT entry missing\n"); return -ENOENT; } #if 0 /* In a perfect world, mode would be set to OTG, mode 3 from DT */ - platdata->plat.mode = fdtdec_get_int(fdt, node, - "mode", -1); - if (platdata->plat.mode < 0) { + plat->plat.mode = fdtdec_get_int(fdt, node, "mode", -1); + if (plat->plat.mode < 0) { pr_err("MUSB mode DT entry missing\n"); return -ENOENT; } #else /* MUSB_OTG, it doesn't work */ #ifdef CONFIG_USB_MUSB_HOST /* Host seems to be the only option that works */ - platdata->plat.mode = MUSB_HOST; + plat->plat.mode = MUSB_HOST; #else /* For that matter, MUSB_PERIPHERAL doesn't either */ - platdata->plat.mode = MUSB_PERIPHERAL; + plat->plat.mode = MUSB_PERIPHERAL; #endif #endif - platdata->otg_board_data.dev = dev; - platdata->plat.config = &platdata->musb_config; - platdata->plat.platform_ops = &omap2430_ops; - platdata->plat.board_data = &platdata->otg_board_data; + plat->otg_board_data.dev = dev; + plat->plat.config = &plat->musb_config; + plat->plat.platform_ops = &omap2430_ops; + plat->plat.board_data = &plat->otg_board_data; return 0; } @@ -222,7 +218,7 @@ static int omap2430_musb_probe(struct udevice *dev) #else struct musb *musbp; #endif - struct omap2430_musb_platdata *platdata = dev_get_platdata(dev); + struct omap2430_musb_plat *plat = dev_get_plat(dev); struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct omap_musb_board_data *otg_board_data; int ret = 0; @@ -230,21 +226,20 @@ static int omap2430_musb_probe(struct udevice *dev) priv->desc_before_addr = true; - otg_board_data = &platdata->otg_board_data; + otg_board_data = &plat->otg_board_data; #ifdef CONFIG_USB_MUSB_HOST - host->host = musb_init_controller(&platdata->plat, + host->host = musb_init_controller(&plat->plat, (struct device *)otg_board_data, - platdata->base); + plat->base); if (!host->host) { return -EIO; } ret = musb_lowlevel_init(host); #else - musbp = musb_register(&platdata->plat, - (struct device *)otg_board_data, - platdata->base); + musbp = musb_register(&plat->plat, (struct device *)otg_board_data, + plat->base); if (IS_ERR_OR_NULL(musbp)) return -EINVAL; #endif @@ -274,14 +269,14 @@ U_BOOT_DRIVER(omap2430_musb) = { .id = UCLASS_USB_GADGET_GENERIC, #endif .of_match = omap2430_musb_ids, - .ofdata_to_platdata = omap2430_musb_ofdata_to_platdata, + .of_to_plat = omap2430_musb_of_to_plat, .probe = omap2430_musb_probe, .remove = omap2430_musb_remove, #ifdef CONFIG_USB_MUSB_HOST .ops = &musb_usb_ops, #endif - .platdata_auto_alloc_size = sizeof(struct omap2430_musb_platdata), - .priv_auto_alloc_size = sizeof(struct musb_host_data), + .plat_auto = sizeof(struct omap2430_musb_plat), + .priv_auto = sizeof(struct musb_host_data), }; #endif /* CONFIG_IS_ENABLED(DM_USB) */ diff --git a/drivers/usb/musb-new/pic32.c b/drivers/usb/musb-new/pic32.c index 2fbe9bebf1..b833f10f4b 100644 --- a/drivers/usb/musb-new/pic32.c +++ b/drivers/usb/musb-new/pic32.c @@ -288,6 +288,6 @@ U_BOOT_DRIVER(usb_musb) = { #ifdef CONFIG_USB_MUSB_HOST .ops = &musb_usb_ops, #endif - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct pic32_musb_data), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct pic32_musb_data), }; diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 187db7794b..fea4105f3d 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -552,6 +552,6 @@ U_BOOT_DRIVER(usb_musb) = { #ifdef CONFIG_USB_MUSB_HOST .ops = &musb_usb_ops, #endif - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct sunxi_glue), + .plat_auto = sizeof(struct usb_plat), + .priv_auto = sizeof(struct sunxi_glue), }; diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index f4f26d86b3..75cf1811f7 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -33,17 +33,17 @@ DECLARE_GLOBAL_DATA_PTR; static void ti_musb_set_phy_power(struct udevice *dev, u8 on) { - struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct ti_musb_plat *plat = dev_get_plat(dev); - if (!platdata->ctrl_mod_base) + if (!plat->ctrl_mod_base) return; if (on) { - clrsetbits_le32(platdata->ctrl_mod_base, + clrsetbits_le32(plat->ctrl_mod_base, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, OTGVDET_EN | OTGSESSENDEN); } else { - clrsetbits_le32(platdata->ctrl_mod_base, 0, + clrsetbits_le32(plat->ctrl_mod_base, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); } } @@ -77,9 +77,9 @@ static int ti_musb_get_usb_index(int node) return -ENOENT; } -static int ti_musb_ofdata_to_platdata(struct udevice *dev) +static int ti_musb_of_to_plat(struct udevice *dev) { - struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct ti_musb_plat *plat = dev_get_plat(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); int phys; @@ -87,18 +87,18 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev) int usb_index; struct musb_hdrc_config *musb_config; - platdata->base = (void *)devfdt_get_addr_index(dev, 1); + plat->base = (void *)devfdt_get_addr_index(dev, 1); phys = fdtdec_lookup_phandle(fdt, node, "phys"); ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod"); - platdata->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg"); + plat->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg"); usb_index = ti_musb_get_usb_index(node); switch (usb_index) { case 1: - platdata->ctrl_mod_base += AM335X_USB1_CTRL; + plat->ctrl_mod_base += AM335X_USB1_CTRL; break; case 0: - platdata->ctrl_mod_base += AM335X_USB0_CTRL; + plat->ctrl_mod_base += AM335X_USB0_CTRL; break; default: break; @@ -130,15 +130,15 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev) return -ENOENT; } - platdata->plat.config = musb_config; + plat->plat.config = musb_config; - platdata->plat.power = fdtdec_get_int(fdt, node, "mentor,power", -1); - if (platdata->plat.power < 0) { + plat->plat.power = fdtdec_get_int(fdt, node, "mentor,power", -1); + if (plat->plat.power < 0) { pr_err("MUSB mentor,power DT entry missing\n"); return -ENOENT; } - platdata->plat.platform_ops = &musb_dsps_ops; + plat->plat.platform_ops = &musb_dsps_ops; return 0; } @@ -147,15 +147,15 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev) static int ti_musb_host_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); - struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct ti_musb_plat *plat = dev_get_plat(dev); struct usb_bus_priv *priv = dev_get_uclass_priv(dev); int ret; priv->desc_before_addr = true; - host->host = musb_init_controller(&platdata->plat, + host->host = musb_init_controller(&plat->plat, NULL, - platdata->base); + plat->base); if (!host->host) return -EIO; @@ -176,20 +176,20 @@ static int ti_musb_host_remove(struct udevice *dev) } #if CONFIG_IS_ENABLED(OF_CONTROL) -static int ti_musb_host_ofdata_to_platdata(struct udevice *dev) +static int ti_musb_host_of_to_plat(struct udevice *dev) { - struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct ti_musb_plat *plat = dev_get_plat(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); int ret; - ret = ti_musb_ofdata_to_platdata(dev); + ret = ti_musb_of_to_plat(dev); if (ret) { - pr_err("platdata dt parse error\n"); + pr_err("plat dt parse error\n"); return ret; } - platdata->plat.mode = MUSB_HOST; + plat->plat.mode = MUSB_HOST; return 0; } @@ -199,13 +199,13 @@ U_BOOT_DRIVER(ti_musb_host) = { .name = "ti-musb-host", .id = UCLASS_USB, #if CONFIG_IS_ENABLED(OF_CONTROL) - .ofdata_to_platdata = ti_musb_host_ofdata_to_platdata, + .of_to_plat = ti_musb_host_of_to_plat, #endif .probe = ti_musb_host_probe, .remove = ti_musb_host_remove, .ops = &musb_usb_ops, - .platdata_auto_alloc_size = sizeof(struct ti_musb_platdata), - .priv_auto_alloc_size = sizeof(struct musb_host_data), + .plat_auto = sizeof(struct ti_musb_plat), + .priv_auto = sizeof(struct musb_host_data), }; #if CONFIG_IS_ENABLED(DM_USB_GADGET) @@ -214,19 +214,19 @@ struct ti_musb_peripheral { }; #if CONFIG_IS_ENABLED(OF_CONTROL) -static int ti_musb_peripheral_ofdata_to_platdata(struct udevice *dev) +static int ti_musb_peripheral_of_to_plat(struct udevice *dev) { - struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct ti_musb_plat *plat = dev_get_plat(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(dev); int ret; - ret = ti_musb_ofdata_to_platdata(dev); + ret = ti_musb_of_to_plat(dev); if (ret) { - pr_err("platdata dt parse error\n"); + pr_err("plat dt parse error\n"); return ret; } - platdata->plat.mode = MUSB_PERIPHERAL; + plat->plat.mode = MUSB_PERIPHERAL; return 0; } @@ -244,12 +244,12 @@ int dm_usb_gadget_handle_interrupts(struct udevice *dev) static int ti_musb_peripheral_probe(struct udevice *dev) { struct ti_musb_peripheral *priv = dev_get_priv(dev); - struct ti_musb_platdata *platdata = dev_get_platdata(dev); + struct ti_musb_plat *plat = dev_get_plat(dev); int ret; - priv->periph = musb_init_controller(&platdata->plat, + priv->periph = musb_init_controller(&plat->plat, NULL, - platdata->base); + plat->base); if (!priv->periph) return -EIO; @@ -272,13 +272,13 @@ U_BOOT_DRIVER(ti_musb_peripheral) = { .name = "ti-musb-peripheral", .id = UCLASS_USB_GADGET_GENERIC, #if CONFIG_IS_ENABLED(OF_CONTROL) - .ofdata_to_platdata = ti_musb_peripheral_ofdata_to_platdata, + .of_to_plat = ti_musb_peripheral_of_to_plat, #endif .probe = ti_musb_peripheral_probe, .remove = ti_musb_peripheral_remove, .ops = &musb_usb_ops, - .platdata_auto_alloc_size = sizeof(struct ti_musb_platdata), - .priv_auto_alloc_size = sizeof(struct ti_musb_peripheral), + .plat_auto = sizeof(struct ti_musb_plat), + .priv_auto = sizeof(struct ti_musb_peripheral), .flags = DM_FLAG_PRE_RELOC, }; #endif @@ -289,7 +289,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent) ofnode node; int ret; - ofnode_for_each_subnode(node, parent->node) { + ofnode_for_each_subnode(node, dev_ofnode(parent)) { struct udevice *dev; const char *name = ofnode_get_name(node); enum usb_dr_mode dr_mode; diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 9fef1a6d29..d39d9b2291 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -555,10 +555,7 @@ config ATMEL_HLCD help HLCDC supports video output to an attached LCD panel. -config AM335X_LCD - bool "Enable AM335x video support" - help - Supports video output to an attached LCD panel. +source "drivers/video/ti/Kconfig" config LOGICORE_DP_TX bool "Enable Logicore DP TX driver" @@ -661,6 +658,13 @@ config VIDEO_NX HDMI. This option enables this support which can be used on devices which have an eDP display connected. +config VIDEO_SEPS525 + bool "Enable video support for Seps525" + depends on DM_VIDEO + help + Enable support for the Syncoam PM-OLED display driver (RGB 160x128). + Currently driver is supporting only SPI interface. + source "drivers/video/nexell/Kconfig" config VIDEO diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 649901360f..494e414a31 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -22,8 +22,8 @@ obj-${CONFIG_EXYNOS_FB} += exynos/ obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/ obj-${CONFIG_VIDEO_STM32} += stm32/ obj-${CONFIG_VIDEO_TEGRA124} += tegra124/ +obj-y += ti/ -obj-$(CONFIG_AM335X_LCD) += am335x-fb.o obj-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o obj-$(CONFIG_ATMEL_HLCD) += atmel_hlcdfb.o obj-$(CONFIG_ATMEL_LCD) += atmel_lcdfb.o @@ -71,6 +71,7 @@ obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o obj-$(CONFIG_VIDEO_TEGRA20) += tegra.o obj-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o obj-$(CONFIG_VIDEO_VESA) += vesa.o +obj-$(CONFIG_VIDEO_SEPS525) += seps525.o obj-y += bridge/ obj-y += sunxi/ diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c index 38def2816b..0485ae2436 100644 --- a/drivers/video/atmel_hlcdfb.c +++ b/drivers/video/atmel_hlcdfb.c @@ -293,7 +293,7 @@ static int at91_hlcdc_enable_clk(struct udevice *dev) static void atmel_hlcdc_init(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct atmel_hlcdc_priv *priv = dev_get_priv(dev); struct atmel_hlcd_regs *regs = priv->regs; struct display_timing *timing = &priv->timing; @@ -501,7 +501,7 @@ static int atmel_hlcdc_probe(struct udevice *dev) return 0; } -static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev) +static int atmel_hlcdc_of_to_plat(struct udevice *dev) { struct atmel_hlcdc_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; @@ -539,7 +539,7 @@ static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev) static int atmel_hlcdc_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); uc_plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * (1 << LCD_MAX_LOG2_BPP) / 8; @@ -561,8 +561,8 @@ U_BOOT_DRIVER(atmel_hlcdfb) = { .of_match = atmel_hlcdc_ids, .bind = atmel_hlcdc_bind, .probe = atmel_hlcdc_probe, - .ofdata_to_platdata = atmel_hlcdc_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct atmel_hlcdc_priv), + .of_to_plat = atmel_hlcdc_of_to_plat, + .priv_auto = sizeof(struct atmel_hlcdc_priv), }; #endif diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index ae8ec26468..f87c0224a1 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -245,7 +245,7 @@ ulong calc_fbsize(void) #ifdef CONFIG_DM_VIDEO static int atmel_fb_lcd_probe(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct atmel_fb_priv *priv = dev_get_priv(dev); struct display_timing *timing = &priv->timing; @@ -267,9 +267,9 @@ static int atmel_fb_lcd_probe(struct udevice *dev) return 0; } -static int atmel_fb_ofdata_to_platdata(struct udevice *dev) +static int atmel_fb_of_to_plat(struct udevice *dev) { - struct atmel_lcd_platdata *plat = dev_get_platdata(dev); + struct atmel_lcd_plat *plat = dev_get_plat(dev); struct atmel_fb_priv *priv = dev_get_priv(dev); struct display_timing *timing = &priv->timing; const void *blob = gd->fdt_blob; @@ -285,7 +285,7 @@ static int atmel_fb_ofdata_to_platdata(struct udevice *dev) static int atmel_fb_lcd_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); uc_plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * (1 << VIDEO_BPP16) / 8; @@ -304,9 +304,9 @@ U_BOOT_DRIVER(atmel_fb) = { .id = UCLASS_VIDEO, .of_match = atmel_fb_lcd_ids, .bind = atmel_fb_lcd_bind, - .ofdata_to_platdata = atmel_fb_ofdata_to_platdata, + .of_to_plat = atmel_fb_of_to_plat, .probe = atmel_fb_lcd_probe, - .platdata_auto_alloc_size = sizeof(struct atmel_lcd_platdata), - .priv_auto_alloc_size = sizeof(struct atmel_fb_priv), + .plat_auto = sizeof(struct atmel_lcd_plat), + .priv_auto = sizeof(struct atmel_fb_priv), }; #endif diff --git a/drivers/video/backlight_gpio.c b/drivers/video/backlight_gpio.c index 433d0979e8..eea824ab5e 100644 --- a/drivers/video/backlight_gpio.c +++ b/drivers/video/backlight_gpio.c @@ -24,7 +24,7 @@ static int gpio_backlight_enable(struct udevice *dev) return 0; } -static int gpio_backlight_ofdata_to_platdata(struct udevice *dev) +static int gpio_backlight_of_to_plat(struct udevice *dev) { struct gpio_backlight_priv *priv = dev_get_priv(dev); int ret; @@ -66,7 +66,7 @@ U_BOOT_DRIVER(gpio_backlight) = { .id = UCLASS_PANEL_BACKLIGHT, .of_match = gpio_backlight_ids, .ops = &gpio_backlight_ops, - .ofdata_to_platdata = gpio_backlight_ofdata_to_platdata, + .of_to_plat = gpio_backlight_of_to_plat, .probe = gpio_backlight_probe, - .priv_auto_alloc_size = sizeof(struct gpio_backlight_priv), + .priv_auto = sizeof(struct gpio_backlight_priv), }; diff --git a/drivers/video/bcm2835.c b/drivers/video/bcm2835.c index 0888cb0019..9326999cd3 100644 --- a/drivers/video/bcm2835.c +++ b/drivers/video/bcm2835.c @@ -13,7 +13,7 @@ static int bcm2835_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); int ret; int w, h, pitch; diff --git a/drivers/video/bridge/anx6345.c b/drivers/video/bridge/anx6345.c index 1c5270ff05..93fa25f16e 100644 --- a/drivers/video/bridge/anx6345.c +++ b/drivers/video/bridge/anx6345.c @@ -74,7 +74,7 @@ static int anx6345_read(struct udevice *dev, unsigned int addr_off, static int anx6345_write_r0(struct udevice *dev, unsigned char reg_addr, unsigned char value) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); return anx6345_write(dev, chip->chip_addr, reg_addr, value); } @@ -82,7 +82,7 @@ static int anx6345_write_r0(struct udevice *dev, unsigned char reg_addr, static int anx6345_read_r0(struct udevice *dev, unsigned char reg_addr, unsigned char *value) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); return anx6345_read(dev, chip->chip_addr, reg_addr, value); } @@ -90,7 +90,7 @@ static int anx6345_read_r0(struct udevice *dev, unsigned char reg_addr, static int anx6345_write_r1(struct udevice *dev, unsigned char reg_addr, unsigned char value) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); return anx6345_write(dev, chip->chip_addr + 1, reg_addr, value); } @@ -98,7 +98,7 @@ static int anx6345_write_r1(struct udevice *dev, unsigned char reg_addr, static int anx6345_read_r1(struct udevice *dev, unsigned char reg_addr, unsigned char *value) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); return anx6345_read(dev, chip->chip_addr + 1, reg_addr, value); } @@ -421,5 +421,5 @@ U_BOOT_DRIVER(analogix_anx6345) = { .of_match = anx6345_ids, .probe = anx6345_probe, .ops = &anx6345_ops, - .priv_auto_alloc_size = sizeof(struct anx6345_priv), + .priv_auto = sizeof(struct anx6345_priv), }; diff --git a/drivers/video/bridge/ps862x.c b/drivers/video/bridge/ps862x.c index 8399c6f74c..76115b7bc5 100644 --- a/drivers/video/bridge/ps862x.c +++ b/drivers/video/bridge/ps862x.c @@ -37,7 +37,7 @@ DECLARE_GLOBAL_DATA_PTR; static int ps8622_write(struct udevice *dev, unsigned addr_off, unsigned char reg_addr, unsigned char value) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); uint8_t buf[2]; struct i2c_msg msg; int ret; diff --git a/drivers/video/bridge/video-bridge-uclass.c b/drivers/video/bridge/video-bridge-uclass.c index 389b02cdcb..08d38b244b 100644 --- a/drivers/video/bridge/video-bridge-uclass.c +++ b/drivers/video/bridge/video-bridge-uclass.c @@ -134,6 +134,6 @@ int video_bridge_set_active(struct udevice *dev, bool active) UCLASS_DRIVER(video_bridge) = { .id = UCLASS_VIDEO_BRIDGE, .name = "video_bridge", - .per_device_auto_alloc_size = sizeof(struct video_bridge_priv), + .per_device_auto = sizeof(struct video_bridge_priv), .pre_probe = video_bridge_pre_probe, }; diff --git a/drivers/video/broadwell_igd.c b/drivers/video/broadwell_igd.c index df6a761d2d..cba105c19a 100644 --- a/drivers/video/broadwell_igd.c +++ b/drivers/video/broadwell_igd.c @@ -356,7 +356,7 @@ static int gtt_poll(struct broadwell_igd_priv *priv, u32 reg, u32 mask, static void igd_setup_panel(struct udevice *dev) { - struct broadwell_igd_plat *plat = dev_get_platdata(dev); + struct broadwell_igd_plat *plat = dev_get_plat(dev); struct broadwell_igd_priv *priv = dev_get_priv(dev); u32 reg32; @@ -398,7 +398,7 @@ static void igd_setup_panel(struct udevice *dev) static int igd_cdclk_init_haswell(struct udevice *dev) { - struct broadwell_igd_plat *plat = dev_get_platdata(dev); + struct broadwell_igd_plat *plat = dev_get_plat(dev); struct broadwell_igd_priv *priv = dev_get_priv(dev); int cdclk = plat->cdclk; u16 devid; @@ -472,7 +472,7 @@ err: static int igd_cdclk_init_broadwell(struct udevice *dev) { - struct broadwell_igd_plat *plat = dev_get_platdata(dev); + struct broadwell_igd_plat *plat = dev_get_plat(dev); struct broadwell_igd_priv *priv = dev_get_priv(dev); int cdclk = plat->cdclk; u32 dpdiv, lpcll, pwctl, cdset; @@ -567,7 +567,7 @@ u8 systemagent_revision(struct udevice *bus) static int igd_pre_init(struct udevice *dev, bool is_broadwell) { - struct broadwell_igd_plat *plat = dev_get_platdata(dev); + struct broadwell_igd_plat *plat = dev_get_plat(dev); struct broadwell_igd_priv *priv = dev_get_priv(dev); u32 rp1_gfx_freq; int ret; @@ -661,7 +661,7 @@ static int broadwell_igd_int15_handler(void) static int broadwell_igd_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); bool is_broadwell; ulong fbbase; @@ -706,9 +706,9 @@ static int broadwell_igd_probe(struct udevice *dev) return 0; } -static int broadwell_igd_ofdata_to_platdata(struct udevice *dev) +static int broadwell_igd_of_to_plat(struct udevice *dev) { - struct broadwell_igd_plat *plat = dev_get_platdata(dev); + struct broadwell_igd_plat *plat = dev_get_plat(dev); struct broadwell_igd_priv *priv = dev_get_priv(dev); int node = dev_of_offset(dev); const void *blob = gd->fdt_blob; @@ -756,7 +756,7 @@ static int broadwell_igd_ofdata_to_platdata(struct udevice *dev) static int broadwell_igd_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Set the maximum supported resolution */ uc_plat->size = 2560 * 1600 * 4; @@ -778,9 +778,9 @@ U_BOOT_DRIVER(broadwell_igd) = { .id = UCLASS_VIDEO, .of_match = broadwell_igd_ids, .ops = &broadwell_igd_ops, - .ofdata_to_platdata = broadwell_igd_ofdata_to_platdata, + .of_to_plat = broadwell_igd_of_to_plat, .bind = broadwell_igd_bind, .probe = broadwell_igd_probe, - .priv_auto_alloc_size = sizeof(struct broadwell_igd_priv), - .platdata_auto_alloc_size = sizeof(struct broadwell_igd_plat), + .priv_auto = sizeof(struct broadwell_igd_priv), + .plat_auto = sizeof(struct broadwell_igd_plat), }; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 8205413d2a..fa11b3bbef 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -588,5 +588,5 @@ U_BOOT_DRIVER(vidconsole_truetype) = { .id = UCLASS_VIDEO_CONSOLE, .ops = &console_truetype_ops, .probe = console_truetype_probe, - .priv_auto_alloc_size = sizeof(struct console_tt_priv), + .priv_auto = sizeof(struct console_tt_priv), }; diff --git a/drivers/video/coreboot.c b/drivers/video/coreboot.c index c8797a0d9c..0a5fb08dc8 100644 --- a/drivers/video/coreboot.c +++ b/drivers/video/coreboot.c @@ -38,7 +38,7 @@ static int save_vesa_mode(struct cb_framebuffer *fb, static int coreboot_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct cb_framebuffer *fb = lib_sysinfo.framebuffer; struct vesa_mode_info *vesa = &mode_info.vesa; diff --git a/drivers/video/display-uclass.c b/drivers/video/display-uclass.c index 1a29ce5d85..068108e915 100644 --- a/drivers/video/display-uclass.c +++ b/drivers/video/display-uclass.c @@ -31,7 +31,7 @@ int display_enable(struct udevice *dev, int panel_bpp, if (ret) return ret; - disp_uc_plat = dev_get_uclass_platdata(dev); + disp_uc_plat = dev_get_uclass_plat(dev); disp_uc_plat->in_use = true; return 0; @@ -71,7 +71,7 @@ int display_read_timing(struct udevice *dev, struct display_timing *timing) bool display_in_use(struct udevice *dev) { - struct display_plat *disp_uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *disp_uc_plat = dev_get_uclass_plat(dev); return disp_uc_plat->in_use; } @@ -79,5 +79,5 @@ bool display_in_use(struct udevice *dev) UCLASS_DRIVER(display) = { .id = UCLASS_DISPLAY, .name = "display", - .per_device_platdata_auto_alloc_size = sizeof(struct display_plat), + .per_device_plat_auto = sizeof(struct display_plat), }; diff --git a/drivers/video/dw_mipi_dsi.c b/drivers/video/dw_mipi_dsi.c index 4055ef49b6..4dde648814 100644 --- a/drivers/video/dw_mipi_dsi.c +++ b/drivers/video/dw_mipi_dsi.c @@ -845,7 +845,7 @@ U_BOOT_DRIVER(dw_mipi_dsi) = { .id = UCLASS_DSI_HOST, .probe = dw_mipi_dsi_probe, .ops = &dw_mipi_dsi_ops, - .priv_auto_alloc_size = sizeof(struct dw_mipi_dsi), + .priv_auto = sizeof(struct dw_mipi_dsi), }; MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>"); diff --git a/drivers/video/efi.c b/drivers/video/efi.c index 47441a35a6..c248bd352a 100644 --- a/drivers/video/efi.c +++ b/drivers/video/efi.c @@ -110,7 +110,7 @@ static int save_vesa_mode(struct vesa_mode_info *vesa) static int efi_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct vesa_mode_info *vesa = &mode_info.vesa; int ret; diff --git a/drivers/video/exynos/exynos_dp.c b/drivers/video/exynos/exynos_dp.c index 999ee1c14a..63b5b8e61a 100644 --- a/drivers/video/exynos/exynos_dp.c +++ b/drivers/video/exynos/exynos_dp.c @@ -877,7 +877,7 @@ static unsigned int exynos_dp_config_video(struct exynos_dp *regs, return ret; } -static int exynos_dp_ofdata_to_platdata(struct udevice *dev) +static int exynos_dp_of_to_plat(struct udevice *dev) { struct exynos_dp_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; @@ -1080,6 +1080,6 @@ U_BOOT_DRIVER(exynos_dp) = { .id = UCLASS_DISPLAY, .of_match = exynos_dp_ids, .ops = &exynos_dp_ops, - .ofdata_to_platdata = exynos_dp_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct exynos_dp_priv), + .of_to_plat = exynos_dp_of_to_plat, + .priv_auto = sizeof(struct exynos_dp_priv), }; diff --git a/drivers/video/exynos/exynos_fb.c b/drivers/video/exynos/exynos_fb.c index 979b909182..7b4459ced8 100644 --- a/drivers/video/exynos/exynos_fb.c +++ b/drivers/video/exynos/exynos_fb.c @@ -377,7 +377,7 @@ void exynos_fimd_disable_sysmmu(void) void exynos_fimd_lcd_init(struct udevice *dev) { struct exynos_fb_priv *priv = dev_get_priv(dev); - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct exynos_fb *reg = priv->reg; unsigned int cfg = 0, rgb_mode; unsigned int offset; @@ -479,7 +479,7 @@ unsigned long exynos_fimd_calc_fbsize(struct exynos_fb_priv *priv) return priv->vl_col * priv->vl_row * (VNBITS(priv->vl_bpix) / 8); } -int exynos_fb_ofdata_to_platdata(struct udevice *dev) +int exynos_fb_of_to_plat(struct udevice *dev) { struct exynos_fb_priv *priv = dev_get_priv(dev); unsigned int node = dev_of_offset(dev); @@ -692,7 +692,7 @@ static int exynos_fb_probe(struct udevice *dev) static int exynos_fb_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); /* This is the maximum panel size we expect to see */ plat->size = 1920 * 1080 * 2; @@ -715,6 +715,6 @@ U_BOOT_DRIVER(exynos_fb) = { .ops = &exynos_fb_ops, .bind = exynos_fb_bind, .probe = exynos_fb_probe, - .ofdata_to_platdata = exynos_fb_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct exynos_fb_priv), + .of_to_plat = exynos_fb_of_to_plat, + .priv_auto = sizeof(struct exynos_fb_priv), }; diff --git a/drivers/video/fsl_dcu_fb.c b/drivers/video/fsl_dcu_fb.c index e9d05c9394..4ea0f12487 100644 --- a/drivers/video/fsl_dcu_fb.c +++ b/drivers/video/fsl_dcu_fb.c @@ -484,7 +484,7 @@ void *video_hw_init(void) static int fsl_dcu_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct fb_info fbinfo = { 0 }; unsigned int win_x; @@ -516,7 +516,7 @@ static int fsl_dcu_video_probe(struct udevice *dev) static int fsl_dcu_video_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); unsigned int win_x; unsigned int win_y; unsigned int depth = 0, freq = 0; diff --git a/drivers/video/ihs_video_out.c b/drivers/video/ihs_video_out.c index f02fd13d28..73b8f4bd1c 100644 --- a/drivers/video/ihs_video_out.c +++ b/drivers/video/ihs_video_out.c @@ -338,5 +338,5 @@ U_BOOT_DRIVER(ihs_video_out_drv) = { .ops = &ihs_video_out_ops, .of_match = ihs_video_out_ids, .probe = ihs_video_out_probe, - .priv_auto_alloc_size = sizeof(struct ihs_video_out_priv), + .priv_auto = sizeof(struct ihs_video_out_priv), }; diff --git a/drivers/video/imx/mxc_ipuv3_fb.c b/drivers/video/imx/mxc_ipuv3_fb.c index eb93a4f1fa..6cdbbafafb 100644 --- a/drivers/video/imx/mxc_ipuv3_fb.c +++ b/drivers/video/imx/mxc_ipuv3_fb.c @@ -383,7 +383,7 @@ static int mxcfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) static int mxcfb_map_video_memory(struct fb_info *fbi) { struct mxcfb_info *mxc_fbi = (struct mxcfb_info *)fbi->par; - struct video_uc_platdata *plat = dev_get_uclass_platdata(mxc_fbi->udev); + struct video_uc_plat *plat = dev_get_uclass_plat(mxc_fbi->udev); if (fbi->fix.smem_len < fbi->var.yres_virtual * fbi->fix.line_length) { fbi->fix.smem_len = fbi->var.yres_virtual * @@ -586,7 +586,7 @@ enum { static int ipuv3_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); #if defined(CONFIG_DISPLAY) struct udevice *disp_dev; @@ -647,7 +647,7 @@ struct ipuv3_video_priv { static int ipuv3_video_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * (1 << VIDEO_BPP32) / 8; @@ -671,6 +671,6 @@ U_BOOT_DRIVER(fsl_imx6q_ipu) = { .of_match = ipuv3_video_ids, .bind = ipuv3_video_bind, .probe = ipuv3_video_probe, - .priv_auto_alloc_size = sizeof(struct ipuv3_video_priv), + .priv_auto = sizeof(struct ipuv3_video_priv), .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/video/ivybridge_igd.c b/drivers/video/ivybridge_igd.c index 2587f53ac1..e7db0cbcef 100644 --- a/drivers/video/ivybridge_igd.c +++ b/drivers/video/ivybridge_igd.c @@ -753,7 +753,7 @@ static int gma_func0_init(struct udevice *dev) static int bd82x6x_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); ulong fbbase; void *gtt_bar; int ret, rev; @@ -781,7 +781,7 @@ static int bd82x6x_video_probe(struct udevice *dev) static int bd82x6x_video_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Set the maximum supported resolution */ uc_plat->size = 2560 * 1600 * 4; diff --git a/drivers/video/lg4573.c b/drivers/video/lg4573.c index 45df9c1347..dd87fc461b 100644 --- a/drivers/video/lg4573.c +++ b/drivers/video/lg4573.c @@ -219,7 +219,7 @@ static int do_lgset(struct cmd_tbl *cmdtp, int flag, int argc, int ret; ret = uclass_get_device_by_driver(UCLASS_DISPLAY, - DM_GET_DRIVER(lg4573_lcd), &dev); + DM_DRIVER_GET(lg4573_lcd), &dev); if (ret) { printf("%s: Could not get lg4573 device\n", __func__); return ret; @@ -294,7 +294,7 @@ static const struct dm_display_ops lg4573_lcd_ops = { .enable = lg4573_lcd_enable, }; -static int lg4573_ofdata_to_platdata(struct udevice *dev) +static int lg4573_of_to_plat(struct udevice *dev) { struct lg4573_lcd_priv *priv = dev_get_priv(dev); int ret; @@ -323,9 +323,9 @@ U_BOOT_DRIVER(lg4573_lcd) = { .name = "lg4573", .id = UCLASS_DISPLAY, .ops = &lg4573_lcd_ops, - .ofdata_to_platdata = lg4573_ofdata_to_platdata, + .of_to_plat = lg4573_of_to_plat, .of_match = lg4573_ids, .bind = lg4573_bind, .probe = lg4573_probe, - .priv_auto_alloc_size = sizeof(struct lg4573_lcd_priv), + .priv_auto = sizeof(struct lg4573_lcd_priv), }; diff --git a/drivers/video/logicore_dp_tx.c b/drivers/video/logicore_dp_tx.c index 9bc4bbb85d..624084d38b 100644 --- a/drivers/video/logicore_dp_tx.c +++ b/drivers/video/logicore_dp_tx.c @@ -2292,6 +2292,6 @@ U_BOOT_DRIVER(logicore_dp_tx) = { .id = UCLASS_DISPLAY, .of_match = logicore_dp_tx_ids, .probe = logicore_dp_tx_probe, - .priv_auto_alloc_size = sizeof(struct dp_tx), + .priv_auto = sizeof(struct dp_tx), .ops = &logicore_dp_tx_ops, }; diff --git a/drivers/video/mali_dp.c b/drivers/video/mali_dp.c index 1e6da0e1e2..dc4f542256 100644 --- a/drivers/video/mali_dp.c +++ b/drivers/video/mali_dp.c @@ -260,7 +260,7 @@ static int malidp_update_timings_from_edid(struct udevice *dev, static int malidp_probe(struct udevice *dev) { struct video_priv *uc_priv = dev_get_uclass_priv(dev); - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); ofnode framebuffer = ofnode_find_subnode(dev_ofnode(dev), "framebuffer"); struct malidp_priv *priv = dev_get_priv(dev); struct display_timing timings; @@ -382,7 +382,7 @@ fail_aclk: static int malidp_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* choose max possible size: 2K x 2K, XRGB888 framebuffer */ uc_plat->size = 4 * 2048 * 2048; @@ -403,6 +403,6 @@ U_BOOT_DRIVER(mali_dp) = { .of_match = malidp_ids, .bind = malidp_bind, .probe = malidp_probe, - .priv_auto_alloc_size = sizeof(struct malidp_priv), + .priv_auto = sizeof(struct malidp_priv), .ops = &malidp_ops, }; diff --git a/drivers/video/meson/meson_dw_hdmi.c b/drivers/video/meson/meson_dw_hdmi.c index 5d74f7f1a7..e5f2813205 100644 --- a/drivers/video/meson/meson_dw_hdmi.c +++ b/drivers/video/meson/meson_dw_hdmi.c @@ -508,5 +508,5 @@ U_BOOT_DRIVER(meson_dw_hdmi) = { .of_match = meson_dw_hdmi_ids, .ops = &meson_dw_hdmi_ops, .probe = meson_dw_hdmi_probe, - .priv_auto_alloc_size = sizeof(struct meson_dw_hdmi), + .priv_auto = sizeof(struct meson_dw_hdmi), }; diff --git a/drivers/video/meson/meson_plane.c b/drivers/video/meson/meson_plane.c index b367276f23..e3f784ecfe 100644 --- a/drivers/video/meson/meson_plane.c +++ b/drivers/video/meson/meson_plane.c @@ -100,7 +100,7 @@ meson_vpp_disable_interlace_vscaler_osd1(struct meson_vpu_priv *priv) void meson_vpu_setup_plane(struct udevice *dev, bool is_interlaced) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct meson_vpu_priv *priv = dev_get_priv(dev); u32 osd1_ctrl_stat; diff --git a/drivers/video/meson/meson_vpu.c b/drivers/video/meson/meson_vpu.c index 4868839ff7..ca6933a6c5 100644 --- a/drivers/video/meson/meson_vpu.c +++ b/drivers/video/meson/meson_vpu.c @@ -43,7 +43,7 @@ bool meson_vpu_is_compatible(struct meson_vpu_priv *priv, static int meson_vpu_setup_mode(struct udevice *dev, struct udevice *disp) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct display_timing timing; bool is_cvbs = false; @@ -138,7 +138,7 @@ static int meson_vpu_probe(struct udevice *dev) static int meson_vpu_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); plat->size = VPU_MAX_WIDTH * VPU_MAX_HEIGHT * (1 << VPU_MAX_LOG2_BPP) / 8; @@ -211,6 +211,6 @@ U_BOOT_DRIVER(meson_vpu) = { .of_match = meson_vpu_ids, .probe = meson_vpu_probe, .bind = meson_vpu_bind, - .priv_auto_alloc_size = sizeof(struct meson_vpu_priv), + .priv_auto = sizeof(struct meson_vpu_priv), .flags = DM_FLAG_PRE_RELOC | DM_FLAG_REMOVE_WITH_PD_ON, }; diff --git a/drivers/video/mvebu_lcd.c b/drivers/video/mvebu_lcd.c index f3cb2bfb48..d3d07e5f83 100644 --- a/drivers/video/mvebu_lcd.c +++ b/drivers/video/mvebu_lcd.c @@ -526,7 +526,7 @@ static void mvebu_lcd_register_init(struct mvebu_lcd_info *lcd_info, static int mvebu_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct mvebu_video_priv *priv = dev_get_priv(dev); struct mvebu_lcd_info lcd_info; @@ -575,7 +575,7 @@ static int mvebu_video_probe(struct udevice *dev) static int mvebu_video_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * (1 << LCD_MAX_LOG2_BPP) / 8; @@ -594,5 +594,5 @@ U_BOOT_DRIVER(mvebu_video) = { .of_match = mvebu_video_ids, .bind = mvebu_video_bind, .probe = mvebu_video_probe, - .priv_auto_alloc_size = sizeof(struct mvebu_video_priv), + .priv_auto = sizeof(struct mvebu_video_priv), }; diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index 6589a2a09d..b43732a77a 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -356,7 +356,7 @@ static int mxs_of_get_timings(struct udevice *dev, static int mxs_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct display_timing timings; @@ -409,7 +409,7 @@ static int mxs_video_probe(struct udevice *dev) static int mxs_video_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct display_timing timings; u32 bpp = 0; u32 bytes_pp = 0; @@ -443,7 +443,7 @@ static int mxs_video_bind(struct udevice *dev) static int mxs_video_remove(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); mxs_remove_common(plat->base); diff --git a/drivers/video/nexell_display.c b/drivers/video/nexell_display.c index 4101e0962a..b47bef3578 100644 --- a/drivers/video/nexell_display.c +++ b/drivers/video/nexell_display.c @@ -174,7 +174,7 @@ static void nx_display_parse_dp_layer(ofnode node, struct dp_plane_info *plane) static void nx_display_parse_dp_planes(ofnode node, struct nx_display_dev *dp, - struct video_uc_platdata *plat) + struct video_uc_plat *plat) { const char *name; ofnode subnode; @@ -332,7 +332,7 @@ static int nx_display_parse_dp_lcds(ofnode node, const char *type, static int nx_display_parse_dt(struct udevice *dev, struct nx_display_dev *dp, - struct video_uc_platdata *plat) + struct video_uc_plat *plat) { const char *name, *dtype; int ret = 0; @@ -391,7 +391,7 @@ static struct nx_display_dev *nx_display_setup(void) struct nx_display_dev *dp; int i, ret; int node = 0; - struct video_uc_platdata *plat = NULL; + struct video_uc_plat *plat = NULL; struct udevice *dev; @@ -404,9 +404,9 @@ static struct nx_display_dev *nx_display_setup(void) __func__); return NULL; } - plat = dev_get_uclass_platdata(dev); + plat = dev_get_uclass_plat(dev); if (!dev) { - debug("%s(): dev_get_uclass_platdata(dev) == NULL --> return NULL\n", + debug("%s(): dev_get_uclass_plat(dev) == NULL --> return NULL\n", __func__); return NULL; } @@ -416,7 +416,7 @@ static struct nx_display_dev *nx_display_setup(void) __func__); return NULL; } - node = dev->node.of_offset; + node = dev_ofnode(dev).of_offset; if (CONFIG_IS_ENABLED(OF_CONTROL)) { ret = nx_display_parse_dt(dev, dp, plat); @@ -534,9 +534,9 @@ __weak void lcd_enable(void) static int nx_display_probe(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); - struct nx_display_platdata *plat = dev_get_platdata(dev); + struct nx_display_plat *plat = dev_get_plat(dev); static GraphicDevice *graphic_device; char addr[64]; @@ -546,7 +546,7 @@ static int nx_display_probe(struct udevice *dev) return -EINVAL; if (!uc_plat) { - debug("%s(): video_uc_platdata *plat == NULL --> return -EINVAL\n", + debug("%s(): video_uc_plat *plat == NULL --> return -EINVAL\n", __func__); return -EINVAL; } @@ -558,7 +558,7 @@ static int nx_display_probe(struct udevice *dev) } if (!plat) { - debug("%s(): nx_display_platdata *plat == NULL --> return -EINVAL\n", + debug("%s(): nx_display_plat *plat == NULL --> return -EINVAL\n", __func__); return -EINVAL; } @@ -619,7 +619,7 @@ static int nx_display_probe(struct udevice *dev) static int nx_display_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); debug("%s()\n", __func__); @@ -643,9 +643,8 @@ U_BOOT_DRIVER(nexell_display) = { .name = "nexell-display", .id = UCLASS_VIDEO, .of_match = nx_display_ids, - .platdata_auto_alloc_size = - sizeof(struct nx_display_platdata), + .plat_auto = sizeof(struct nx_display_plat), .bind = nx_display_bind, .probe = nx_display_probe, - .priv_auto_alloc_size = sizeof(struct nx_display_dev), + .priv_auto = sizeof(struct nx_display_dev), }; diff --git a/drivers/video/orisetech_otm8009a.c b/drivers/video/orisetech_otm8009a.c index 362bf6a6fe..95738e34bf 100644 --- a/drivers/video/orisetech_otm8009a.c +++ b/drivers/video/orisetech_otm8009a.c @@ -79,7 +79,7 @@ static const struct display_timing default_timing = { static void otm8009a_dcs_write_buf(struct udevice *dev, const void *data, size_t len) { - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); struct mipi_dsi_device *device = plat->device; if (mipi_dsi_dcs_write_buffer(device, data, len) < 0) @@ -89,7 +89,7 @@ static void otm8009a_dcs_write_buf(struct udevice *dev, const void *data, static void otm8009a_dcs_write_buf_hs(struct udevice *dev, const void *data, size_t len) { - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); struct mipi_dsi_device *device = plat->device; /* data will be sent in dsi hs mode (ie. no lpm) */ @@ -124,7 +124,7 @@ static void otm8009a_dcs_write_buf_hs(struct udevice *dev, const void *data, static int otm8009a_init_sequence(struct udevice *dev) { - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); struct mipi_dsi_device *device = plat->device; int ret; @@ -255,7 +255,7 @@ static int otm8009a_init_sequence(struct udevice *dev) static int otm8009a_panel_enable_backlight(struct udevice *dev) { - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); struct mipi_dsi_device *device = plat->device; int ret; @@ -295,7 +295,7 @@ static int otm8009a_panel_get_display_timing(struct udevice *dev, return 0; } -static int otm8009a_panel_ofdata_to_platdata(struct udevice *dev) +static int otm8009a_panel_of_to_plat(struct udevice *dev) { struct otm8009a_panel_priv *priv = dev_get_priv(dev); int ret; @@ -323,7 +323,7 @@ static int otm8009a_panel_ofdata_to_platdata(struct udevice *dev) static int otm8009a_panel_probe(struct udevice *dev) { struct otm8009a_panel_priv *priv = dev_get_priv(dev); - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); int ret; if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) { @@ -364,8 +364,8 @@ U_BOOT_DRIVER(otm8009a_panel) = { .id = UCLASS_PANEL, .of_match = otm8009a_panel_ids, .ops = &otm8009a_panel_ops, - .ofdata_to_platdata = otm8009a_panel_ofdata_to_platdata, + .of_to_plat = otm8009a_panel_of_to_plat, .probe = otm8009a_panel_probe, - .platdata_auto_alloc_size = sizeof(struct mipi_dsi_panel_plat), - .priv_auto_alloc_size = sizeof(struct otm8009a_panel_priv), + .plat_auto = sizeof(struct mipi_dsi_panel_plat), + .priv_auto = sizeof(struct otm8009a_panel_priv), }; diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c index 9519180ceb..9e32bc47cf 100644 --- a/drivers/video/pwm_backlight.c +++ b/drivers/video/pwm_backlight.c @@ -84,10 +84,10 @@ static int enable_sequence(struct udevice *dev, int seq) switch (seq) { case 0: if (priv->reg) { - __maybe_unused struct dm_regulator_uclass_platdata + __maybe_unused struct dm_regulator_uclass_plat *plat; - plat = dev_get_uclass_platdata(priv->reg); + plat = dev_get_uclass_plat(priv->reg); log_debug("Enable '%s', regulator '%s'/'%s'\n", dev->name, priv->reg->name, plat->name); ret = regulator_set_enable(priv->reg, true); @@ -182,7 +182,7 @@ static int pwm_backlight_set_brightness(struct udevice *dev, int percent) return 0; } -static int pwm_backlight_ofdata_to_platdata(struct udevice *dev) +static int pwm_backlight_of_to_plat(struct udevice *dev) { struct pwm_backlight_priv *priv = dev_get_priv(dev); struct ofnode_phandle_args args; @@ -263,7 +263,7 @@ U_BOOT_DRIVER(pwm_backlight) = { .id = UCLASS_PANEL_BACKLIGHT, .of_match = pwm_backlight_ids, .ops = &pwm_backlight_ops, - .ofdata_to_platdata = pwm_backlight_ofdata_to_platdata, + .of_to_plat = pwm_backlight_of_to_plat, .probe = pwm_backlight_probe, - .priv_auto_alloc_size = sizeof(struct pwm_backlight_priv), + .priv_auto = sizeof(struct pwm_backlight_priv), }; diff --git a/drivers/video/raydium-rm68200.c b/drivers/video/raydium-rm68200.c index 353894503b..373668d28b 100644 --- a/drivers/video/raydium-rm68200.c +++ b/drivers/video/raydium-rm68200.c @@ -92,7 +92,7 @@ static const struct display_timing default_timing = { static void rm68200_dcs_write_buf(struct udevice *dev, const void *data, size_t len) { - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); struct mipi_dsi_device *device = plat->device; int err; @@ -103,7 +103,7 @@ static void rm68200_dcs_write_buf(struct udevice *dev, const void *data, static void rm68200_dcs_write_cmd(struct udevice *dev, u8 cmd, u8 value) { - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); struct mipi_dsi_device *device = plat->device; int err; @@ -223,7 +223,7 @@ static void rm68200_init_sequence(struct udevice *dev) static int rm68200_panel_enable_backlight(struct udevice *dev) { - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); struct mipi_dsi_device *device = plat->device; struct rm68200_panel_priv *priv = dev_get_priv(dev); int ret; @@ -261,7 +261,7 @@ static int rm68200_panel_get_display_timing(struct udevice *dev, return 0; } -static int rm68200_panel_ofdata_to_platdata(struct udevice *dev) +static int rm68200_panel_of_to_plat(struct udevice *dev) { struct rm68200_panel_priv *priv = dev_get_priv(dev); int ret; @@ -296,7 +296,7 @@ static int rm68200_panel_ofdata_to_platdata(struct udevice *dev) static int rm68200_panel_probe(struct udevice *dev) { struct rm68200_panel_priv *priv = dev_get_priv(dev); - struct mipi_dsi_panel_plat *plat = dev_get_platdata(dev); + struct mipi_dsi_panel_plat *plat = dev_get_plat(dev); int ret; if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) { @@ -336,8 +336,8 @@ U_BOOT_DRIVER(rm68200_panel) = { .id = UCLASS_PANEL, .of_match = rm68200_panel_ids, .ops = &rm68200_panel_ops, - .ofdata_to_platdata = rm68200_panel_ofdata_to_platdata, + .of_to_plat = rm68200_panel_of_to_plat, .probe = rm68200_panel_probe, - .platdata_auto_alloc_size = sizeof(struct mipi_dsi_panel_plat), - .priv_auto_alloc_size = sizeof(struct rm68200_panel_priv), + .plat_auto = sizeof(struct mipi_dsi_panel_plat), + .priv_auto = sizeof(struct rm68200_panel_priv), }; diff --git a/drivers/video/rockchip/rk3288_hdmi.c b/drivers/video/rockchip/rk3288_hdmi.c index f835f4d517..327ae78712 100644 --- a/drivers/video/rockchip/rk3288_hdmi.c +++ b/drivers/video/rockchip/rk3288_hdmi.c @@ -25,7 +25,7 @@ static int rk3288_hdmi_enable(struct udevice *dev, int panel_bpp, const struct display_timing *edid) { struct rk_hdmi_priv *priv = dev_get_priv(dev); - struct display_plat *uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *uc_plat = dev_get_uclass_plat(dev); int vop_id = uc_plat->source_id; struct rk3288_grf *grf = priv->grf; @@ -38,7 +38,7 @@ static int rk3288_hdmi_enable(struct udevice *dev, int panel_bpp, return dw_hdmi_enable(&priv->hdmi, edid); } -static int rk3288_hdmi_ofdata_to_platdata(struct udevice *dev) +static int rk3288_hdmi_of_to_plat(struct udevice *dev) { struct rk_hdmi_priv *priv = dev_get_priv(dev); struct dw_hdmi *hdmi = &priv->hdmi; @@ -53,12 +53,12 @@ static int rk3288_hdmi_ofdata_to_platdata(struct udevice *dev) hdmi->i2c_clk_high = 0x0d; hdmi->i2c_clk_low = 0x0d; - return rk_hdmi_ofdata_to_platdata(dev); + return rk_hdmi_of_to_plat(dev); } static int rk3288_clk_config(struct udevice *dev) { - struct display_plat *uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *uc_plat = dev_get_uclass_plat(dev); struct clk clk; int ret; @@ -111,7 +111,7 @@ U_BOOT_DRIVER(rk3288_hdmi_rockchip) = { .id = UCLASS_DISPLAY, .of_match = rk3288_hdmi_ids, .ops = &rk3288_hdmi_ops, - .ofdata_to_platdata = rk3288_hdmi_ofdata_to_platdata, + .of_to_plat = rk3288_hdmi_of_to_plat, .probe = rk3288_hdmi_probe, - .priv_auto_alloc_size = sizeof(struct rk_hdmi_priv), + .priv_auto = sizeof(struct rk_hdmi_priv), }; diff --git a/drivers/video/rockchip/rk3288_mipi.c b/drivers/video/rockchip/rk3288_mipi.c index 8ac0125b50..7e48dd8346 100644 --- a/drivers/video/rockchip/rk3288_mipi.c +++ b/drivers/video/rockchip/rk3288_mipi.c @@ -31,7 +31,7 @@ static int rk_mipi_dsi_source_select(struct udevice *dev) { struct rk_mipi_priv *priv = dev_get_priv(dev); struct rk3288_grf *grf = priv->grf; - struct display_plat *disp_uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *disp_uc_plat = dev_get_uclass_plat(dev); /* Select the video source */ switch (disp_uc_plat->source_id) { @@ -129,7 +129,7 @@ static int rk_mipi_enable(struct udevice *dev, int panel_bpp, return 0; } -static int rk_mipi_ofdata_to_platdata(struct udevice *dev) +static int rk_mipi_of_to_plat(struct udevice *dev) { struct rk_mipi_priv *priv = dev_get_priv(dev); @@ -182,8 +182,8 @@ U_BOOT_DRIVER(rk_mipi_dsi) = { .name = "rk_mipi_dsi", .id = UCLASS_DISPLAY, .of_match = rk_mipi_dsi_ids, - .ofdata_to_platdata = rk_mipi_ofdata_to_platdata, + .of_to_plat = rk_mipi_of_to_plat, .probe = rk_mipi_probe, .ops = &rk_mipi_dsi_ops, - .priv_auto_alloc_size = sizeof(struct rk_mipi_priv), + .priv_auto = sizeof(struct rk_mipi_priv), }; diff --git a/drivers/video/rockchip/rk3288_vop.c b/drivers/video/rockchip/rk3288_vop.c index 9ec33e6e51..3f6ee74487 100644 --- a/drivers/video/rockchip/rk3288_vop.c +++ b/drivers/video/rockchip/rk3288_vop.c @@ -105,5 +105,5 @@ U_BOOT_DRIVER(rockchip_rk3288_vop) = { .bind = rk_vop_bind, .probe = rk3288_vop_probe, .remove = rk_vop_remove, - .priv_auto_alloc_size = sizeof(struct rk_vop_priv), + .priv_auto = sizeof(struct rk_vop_priv), }; diff --git a/drivers/video/rockchip/rk3399_hdmi.c b/drivers/video/rockchip/rk3399_hdmi.c index a62be98327..3041360c6e 100644 --- a/drivers/video/rockchip/rk3399_hdmi.c +++ b/drivers/video/rockchip/rk3399_hdmi.c @@ -23,7 +23,7 @@ static int rk3399_hdmi_enable(struct udevice *dev, int panel_bpp, const struct display_timing *edid) { struct rk_hdmi_priv *priv = dev_get_priv(dev); - struct display_plat *uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *uc_plat = dev_get_uclass_plat(dev); int vop_id = uc_plat->source_id; struct rk3399_grf_regs *grf = priv->grf; @@ -34,7 +34,7 @@ static int rk3399_hdmi_enable(struct udevice *dev, int panel_bpp, return dw_hdmi_enable(&priv->hdmi, edid); } -static int rk3399_hdmi_ofdata_to_platdata(struct udevice *dev) +static int rk3399_hdmi_of_to_plat(struct udevice *dev) { struct rk_hdmi_priv *priv = dev_get_priv(dev); struct dw_hdmi *hdmi = &priv->hdmi; @@ -42,7 +42,7 @@ static int rk3399_hdmi_ofdata_to_platdata(struct udevice *dev) hdmi->i2c_clk_high = 0x7a; hdmi->i2c_clk_low = 0x8d; - return rk_hdmi_ofdata_to_platdata(dev); + return rk_hdmi_of_to_plat(dev); } static const char * const rk3399_regulator_names[] = { @@ -74,7 +74,7 @@ U_BOOT_DRIVER(rk3399_hdmi_rockchip) = { .id = UCLASS_DISPLAY, .of_match = rk3399_hdmi_ids, .ops = &rk3399_hdmi_ops, - .ofdata_to_platdata = rk3399_hdmi_ofdata_to_platdata, + .of_to_plat = rk3399_hdmi_of_to_plat, .probe = rk3399_hdmi_probe, - .priv_auto_alloc_size = sizeof(struct rk_hdmi_priv), + .priv_auto = sizeof(struct rk_hdmi_priv), }; diff --git a/drivers/video/rockchip/rk3399_mipi.c b/drivers/video/rockchip/rk3399_mipi.c index e5534c36e6..9173350483 100644 --- a/drivers/video/rockchip/rk3399_mipi.c +++ b/drivers/video/rockchip/rk3399_mipi.c @@ -29,7 +29,7 @@ static int rk_mipi_dsi_source_select(struct udevice *dev) { struct rk_mipi_priv *priv = dev_get_priv(dev); struct rk3399_grf_regs *grf = priv->grf; - struct display_plat *disp_uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *disp_uc_plat = dev_get_uclass_plat(dev); /* Select the video source */ switch (disp_uc_plat->source_id) { @@ -121,7 +121,7 @@ static int rk_display_enable(struct udevice *dev, int panel_bpp, return 0; } -static int rk_mipi_ofdata_to_platdata(struct udevice *dev) +static int rk_mipi_of_to_plat(struct udevice *dev) { struct rk_mipi_priv *priv = dev_get_priv(dev); @@ -173,8 +173,8 @@ U_BOOT_DRIVER(rk_mipi_dsi) = { .name = "rk_mipi_dsi", .id = UCLASS_DISPLAY, .of_match = rk_mipi_dsi_ids, - .ofdata_to_platdata = rk_mipi_ofdata_to_platdata, + .of_to_plat = rk_mipi_of_to_plat, .probe = rk_mipi_probe, .ops = &rk_mipi_dsi_ops, - .priv_auto_alloc_size = sizeof(struct rk_mipi_priv), + .priv_auto = sizeof(struct rk_mipi_priv), }; diff --git a/drivers/video/rockchip/rk3399_vop.c b/drivers/video/rockchip/rk3399_vop.c index 55d1be0411..30e81b88b6 100644 --- a/drivers/video/rockchip/rk3399_vop.c +++ b/drivers/video/rockchip/rk3399_vop.c @@ -99,5 +99,5 @@ U_BOOT_DRIVER(rk3399_vop) = { .ops = &rk3399_vop_ops, .bind = rk_vop_bind, .probe = rk3399_vop_probe, - .priv_auto_alloc_size = sizeof(struct rk_vop_priv), + .priv_auto = sizeof(struct rk_vop_priv), }; diff --git a/drivers/video/rockchip/rk_edp.c b/drivers/video/rockchip/rk_edp.c index c55f7a4f72..0be60e169e 100644 --- a/drivers/video/rockchip/rk_edp.c +++ b/drivers/video/rockchip/rk_edp.c @@ -1001,7 +1001,7 @@ done: return edid_size; } -static int rk_edp_ofdata_to_platdata(struct udevice *dev) +static int rk_edp_of_to_plat(struct udevice *dev) { struct rk_edp_priv *priv = dev_get_priv(dev); @@ -1026,7 +1026,7 @@ static int rk_edp_remove(struct udevice *dev) static int rk_edp_probe(struct udevice *dev) { - struct display_plat *uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *uc_plat = dev_get_uclass_plat(dev); struct rk_edp_priv *priv = dev_get_priv(dev); struct rk3288_edp *regs = priv->regs; struct clk clk; @@ -1099,8 +1099,8 @@ U_BOOT_DRIVER(dp_rockchip) = { .id = UCLASS_DISPLAY, .of_match = rockchip_dp_ids, .ops = &dp_rockchip_ops, - .ofdata_to_platdata = rk_edp_ofdata_to_platdata, + .of_to_plat = rk_edp_of_to_plat, .probe = rk_edp_probe, .remove = rk_edp_remove, - .priv_auto_alloc_size = sizeof(struct rk_edp_priv), + .priv_auto = sizeof(struct rk_edp_priv), }; diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c index f27cdf8ed4..8dcd4d5964 100644 --- a/drivers/video/rockchip/rk_hdmi.c +++ b/drivers/video/rockchip/rk_hdmi.c @@ -78,7 +78,7 @@ int rk_hdmi_read_edid(struct udevice *dev, u8 *buf, int buf_size) return dw_hdmi_read_edid(&priv->hdmi, buf, buf_size); } -int rk_hdmi_ofdata_to_platdata(struct udevice *dev) +int rk_hdmi_of_to_plat(struct udevice *dev) { struct rk_hdmi_priv *priv = dev_get_priv(dev); struct dw_hdmi *hdmi = &priv->hdmi; diff --git a/drivers/video/rockchip/rk_hdmi.h b/drivers/video/rockchip/rk_hdmi.h index 5767ef1443..859a0b9ff3 100644 --- a/drivers/video/rockchip/rk_hdmi.h +++ b/drivers/video/rockchip/rk_hdmi.h @@ -52,12 +52,12 @@ int rk_hdmi_read_edid(struct udevice *dev, u8 *buf, int buf_size); void rk_hdmi_probe_regulators(struct udevice *dev, const char * const *names, int cnt); /** - * rk_hdmi_ofdata_to_platdata() - common ofdata_to_platdata implementation + * rk_hdmi_of_to_plat() - common of_to_plat implementation * * @dev: device * @return 0 if OK, -ve if something went wrong */ -int rk_hdmi_ofdata_to_platdata(struct udevice *dev); +int rk_hdmi_of_to_plat(struct udevice *dev); /** * rk_hdmi_probe() - common probe implementation diff --git a/drivers/video/rockchip/rk_lvds.c b/drivers/video/rockchip/rk_lvds.c index 04f795a213..03c8257a35 100644 --- a/drivers/video/rockchip/rk_lvds.c +++ b/drivers/video/rockchip/rk_lvds.c @@ -53,7 +53,7 @@ int rk_lvds_enable(struct udevice *dev, int panel_bpp, const struct display_timing *edid) { struct rk_lvds_priv *priv = dev_get_priv(dev); - struct display_plat *uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *uc_plat = dev_get_uclass_plat(dev); int ret = 0; unsigned int val = 0; @@ -170,7 +170,7 @@ int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing) return 0; } -static int rk_lvds_ofdata_to_platdata(struct udevice *dev) +static int rk_lvds_of_to_plat(struct udevice *dev) { struct rk_lvds_priv *priv = dev_get_priv(dev); int ret; @@ -245,7 +245,7 @@ U_BOOT_DRIVER(lvds_rockchip) = { .id = UCLASS_DISPLAY, .of_match = rockchip_lvds_ids, .ops = &lvds_rockchip_ops, - .ofdata_to_platdata = rk_lvds_ofdata_to_platdata, + .of_to_plat = rk_lvds_of_to_plat, .probe = rk_lvds_probe, - .priv_auto_alloc_size = sizeof(struct rk_lvds_priv), + .priv_auto = sizeof(struct rk_lvds_priv), }; diff --git a/drivers/video/rockchip/rk_mipi.c b/drivers/video/rockchip/rk_mipi.c index d125a5ba73..159201a591 100644 --- a/drivers/video/rockchip/rk_mipi.c +++ b/drivers/video/rockchip/rk_mipi.c @@ -119,7 +119,7 @@ int rk_mipi_dsi_enable(struct udevice *dev, rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0); /* Set dpi color coding depth 24 bit */ - timing_node = ofnode_find_subnode(dev->node, "display-timings"); + timing_node = ofnode_find_subnode(dev_ofnode(dev), "display-timings"); node = ofnode_first_subnode(timing_node); val = ofnode_read_u32_default(node, "bits-per-pixel", -1); diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c index 6475b3e2af..fcb393b906 100644 --- a/drivers/video/rockchip/rk_vop.c +++ b/drivers/video/rockchip/rk_vop.c @@ -283,7 +283,7 @@ static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node) break; }; - disp_uc_plat = dev_get_uclass_platdata(disp); + disp_uc_plat = dev_get_uclass_plat(disp); debug("Found device '%s', disp_uc_priv=%p\n", disp->name, disp_uc_plat); if (display_in_use(disp)) { debug(" - device in use\n"); @@ -364,7 +364,7 @@ void rk_vop_probe_regulators(struct udevice *dev, int rk_vop_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct rk_vop_priv *priv = dev_get_priv(dev); int ret = 0; ofnode port, node; @@ -406,7 +406,7 @@ int rk_vop_probe(struct udevice *dev) int rk_vop_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); plat->size = 4 * (CONFIG_VIDEO_ROCKCHIP_MAX_XRES * CONFIG_VIDEO_ROCKCHIP_MAX_YRES); diff --git a/drivers/video/sandbox_dsi_host.c b/drivers/video/sandbox_dsi_host.c index cd644ec0b4..c84a27ee3b 100644 --- a/drivers/video/sandbox_dsi_host.c +++ b/drivers/video/sandbox_dsi_host.c @@ -86,5 +86,5 @@ U_BOOT_DRIVER(sandbox_dsi_host) = { .id = UCLASS_DSI_HOST, .of_match = sandbox_dsi_host_ids, .ops = &sandbox_dsi_host_ops, - .priv_auto_alloc_size = sizeof(struct sandbox_dsi_host_priv), + .priv_auto = sizeof(struct sandbox_dsi_host_priv), }; diff --git a/drivers/video/sandbox_osd.c b/drivers/video/sandbox_osd.c index 7e722326b3..2a854d3958 100644 --- a/drivers/video/sandbox_osd.c +++ b/drivers/video/sandbox_osd.c @@ -158,5 +158,5 @@ U_BOOT_DRIVER(sandbox_osd_drv) = { .ops = &sandbox_osd_ops, .of_match = sandbox_osd_ids, .probe = sandbox_osd_probe, - .priv_auto_alloc_size = sizeof(struct sandbox_osd_priv), + .priv_auto = sizeof(struct sandbox_osd_priv), }; diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index d806f35deb..12edf9c90c 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -23,8 +23,8 @@ enum { static int sandbox_sdl_probe(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); - struct sandbox_sdl_plat *plat = dev_get_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); + struct sandbox_sdl_plat *plat = dev_get_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct sandbox_state *state = state_get_current(); int ret; @@ -49,8 +49,8 @@ static int sandbox_sdl_probe(struct udevice *dev) static int sandbox_sdl_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); - struct sandbox_sdl_plat *plat = dev_get_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); + struct sandbox_sdl_plat *plat = dev_get_plat(dev); int ret = 0; plat->xres = dev_read_u32_default(dev, "xres", LCD_MAX_WIDTH); @@ -78,5 +78,5 @@ U_BOOT_DRIVER(sandbox_lcd_sdl) = { .of_match = sandbox_sdl_ids, .bind = sandbox_sdl_bind, .probe = sandbox_sdl_probe, - .platdata_auto_alloc_size = sizeof(struct sandbox_sdl_plat), + .plat_auto = sizeof(struct sandbox_sdl_plat), }; diff --git a/drivers/video/seps525.c b/drivers/video/seps525.c new file mode 100644 index 0000000000..369e5e6afc --- /dev/null +++ b/drivers/video/seps525.c @@ -0,0 +1,327 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * FB driver for the WiseChip Semiconductor Inc. (UG-6028GDEBF02) display + * using the SEPS525 (Syncoam) LCD Controller + * + * Copyright (C) 2020 Xilinx Inc. + */ + +#include <common.h> +#include <command.h> +#include <cpu_func.h> +#include <dm.h> +#include <errno.h> +#include <spi.h> +#include <video.h> +#include <asm/gpio.h> +#include <dm/device_compat.h> +#include <linux/delay.h> + +#define WIDTH 160 +#define HEIGHT 128 + +#define SEPS525_INDEX 0x00 +#define SEPS525_STATUS_RD 0x01 +#define SEPS525_OSC_CTL 0x02 +#define SEPS525_IREF 0x80 +#define SEPS525_CLOCK_DIV 0x03 +#define SEPS525_REDUCE_CURRENT 0x04 +#define SEPS525_SOFT_RST 0x05 +#define SEPS525_DISP_ONOFF 0x06 +#define SEPS525_PRECHARGE_TIME_R 0x08 +#define SEPS525_PRECHARGE_TIME_G 0x09 +#define SEPS525_PRECHARGE_TIME_B 0x0A +#define SEPS525_PRECHARGE_CURRENT_R 0x0B +#define SEPS525_PRECHARGE_CURRENT_G 0x0C +#define SEPS525_PRECHARGE_CURRENT_B 0x0D +#define SEPS525_DRIVING_CURRENT_R 0x10 +#define SEPS525_DRIVING_CURRENT_G 0x11 +#define SEPS525_DRIVING_CURRENT_B 0x12 +#define SEPS525_DISPLAYMODE_SET 0x13 +#define SEPS525_RGBIF 0x14 +#define SEPS525_RGB_POL 0x15 +#define SEPS525_MEMORY_WRITEMODE 0x16 +#define SEPS525_MX1_ADDR 0x17 +#define SEPS525_MX2_ADDR 0x18 +#define SEPS525_MY1_ADDR 0x19 +#define SEPS525_MY2_ADDR 0x1A +#define SEPS525_MEMORY_ACCESS_POINTER_X 0x20 +#define SEPS525_MEMORY_ACCESS_POINTER_Y 0x21 +#define SEPS525_DDRAM_DATA_ACCESS_PORT 0x22 +#define SEPS525_GRAY_SCALE_TABLE_INDEX 0x50 +#define SEPS525_GRAY_SCALE_TABLE_DATA 0x51 +#define SEPS525_DUTY 0x28 +#define SEPS525_DSL 0x29 +#define SEPS525_D1_DDRAM_FAC 0x2E +#define SEPS525_D1_DDRAM_FAR 0x2F +#define SEPS525_D2_DDRAM_SAC 0x31 +#define SEPS525_D2_DDRAM_SAR 0x32 +#define SEPS525_SCR1_FX1 0x33 +#define SEPS525_SCR1_FX2 0x34 +#define SEPS525_SCR1_FY1 0x35 +#define SEPS525_SCR1_FY2 0x36 +#define SEPS525_SCR2_SX1 0x37 +#define SEPS525_SCR2_SX2 0x38 +#define SEPS525_SCR2_SY1 0x39 +#define SEPS525_SCR2_SY2 0x3A +#define SEPS525_SCREEN_SAVER_CONTEROL 0x3B +#define SEPS525_SS_SLEEP_TIMER 0x3C +#define SEPS525_SCREEN_SAVER_MODE 0x3D +#define SEPS525_SS_SCR1_FU 0x3E +#define SEPS525_SS_SCR1_MXY 0x3F +#define SEPS525_SS_SCR2_FU 0x40 +#define SEPS525_SS_SCR2_MXY 0x41 +#define SEPS525_MOVING_DIRECTION 0x42 +#define SEPS525_SS_SCR2_SX1 0x47 +#define SEPS525_SS_SCR2_SX2 0x48 +#define SEPS525_SS_SCR2_SY1 0x49 +#define SEPS525_SS_SCR2_SY2 0x4A + +/* SEPS525_DISPLAYMODE_SET */ +#define MODE_SWAP_BGR BIT(7) +#define MODE_SM BIT(6) +#define MODE_RD BIT(5) +#define MODE_CD BIT(4) + +/** + * struct seps525_priv - Private structure + * @reset_gpio: Reset gpio pin + * @dc_gpio: Data/command control gpio pin + * @dev: Device uclass for video_ops + */ +struct seps525_priv { + struct gpio_desc reset_gpio; + struct gpio_desc dc_gpio; + struct udevice *dev; +}; + +static int seps525_spi_write_cmd(struct udevice *dev, u32 reg) +{ + struct seps525_priv *priv = dev_get_priv(dev); + u8 buf8 = reg; + int ret; + + ret = dm_gpio_set_value(&priv->dc_gpio, 0); + if (ret) { + dev_dbg(dev, "Failed to handle dc\n"); + return ret; + } + + ret = dm_spi_xfer(dev, 8, &buf8, NULL, SPI_XFER_BEGIN | SPI_XFER_END); + if (ret) + dev_dbg(dev, "Failed to write command\n"); + + return ret; +} + +static int seps525_spi_write_data(struct udevice *dev, u32 val) +{ + struct seps525_priv *priv = dev_get_priv(dev); + u8 buf8 = val; + int ret; + + ret = dm_gpio_set_value(&priv->dc_gpio, 1); + if (ret) { + dev_dbg(dev, "Failed to handle dc\n"); + return ret; + } + + ret = dm_spi_xfer(dev, 8, &buf8, NULL, SPI_XFER_BEGIN | SPI_XFER_END); + if (ret) + dev_dbg(dev, "Failed to write data\n"); + + return ret; +} + +static void seps525_spi_write(struct udevice *dev, u32 reg, u32 val) +{ + (void)seps525_spi_write_cmd(dev, reg); + (void)seps525_spi_write_data(dev, val); +} + +static int seps525_display_init(struct udevice *dev) +{ + /* Disable Oscillator Power Down */ + seps525_spi_write(dev, SEPS525_REDUCE_CURRENT, 0x03); + mdelay(5); + + /* Set Normal Driving Current */ + seps525_spi_write(dev, SEPS525_REDUCE_CURRENT, 0x00); + mdelay(5); + + seps525_spi_write(dev, SEPS525_SCREEN_SAVER_CONTEROL, 0x00); + /* Set EXPORT1 Pin at Internal Clock */ + seps525_spi_write(dev, SEPS525_OSC_CTL, 0x01); + /* Set Clock as 120 Frames/Sec */ + seps525_spi_write(dev, SEPS525_CLOCK_DIV, 0x90); + /* Set Reference Voltage Controlled by External Resister */ + seps525_spi_write(dev, SEPS525_IREF, 0x01); + + /* precharge time R G B */ + seps525_spi_write(dev, SEPS525_PRECHARGE_TIME_R, 0x04); + seps525_spi_write(dev, SEPS525_PRECHARGE_TIME_G, 0x05); + seps525_spi_write(dev, SEPS525_PRECHARGE_TIME_B, 0x05); + + /* precharge current R G B (uA) */ + seps525_spi_write(dev, SEPS525_PRECHARGE_CURRENT_R, 0x9D); + seps525_spi_write(dev, SEPS525_PRECHARGE_CURRENT_G, 0x8C); + seps525_spi_write(dev, SEPS525_PRECHARGE_CURRENT_B, 0x57); + + /* driving current R G B (uA) */ + seps525_spi_write(dev, SEPS525_DRIVING_CURRENT_R, 0x56); + seps525_spi_write(dev, SEPS525_DRIVING_CURRENT_G, 0x4D); + seps525_spi_write(dev, SEPS525_DRIVING_CURRENT_B, 0x46); + /* Set Color Sequence */ + seps525_spi_write(dev, SEPS525_DISPLAYMODE_SET, 0x00); + /* Set MCU Interface Mode */ + seps525_spi_write(dev, SEPS525_RGBIF, 0x01); + /* Set Memory Write Mode */ + seps525_spi_write(dev, SEPS525_MEMORY_WRITEMODE, 0x66); + /* 1/128 Duty (0x0F~0x7F) */ + seps525_spi_write(dev, SEPS525_DUTY, 0x7F); + /* Set Mapping RAM Display Start Line (0x00~0x7F) */ + seps525_spi_write(dev, SEPS525_DSL, 0x00); + /* Display On (0x00/0x01) */ + seps525_spi_write(dev, SEPS525_DISP_ONOFF, 0x01); + /* Set All Internal Register Value as Normal Mode */ + seps525_spi_write(dev, SEPS525_SOFT_RST, 0x00); + /* Set RGB Interface Polarity as Active Low */ + seps525_spi_write(dev, SEPS525_RGB_POL, 0x00); + + /* Enable access for data */ + (void)seps525_spi_write_cmd(dev, SEPS525_DDRAM_DATA_ACCESS_PORT); + + return 0; +} + +static int seps525_spi_startup(struct udevice *dev) +{ + struct seps525_priv *priv = dev_get_priv(dev); + int ret; + + ret = dm_gpio_set_value(&priv->reset_gpio, 1); + if (ret) + return ret; + + ret = dm_gpio_set_value(&priv->reset_gpio, 0); + if (ret) + return ret; + + ret = dm_spi_claim_bus(dev); + if (ret) { + dev_err(dev, "Failed to claim SPI bus: %d\n", ret); + return ret; + } + + ret = seps525_display_init(dev); + if (ret) + return ret; + + dm_spi_release_bus(dev); + + return 0; +} + +static int seps525_sync(struct udevice *vid) +{ + struct video_priv *uc_priv = dev_get_uclass_priv(vid); + struct seps525_priv *priv = dev_get_priv(vid); + struct udevice *dev = priv->dev; + int i, ret; + u8 data1, data2; + u8 *start = uc_priv->fb; + + ret = dm_spi_claim_bus(dev); + if (ret) { + dev_err(dev, "Failed to claim SPI bus: %d\n", ret); + return ret; + } + + /* start position X,Y */ + seps525_spi_write(dev, SEPS525_MEMORY_ACCESS_POINTER_X, 0); + seps525_spi_write(dev, SEPS525_MEMORY_ACCESS_POINTER_Y, 0); + + /* Enable access for data */ + (void)seps525_spi_write_cmd(dev, SEPS525_DDRAM_DATA_ACCESS_PORT); + + for (i = 0; i < (uc_priv->xsize * uc_priv->ysize); i++) { + data2 = *start++; + data1 = *start++; + (void)seps525_spi_write_data(dev, data1); + (void)seps525_spi_write_data(dev, data2); + } + + dm_spi_release_bus(dev); + + return 0; +} + +static int seps525_probe(struct udevice *dev) +{ + struct video_priv *uc_priv = dev_get_uclass_priv(dev); + struct seps525_priv *priv = dev_get_priv(dev); + u32 buswidth; + int ret; + + buswidth = dev_read_u32_default(dev, "buswidth", 0); + if (buswidth != 8) { + dev_err(dev, "Only 8bit buswidth is supported now"); + return -EINVAL; + } + + ret = gpio_request_by_name(dev, "reset-gpios", 0, + &priv->reset_gpio, GPIOD_IS_OUT); + if (ret) { + dev_err(dev, "missing reset GPIO\n"); + return ret; + } + + ret = gpio_request_by_name(dev, "dc-gpios", 0, + &priv->dc_gpio, GPIOD_IS_OUT); + if (ret) { + dev_err(dev, "missing dc GPIO\n"); + return ret; + } + + uc_priv->bpix = VIDEO_BPP16; + uc_priv->xsize = WIDTH; + uc_priv->ysize = HEIGHT; + uc_priv->rot = 0; + + priv->dev = dev; + + ret = seps525_spi_startup(dev); + if (ret) + return ret; + + return 0; +} + +static int seps525_bind(struct udevice *dev) +{ + struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + + plat->size = WIDTH * HEIGHT * 16; + + return 0; +} + +static const struct video_ops seps525_ops = { + .video_sync = seps525_sync, +}; + +static const struct udevice_id seps525_ids[] = { + { .compatible = "syncoam,seps525" }, + { } +}; + +U_BOOT_DRIVER(seps525_video) = { + .name = "seps525_video", + .id = UCLASS_VIDEO, + .of_match = seps525_ids, + .ops = &seps525_ops, + .platdata_auto_alloc_size = sizeof(struct video_uc_platdata), + .bind = seps525_bind, + .probe = seps525_probe, + .priv_auto_alloc_size = sizeof(struct seps525_priv), +}; diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c index 6c624c3769..59e17f8f10 100644 --- a/drivers/video/simple_panel.c +++ b/drivers/video/simple_panel.c @@ -48,7 +48,7 @@ static int simple_panel_set_backlight(struct udevice *dev, int percent) return 0; } -static int simple_panel_ofdata_to_platdata(struct udevice *dev) +static int simple_panel_of_to_plat(struct udevice *dev) { struct simple_panel_priv *priv = dev_get_priv(dev); int ret; @@ -116,7 +116,7 @@ U_BOOT_DRIVER(simple_panel) = { .id = UCLASS_PANEL, .of_match = simple_panel_ids, .ops = &simple_panel_ops, - .ofdata_to_platdata = simple_panel_ofdata_to_platdata, + .of_to_plat = simple_panel_of_to_plat, .probe = simple_panel_probe, - .priv_auto_alloc_size = sizeof(struct simple_panel_priv), + .priv_auto = sizeof(struct simple_panel_priv), }; diff --git a/drivers/video/simplefb.c b/drivers/video/simplefb.c index 0c5b40c30b..b5fb6f62bb 100644 --- a/drivers/video/simplefb.c +++ b/drivers/video/simplefb.c @@ -12,7 +12,7 @@ static int simple_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); const void *blob = gd->fdt_blob; const int node = dev_of_offset(dev); diff --git a/drivers/video/stm32/stm32_dsi.c b/drivers/video/stm32/stm32_dsi.c index 9d5abacc2b..266623b876 100644 --- a/drivers/video/stm32/stm32_dsi.c +++ b/drivers/video/stm32/stm32_dsi.c @@ -351,7 +351,7 @@ static int stm32_dsi_attach(struct udevice *dev) return ret; } - mplat = dev_get_platdata(priv->panel); + mplat = dev_get_plat(priv->panel); mplat->device = &priv->device; device->lanes = mplat->lanes; device->format = mplat->format; @@ -512,5 +512,5 @@ U_BOOT_DRIVER(stm32_dsi) = { .bind = stm32_dsi_bind, .probe = stm32_dsi_probe, .ops = &stm32_dsi_ops, - .priv_auto_alloc_size = sizeof(struct stm32_dsi_priv), + .priv_auto = sizeof(struct stm32_dsi_priv), }; diff --git a/drivers/video/stm32/stm32_ltdc.c b/drivers/video/stm32/stm32_ltdc.c index 7fff735930..dc10b8cfc1 100644 --- a/drivers/video/stm32/stm32_ltdc.c +++ b/drivers/video/stm32/stm32_ltdc.c @@ -329,7 +329,7 @@ static void stm32_ltdc_set_layer1(struct stm32_ltdc_priv *priv, ulong fb_addr) static int stm32_ltdc_probe(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct stm32_ltdc_priv *priv = dev_get_priv(dev); struct udevice *bridge = NULL; @@ -452,7 +452,7 @@ static int stm32_ltdc_probe(struct udevice *dev) static int stm32_ltdc_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); uc_plat->size = CONFIG_VIDEO_STM32_MAX_XRES * CONFIG_VIDEO_STM32_MAX_YRES * @@ -473,5 +473,5 @@ U_BOOT_DRIVER(stm32_ltdc) = { .of_match = stm32_ltdc_ids, .probe = stm32_ltdc_probe, .bind = stm32_ltdc_bind, - .priv_auto_alloc_size = sizeof(struct stm32_ltdc_priv), + .priv_auto = sizeof(struct stm32_ltdc_priv), }; diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c index b657e163f0..a3e21aa5f1 100644 --- a/drivers/video/sunxi/sunxi_de2.c +++ b/drivers/video/sunxi/sunxi_de2.c @@ -189,7 +189,7 @@ static int sunxi_de2_init(struct udevice *dev, ulong fbbase, struct display_plat *disp_uc_plat; int ret; - disp_uc_plat = dev_get_uclass_platdata(disp); + disp_uc_plat = dev_get_uclass_plat(disp); debug("Using device '%s', disp_uc_priv=%p\n", disp->name, disp_uc_plat); if (display_in_use(disp)) { debug(" - device in use\n"); @@ -237,7 +237,7 @@ static int sunxi_de2_init(struct udevice *dev, ulong fbbase, static int sunxi_de2_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct udevice *disp; int ret; @@ -299,7 +299,7 @@ static int sunxi_de2_probe(struct udevice *dev) static int sunxi_de2_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * (1 << LCD_MAX_LOG2_BPP) / 8; @@ -319,7 +319,7 @@ U_BOOT_DRIVER(sunxi_de2) = { .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DEVICE(sunxi_de2) = { +U_BOOT_DRVINFO(sunxi_de2) = { .name = "sunxi_de2" }; @@ -331,7 +331,7 @@ int sunxi_simplefb_setup(void *blob) { struct udevice *de2, *hdmi, *lcd; struct video_priv *de2_priv; - struct video_uc_platdata *de2_plat; + struct video_uc_plat *de2_plat; int mux; int offset, ret; u64 start, size; @@ -383,7 +383,7 @@ int sunxi_simplefb_setup(void *blob) } de2_priv = dev_get_uclass_priv(de2); - de2_plat = dev_get_uclass_platdata(de2); + de2_plat = dev_get_uclass_plat(de2); offset = sunxi_simplefb_fdt_match(blob, pipeline); if (offset < 0) { diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c b/drivers/video/sunxi/sunxi_dw_hdmi.c index 01d4b7a11c..0b8cefc311 100644 --- a/drivers/video/sunxi/sunxi_dw_hdmi.c +++ b/drivers/video/sunxi/sunxi_dw_hdmi.c @@ -340,7 +340,7 @@ static int sunxi_dw_hdmi_enable(struct udevice *dev, int panel_bpp, static int sunxi_dw_hdmi_probe(struct udevice *dev) { - struct display_plat *uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *uc_plat = dev_get_uclass_plat(dev); struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev); struct sunxi_ccm_reg * const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; @@ -395,9 +395,9 @@ U_BOOT_DRIVER(sunxi_dw_hdmi) = { .id = UCLASS_DISPLAY, .ops = &sunxi_dw_hdmi_ops, .probe = sunxi_dw_hdmi_probe, - .priv_auto_alloc_size = sizeof(struct sunxi_dw_hdmi_priv), + .priv_auto = sizeof(struct sunxi_dw_hdmi_priv), }; -U_BOOT_DEVICE(sunxi_dw_hdmi) = { +U_BOOT_DRVINFO(sunxi_dw_hdmi) = { .name = "sunxi_dw_hdmi" }; diff --git a/drivers/video/sunxi/sunxi_lcd.c b/drivers/video/sunxi/sunxi_lcd.c index 49bf083a8d..635edf6dd3 100644 --- a/drivers/video/sunxi/sunxi_lcd.c +++ b/drivers/video/sunxi/sunxi_lcd.c @@ -142,11 +142,11 @@ U_BOOT_DRIVER(sunxi_lcd) = { .id = UCLASS_DISPLAY, .ops = &sunxi_lcd_ops, .probe = sunxi_lcd_probe, - .priv_auto_alloc_size = sizeof(struct sunxi_lcd_priv), + .priv_auto = sizeof(struct sunxi_lcd_priv), }; #ifdef CONFIG_MACH_SUN50I -U_BOOT_DEVICE(sunxi_lcd) = { +U_BOOT_DRVINFO(sunxi_lcd) = { .name = "sunxi_lcd" }; #endif diff --git a/drivers/video/tda19988.c b/drivers/video/tda19988.c index 191cda3ce7..2448743904 100644 --- a/drivers/video/tda19988.c +++ b/drivers/video/tda19988.c @@ -651,5 +651,5 @@ U_BOOT_DRIVER(tda19988) = { .of_match = tda19988_ids, .ops = &tda19988_ops, .probe = tda19988_probe, - .priv_auto_alloc_size = sizeof(struct tda19988_priv), + .priv_auto = sizeof(struct tda19988_priv), }; diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c index 827ea13d13..08b006b469 100644 --- a/drivers/video/tegra.c +++ b/drivers/video/tegra.c @@ -299,7 +299,7 @@ static int tegra_display_probe(const void *blob, struct tegra_lcd_priv *priv, static int tegra_lcd_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *uc_priv = dev_get_uclass_priv(dev); struct tegra_lcd_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; @@ -336,7 +336,7 @@ static int tegra_lcd_probe(struct udevice *dev) return 0; } -static int tegra_lcd_ofdata_to_platdata(struct udevice *dev) +static int tegra_lcd_of_to_plat(struct udevice *dev) { struct tegra_lcd_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; @@ -393,7 +393,7 @@ static int tegra_lcd_ofdata_to_platdata(struct udevice *dev) static int tegra_lcd_bind(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); int rgb; @@ -423,6 +423,6 @@ U_BOOT_DRIVER(tegra_lcd) = { .ops = &tegra_lcd_ops, .bind = tegra_lcd_bind, .probe = tegra_lcd_probe, - .ofdata_to_platdata = tegra_lcd_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct tegra_lcd_priv), + .of_to_plat = tegra_lcd_of_to_plat, + .priv_auto = sizeof(struct tegra_lcd_priv), }; diff --git a/drivers/video/tegra124/display.c b/drivers/video/tegra124/display.c index 6c27932263..f642b3b10a 100644 --- a/drivers/video/tegra124/display.c +++ b/drivers/video/tegra124/display.c @@ -351,7 +351,7 @@ static int display_init(struct udevice *dev, void *lcdbase, return ret; } - disp_uc_plat = dev_get_uclass_platdata(dp_dev); + disp_uc_plat = dev_get_uclass_plat(dp_dev); debug("Found device '%s', disp_uc_priv=%p\n", dp_dev->name, disp_uc_plat); disp_uc_plat->src_dev = dev; @@ -465,7 +465,7 @@ static int tegra124_lcd_init(struct udevice *dev, void *lcdbase, static int tegra124_lcd_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); ulong start; int ret; @@ -482,7 +482,7 @@ static int tegra124_lcd_probe(struct udevice *dev) static int tegra124_lcd_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); uc_plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT * (1 << VIDEO_BPP16) / 8; diff --git a/drivers/video/tegra124/dp.c b/drivers/video/tegra124/dp.c index 59758eb936..8f5116fe7c 100644 --- a/drivers/video/tegra124/dp.c +++ b/drivers/video/tegra124/dp.c @@ -1566,9 +1566,9 @@ error_enable: return 0; } -static int tegra_dp_ofdata_to_platdata(struct udevice *dev) +static int tegra_dp_of_to_plat(struct udevice *dev) { - struct tegra_dp_plat *plat = dev_get_platdata(dev); + struct tegra_dp_plat *plat = dev_get_plat(dev); plat->base = dev_read_addr(dev); @@ -1594,9 +1594,9 @@ static const struct dm_display_ops dp_tegra_ops = { static int dp_tegra_probe(struct udevice *dev) { - struct tegra_dp_plat *plat = dev_get_platdata(dev); + struct tegra_dp_plat *plat = dev_get_plat(dev); struct tegra_dp_priv *priv = dev_get_priv(dev); - struct display_plat *disp_uc_plat = dev_get_uclass_platdata(dev); + struct display_plat *disp_uc_plat = dev_get_uclass_plat(dev); priv->regs = (struct dpaux_ctlr *)plat->base; priv->enabled = false; @@ -1616,9 +1616,9 @@ U_BOOT_DRIVER(dp_tegra) = { .name = "dpaux_tegra", .id = UCLASS_DISPLAY, .of_match = tegra_dp_ids, - .ofdata_to_platdata = tegra_dp_ofdata_to_platdata, + .of_to_plat = tegra_dp_of_to_plat, .probe = dp_tegra_probe, .ops = &dp_tegra_ops, - .priv_auto_alloc_size = sizeof(struct tegra_dp_priv), - .platdata_auto_alloc_size = sizeof(struct tegra_dp_plat), + .priv_auto = sizeof(struct tegra_dp_priv), + .plat_auto = sizeof(struct tegra_dp_plat), }; diff --git a/drivers/video/tegra124/sor.c b/drivers/video/tegra124/sor.c index 49f33c15b5..95976ee573 100644 --- a/drivers/video/tegra124/sor.c +++ b/drivers/video/tegra124/sor.c @@ -1042,7 +1042,7 @@ static int tegra_sor_set_backlight(struct udevice *dev, int percent) return 0; } -static int tegra_sor_ofdata_to_platdata(struct udevice *dev) +static int tegra_sor_of_to_plat(struct udevice *dev) { struct tegra_dc_sor_data *priv = dev_get_priv(dev); int ret; @@ -1077,7 +1077,7 @@ U_BOOT_DRIVER(sor_tegra) = { .name = "sor_tegra", .id = UCLASS_VIDEO_BRIDGE, .of_match = tegra_sor_ids, - .ofdata_to_platdata = tegra_sor_ofdata_to_platdata, + .of_to_plat = tegra_sor_of_to_plat, .ops = &tegra_sor_ops, - .priv_auto_alloc_size = sizeof(struct tegra_dc_sor_data), + .priv_auto = sizeof(struct tegra_dc_sor_data), }; diff --git a/drivers/video/ti/Kconfig b/drivers/video/ti/Kconfig new file mode 100644 index 0000000000..3081e9e8c0 --- /dev/null +++ b/drivers/video/ti/Kconfig @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> +# +config AM335X_LCD + bool "Enable AM335x video support" + help + Supports video output to an attached LCD panel. diff --git a/drivers/video/ti/Makefile b/drivers/video/ti/Makefile new file mode 100644 index 0000000000..ddddd59216 --- /dev/null +++ b/drivers/video/ti/Makefile @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> +# + +ifdef CONFIG_DM_VIDEO +obj-$(CONFIG_AM335X_LCD) += tilcdc.o tilcdc-panel.o +else +obj-$(CONFIG_AM335X_LCD) += am335x-fb.o +endif diff --git a/drivers/video/am335x-fb.c b/drivers/video/ti/am335x-fb.c index 2707ff59c7..5fa6f794ec 100644 --- a/drivers/video/am335x-fb.c +++ b/drivers/video/ti/am335x-fb.c @@ -12,16 +12,13 @@ * - starts output DMA from gd->fb_base buffer */ #include <common.h> -#include <dm.h> #include <lcd.h> #include <log.h> -#include <video.h> #include <asm/arch/clock.h> #include <asm/arch/hardware.h> #include <asm/arch/omap.h> #include <asm/arch/sys_proto.h> #include <asm/io.h> -#include <asm/utils.h> #include <linux/delay.h> #include <linux/err.h> #include "am335x-fb.h" @@ -110,6 +107,25 @@ struct am335x_lcdhw { unsigned int clkc_reset; /* 0x70 */ }; +DECLARE_GLOBAL_DATA_PTR; + +#if !defined(LCD_CNTL_BASE) +#error "hw-base address of LCD-Controller (LCD_CNTL_BASE) not defined!" +#endif + +/* Macro definitions */ +#define FBSIZE(x) (((x)->hactive * (x)->vactive * (x)->bpp) >> 3) + +#define LCDC_RASTER_TIMING_2_INVMASK(x) ((x) & GENMASK(25, 20)) + +static struct am335x_lcdhw *lcdhw = (void *)LCD_CNTL_BASE; + +int lcd_get_size(int *line_length) +{ + *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; + return *line_length * panel_info.vl_row + 0x20; +} + struct dpll_data { unsigned long rounded_rate; u16 rounded_m; @@ -117,8 +133,6 @@ struct dpll_data { u8 rounded_div; }; -DECLARE_GLOBAL_DATA_PTR; - /** * am335x_dpll_round_rate() - Round a target rate for an OMAP DPLL * @@ -197,25 +211,6 @@ static ulong am335x_fb_set_pixel_clk_rate(struct am335x_lcdhw *regs, ulong rate) return round_rate; } -#if !CONFIG_IS_ENABLED(DM_VIDEO) - -#if !defined(LCD_CNTL_BASE) -#error "hw-base address of LCD-Controller (LCD_CNTL_BASE) not defined!" -#endif - -/* Macro definitions */ -#define FBSIZE(x) (((x)->hactive * (x)->vactive * (x)->bpp) >> 3) - -#define LCDC_RASTER_TIMING_2_INVMASK(x) ((x) & GENMASK(25, 20)) - -static struct am335x_lcdhw *lcdhw = (void *)LCD_CNTL_BASE; - -int lcd_get_size(int *line_length) -{ - *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; - return *line_length * panel_info.vl_row + 0x20; -} - int am335xfb_init(struct am335x_lcdpanel *panel) { u32 raster_ctrl = 0; @@ -320,301 +315,3 @@ int am335xfb_init(struct am335x_lcdpanel *panel) return 0; } - -#else /* CONFIG_DM_VIDEO */ - -#define FBSIZE(t, p) (((t)->hactive.typ * (t)->vactive.typ * (p)->bpp) >> 3) - -enum { - LCD_MAX_WIDTH = 2048, - LCD_MAX_HEIGHT = 2048, - LCD_MAX_LOG2_BPP = VIDEO_BPP32, -}; - -/** - * tilcdc_panel_info: Panel parameters - * - * @ac_bias: AC Bias Pin Frequency - * @ac_bias_intrpt: AC Bias Pin Transitions per Interrupt - * @dma_burst_sz: DMA burst size - * @bpp: Bits per pixel - * @fdd: FIFO DMA Request Delay - * @tft_alt_mode: TFT Alternative Signal Mapping (Only for active) - * @invert_pxl_clk: Invert pixel clock - * @sync_edge: Horizontal and Vertical Sync Edge: 0=rising 1=falling - * @sync_ctrl: Horizontal and Vertical Sync: Control: 0=ignore - * @raster_order: Raster Data Order Select: 1=Most-to-least 0=Least-to-most - * @fifo_th: DMA FIFO threshold - */ -struct tilcdc_panel_info { - u32 ac_bias; - u32 ac_bias_intrpt; - u32 dma_burst_sz; - u32 bpp; - u32 fdd; - bool tft_alt_mode; - bool invert_pxl_clk; - u32 sync_edge; - u32 sync_ctrl; - u32 raster_order; - u32 fifo_th; -}; - -struct am335x_fb_priv { - struct am335x_lcdhw *regs; - struct tilcdc_panel_info panel; - struct display_timing timing; -}; - -static int am335x_fb_remove(struct udevice *dev) -{ - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); - - uc_plat->base -= 0x20; - uc_plat->size += 0x20; - return 0; -} - -static int am335x_fb_probe(struct udevice *dev) -{ - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); - struct video_priv *uc_priv = dev_get_uclass_priv(dev); - struct am335x_fb_priv *priv = dev_get_priv(dev); - struct am335x_lcdhw *regs = priv->regs; - struct tilcdc_panel_info *panel = &priv->panel; - struct display_timing *timing = &priv->timing; - struct cm_dpll *const cmdpll = (struct cm_dpll *)CM_DPLL; - u32 reg; - - /* Before relocation we don't need to do anything */ - if (!(gd->flags & GD_FLG_RELOC)) - return 0; - - am335x_fb_set_pixel_clk_rate(regs, timing->pixelclock.typ); - - /* clock source for LCDC from dispPLL M2 */ - writel(0, &cmdpll->clklcdcpixelclk); - - /* palette default entry */ - memset((void *)uc_plat->base, 0, 0x20); - *(unsigned int *)uc_plat->base = 0x4000; - /* point fb behind palette */ - uc_plat->base += 0x20; - uc_plat->size -= 0x20; - - writel(LCDC_CLKC_ENABLE_CORECLKEN | LCDC_CLKC_ENABLE_LIDDCLKEN | - LCDC_CLKC_ENABLE_DMACLKEN, ®s->clkc_enable); - writel(0, ®s->raster_ctrl); - - reg = readl(®s->ctrl) & LCDC_CTRL_CLK_DIVISOR_MASK; - reg |= LCDC_CTRL_RASTER_MODE; - writel(reg, ®s->ctrl); - - writel(uc_plat->base, ®s->lcddma_fb0_base); - writel(uc_plat->base + FBSIZE(timing, panel), - ®s->lcddma_fb0_ceiling); - writel(uc_plat->base, ®s->lcddma_fb1_base); - writel(uc_plat->base + FBSIZE(timing, panel), - ®s->lcddma_fb1_ceiling); - - reg = LCDC_DMA_CTRL_FIFO_TH(panel->fifo_th); - switch (panel->dma_burst_sz) { - case 1: - reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_1); - break; - case 2: - reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_2); - break; - case 4: - reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_4); - break; - case 8: - reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_8); - break; - case 16: - reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_16); - break; - } - - writel(reg, ®s->lcddma_ctrl); - - writel(LCDC_RASTER_TIMING_0_HORLSB(timing->hactive.typ) | - LCDC_RASTER_TIMING_0_HORMSB(timing->hactive.typ) | - LCDC_RASTER_TIMING_0_HFPLSB(timing->hfront_porch.typ) | - LCDC_RASTER_TIMING_0_HBPLSB(timing->hback_porch.typ) | - LCDC_RASTER_TIMING_0_HSWLSB(timing->hsync_len.typ), - ®s->raster_timing0); - - writel(LCDC_RASTER_TIMING_1_VBP(timing->vback_porch.typ) | - LCDC_RASTER_TIMING_1_VFP(timing->vfront_porch.typ) | - LCDC_RASTER_TIMING_1_VSW(timing->vsync_len.typ) | - LCDC_RASTER_TIMING_1_VERLSB(timing->vactive.typ), - ®s->raster_timing1); - - reg = LCDC_RASTER_TIMING_2_ACB(panel->ac_bias) | - LCDC_RASTER_TIMING_2_ACBI(panel->ac_bias_intrpt) | - LCDC_RASTER_TIMING_2_HSWMSB(timing->hsync_len.typ) | - LCDC_RASTER_TIMING_2_VERMSB(timing->vactive.typ) | - LCDC_RASTER_TIMING_2_HBPMSB(timing->hback_porch.typ) | - LCDC_RASTER_TIMING_2_HFPMSB(timing->hfront_porch.typ); - - if (timing->flags & DISPLAY_FLAGS_VSYNC_LOW) - reg |= LCDC_RASTER_TIMING_2_VSYNC_INVERT; - - if (timing->flags & DISPLAY_FLAGS_HSYNC_LOW) - reg |= LCDC_RASTER_TIMING_2_HSYNC_INVERT; - - if (panel->invert_pxl_clk) - reg |= LCDC_RASTER_TIMING_2_PXCLK_INVERT; - - if (panel->sync_edge) - reg |= LCDC_RASTER_TIMING_2_HSVS_RISEFALL; - - if (panel->sync_ctrl) - reg |= LCDC_RASTER_TIMING_2_HSVS_CONTROL; - - writel(reg, ®s->raster_timing2); - - reg = LCDC_RASTER_CTRL_PALMODE_RAWDATA | LCDC_RASTER_CTRL_TFT_MODE | - LCDC_RASTER_CTRL_ENABLE | LCDC_RASTER_CTRL_REQDLY(panel->fdd); - - if (panel->tft_alt_mode) - reg |= LCDC_RASTER_CTRL_TFT_ALT_ENABLE; - - if (panel->bpp == 24) - reg |= LCDC_RASTER_CTRL_TFT_24BPP_MODE; - else if (panel->bpp == 32) - reg |= LCDC_RASTER_CTRL_TFT_24BPP_MODE | - LCDC_RASTER_CTRL_TFT_24BPP_UNPACK; - - if (panel->raster_order) - reg |= LCDC_RASTER_CTRL_DATA_ORDER; - - writel(reg, ®s->raster_ctrl); - - uc_priv->xsize = timing->hactive.typ; - uc_priv->ysize = timing->vactive.typ; - uc_priv->bpix = log_2_n_round_up(panel->bpp); - return 0; -} - -static int am335x_fb_ofdata_to_platdata(struct udevice *dev) -{ - struct am335x_fb_priv *priv = dev_get_priv(dev); - struct tilcdc_panel_info *panel = &priv->panel; - struct display_timing *timing = &priv->timing; - ofnode node; - int err; - - node = ofnode_by_compatible(ofnode_null(), "ti,am33xx-tilcdc"); - if (!ofnode_valid(node)) { - dev_err(dev, "missing 'ti,am33xx-tilcdc' node\n"); - return -ENXIO; - } - - priv->regs = (struct am335x_lcdhw *)ofnode_get_addr(node); - dev_dbg(dev, "LCD: base address=0x%x\n", (unsigned int)priv->regs); - - err = ofnode_decode_display_timing(dev_ofnode(dev), 0, timing); - if (err) { - dev_err(dev, "failed to get display timing\n"); - return err; - } - - if (timing->pixelclock.typ > (LCDC_FMAX / 2)) { - dev_err(dev, "invalid display clock-frequency: %d Hz\n", - timing->pixelclock.typ); - return -EINVAL; - } - - if (timing->hactive.typ > LCD_MAX_WIDTH) - timing->hactive.typ = LCD_MAX_WIDTH; - - if (timing->vactive.typ > LCD_MAX_HEIGHT) - timing->vactive.typ = LCD_MAX_HEIGHT; - - node = ofnode_find_subnode(dev_ofnode(dev), "panel-info"); - if (!ofnode_valid(node)) { - dev_err(dev, "missing 'panel-info' node\n"); - return -ENXIO; - } - - err |= ofnode_read_u32(node, "ac-bias", &panel->ac_bias); - err |= ofnode_read_u32(node, "ac-bias-intrpt", &panel->ac_bias_intrpt); - err |= ofnode_read_u32(node, "dma-burst-sz", &panel->dma_burst_sz); - err |= ofnode_read_u32(node, "bpp", &panel->bpp); - err |= ofnode_read_u32(node, "fdd", &panel->fdd); - err |= ofnode_read_u32(node, "sync-edge", &panel->sync_edge); - err |= ofnode_read_u32(node, "sync-ctrl", &panel->sync_ctrl); - err |= ofnode_read_u32(node, "raster-order", &panel->raster_order); - err |= ofnode_read_u32(node, "fifo-th", &panel->fifo_th); - if (err) { - dev_err(dev, "failed to get panel info\n"); - return err; - } - - switch (panel->bpp) { - case 16: - case 24: - case 32: - break; - default: - dev_err(dev, "invalid seting, bpp: %d\n", panel->bpp); - return -EINVAL; - } - - switch (panel->dma_burst_sz) { - case 1: - case 2: - case 4: - case 8: - case 16: - break; - default: - dev_err(dev, "invalid setting, dma-burst-sz: %d\n", - panel->dma_burst_sz); - return -EINVAL; - } - - /* optional */ - panel->tft_alt_mode = ofnode_read_bool(node, "tft-alt-mode"); - panel->invert_pxl_clk = ofnode_read_bool(node, "invert-pxl-clk"); - - dev_dbg(dev, "LCD: %dx%d, bpp=%d, clk=%d Hz\n", timing->hactive.typ, - timing->vactive.typ, panel->bpp, timing->pixelclock.typ); - dev_dbg(dev, " hbp=%d, hfp=%d, hsw=%d\n", timing->hback_porch.typ, - timing->hfront_porch.typ, timing->hsync_len.typ); - dev_dbg(dev, " vbp=%d, vfp=%d, vsw=%d\n", timing->vback_porch.typ, - timing->vfront_porch.typ, timing->vsync_len.typ); - - return 0; -} - -static int am335x_fb_bind(struct udevice *dev) -{ - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); - - uc_plat->size = ((LCD_MAX_WIDTH * LCD_MAX_HEIGHT * - (1 << LCD_MAX_LOG2_BPP)) >> 3) + 0x20; - - dev_dbg(dev, "frame buffer size 0x%x\n", uc_plat->size); - return 0; -} - -static const struct udevice_id am335x_fb_ids[] = { - { .compatible = "ti,tilcdc,panel" }, - { } -}; - -U_BOOT_DRIVER(am335x_fb) = { - .name = "am335x_fb", - .id = UCLASS_VIDEO, - .of_match = am335x_fb_ids, - .bind = am335x_fb_bind, - .ofdata_to_platdata = am335x_fb_ofdata_to_platdata, - .probe = am335x_fb_probe, - .remove = am335x_fb_remove, - .priv_auto_alloc_size = sizeof(struct am335x_fb_priv), -}; - -#endif /* CONFIG_DM_VIDEO */ diff --git a/drivers/video/am335x-fb.h b/drivers/video/ti/am335x-fb.h index c9f92bc389..ad9b015e09 100644 --- a/drivers/video/am335x-fb.h +++ b/drivers/video/ti/am335x-fb.h @@ -7,8 +7,6 @@ #ifndef AM335X_FB_H #define AM335X_FB_H -#if !CONFIG_IS_ENABLED(DM_VIDEO) - #define HSVS_CONTROL BIT(25) /* * 0 = lcd_lp and lcd_fp are driven on * opposite edges of pixel clock than @@ -70,6 +68,4 @@ struct am335x_lcdpanel { int am335xfb_init(struct am335x_lcdpanel *panel); -#endif /* CONFIG_DM_VIDEO */ - #endif /* AM335X_FB_H */ diff --git a/drivers/video/ti/tilcdc-panel.c b/drivers/video/ti/tilcdc-panel.c new file mode 100644 index 0000000000..b90dfae4ae --- /dev/null +++ b/drivers/video/ti/tilcdc-panel.c @@ -0,0 +1,172 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * OMAP panel support + * + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#include <common.h> +#include <backlight.h> +#include <clk.h> +#include <display.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <log.h> +#include <panel.h> +#include <asm/gpio.h> +#include <linux/err.h> +#include "tilcdc.h" + +struct tilcdc_panel_priv { + struct tilcdc_panel_info info; + struct display_timing timing; + struct udevice *backlight; + struct gpio_desc enable; +}; + +static int tilcdc_panel_enable_backlight(struct udevice *dev) +{ + struct tilcdc_panel_priv *priv = dev_get_priv(dev); + + if (dm_gpio_is_valid(&priv->enable)) + dm_gpio_set_value(&priv->enable, 1); + + if (priv->backlight) + return backlight_enable(priv->backlight); + + return 0; +} + +static int tilcdc_panel_set_backlight(struct udevice *dev, int percent) +{ + struct tilcdc_panel_priv *priv = dev_get_priv(dev); + + if (dm_gpio_is_valid(&priv->enable)) + dm_gpio_set_value(&priv->enable, 1); + + if (priv->backlight) + return backlight_set_brightness(priv->backlight, percent); + + return 0; +} + +int tilcdc_panel_get_display_info(struct udevice *dev, + struct tilcdc_panel_info *info) +{ + struct tilcdc_panel_priv *priv = dev_get_priv(dev); + + memcpy(info, &priv->info, sizeof(*info)); + return 0; +} + +static int tilcdc_panel_get_display_timing(struct udevice *dev, + struct display_timing *timing) +{ + struct tilcdc_panel_priv *priv = dev_get_priv(dev); + + memcpy(timing, &priv->timing, sizeof(*timing)); + return 0; +} + +static int tilcdc_panel_remove(struct udevice *dev) +{ + struct tilcdc_panel_priv *priv = dev_get_priv(dev); + + if (dm_gpio_is_valid(&priv->enable)) + dm_gpio_free(dev, &priv->enable); + + return 0; +} + +static int tilcdc_panel_probe(struct udevice *dev) +{ + struct tilcdc_panel_priv *priv = dev_get_priv(dev); + int err; + + err = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev, + "backlight", &priv->backlight); + if (err) + dev_warn(dev, "failed to get backlight\n"); + + err = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable, + GPIOD_IS_OUT); + if (err) { + dev_warn(dev, "failed to get enable GPIO\n"); + if (err != -ENOENT) + return err; + } + + return 0; +} + +static int tilcdc_panel_of_to_plat(struct udevice *dev) +{ + struct tilcdc_panel_priv *priv = dev_get_priv(dev); + ofnode node; + int err; + + err = ofnode_decode_display_timing(dev_ofnode(dev), 0, &priv->timing); + if (err) { + dev_err(dev, "failed to get display timing\n"); + return err; + } + + node = dev_read_subnode(dev, "panel-info"); + if (!ofnode_valid(node)) { + dev_err(dev, "missing 'panel-info' node\n"); + return -ENXIO; + } + + err |= ofnode_read_u32(node, "ac-bias", &priv->info.ac_bias); + err |= ofnode_read_u32(node, "ac-bias-intrpt", + &priv->info.ac_bias_intrpt); + err |= ofnode_read_u32(node, "dma-burst-sz", &priv->info.dma_burst_sz); + err |= ofnode_read_u32(node, "bpp", &priv->info.bpp); + err |= ofnode_read_u32(node, "fdd", &priv->info.fdd); + err |= ofnode_read_u32(node, "sync-edge", &priv->info.sync_edge); + err |= ofnode_read_u32(node, "sync-ctrl", &priv->info.sync_ctrl); + err |= ofnode_read_u32(node, "raster-order", &priv->info.raster_order); + err |= ofnode_read_u32(node, "fifo-th", &priv->info.fifo_th); + if (err) { + dev_err(dev, "failed to get panel info\n"); + return err; + } + + /* optional */ + priv->info.tft_alt_mode = ofnode_read_bool(node, "tft-alt-mode"); + priv->info.invert_pxl_clk = ofnode_read_bool(node, "invert-pxl-clk"); + + dev_dbg(dev, "LCD: %dx%d, bpp=%d, clk=%d Hz\n", + priv->timing.hactive.typ, priv->timing.vactive.typ, + priv->info.bpp, priv->timing.pixelclock.typ); + dev_dbg(dev, " hbp=%d, hfp=%d, hsw=%d\n", + priv->timing.hback_porch.typ, priv->timing.hfront_porch.typ, + priv->timing.hsync_len.typ); + dev_dbg(dev, " vbp=%d, vfp=%d, vsw=%d\n", + priv->timing.vback_porch.typ, priv->timing.vfront_porch.typ, + priv->timing.vsync_len.typ); + + return 0; +} + +static const struct panel_ops tilcdc_panel_ops = { + .enable_backlight = tilcdc_panel_enable_backlight, + .set_backlight = tilcdc_panel_set_backlight, + .get_display_timing = tilcdc_panel_get_display_timing, +}; + +static const struct udevice_id tilcdc_panel_ids[] = { + {.compatible = "ti,tilcdc,panel"}, + {} +}; + +U_BOOT_DRIVER(tilcdc_panel) = { + .name = "tilcdc_panel", + .id = UCLASS_PANEL, + .of_match = tilcdc_panel_ids, + .ops = &tilcdc_panel_ops, + .ofdata_to_platdata = tilcdc_panel_of_to_plat, + .probe = tilcdc_panel_probe, + .remove = tilcdc_panel_remove, + .priv_auto = sizeof(struct tilcdc_panel_priv), +}; diff --git a/drivers/video/ti/tilcdc-panel.h b/drivers/video/ti/tilcdc-panel.h new file mode 100644 index 0000000000..6bcfbf8a8b --- /dev/null +++ b/drivers/video/ti/tilcdc-panel.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#ifndef _TILCDC_PANEL_H +#define _TILCDC_PANEL_H + +#include "tilcdc.h" + +int tilcdc_panel_get_display_info(struct udevice *dev, + struct tilcdc_panel_info *info); + +#endif /* _TILCDC_PANEL_H */ diff --git a/drivers/video/ti/tilcdc.c b/drivers/video/ti/tilcdc.c new file mode 100644 index 0000000000..d13cc11801 --- /dev/null +++ b/drivers/video/ti/tilcdc.c @@ -0,0 +1,425 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#include <common.h> +#include <clk.h> +#include <dm.h> +#include <dm/device_compat.h> +#include <lcd.h> +#include <log.h> +#include <panel.h> +#include <video.h> +#include <asm/io.h> +#include <asm/utils.h> +#include "tilcdc.h" +#include "tilcdc-panel.h" + +#define LCDC_FMAX 200000000 + +/* LCD Control Register */ +#define LCDC_CTRL_CLK_DIVISOR_MASK GENMASK(15, 8) +#define LCDC_CTRL_RASTER_MODE BIT(0) +#define LCDC_CTRL_CLK_DIVISOR(x) (((x) & GENMASK(7, 0)) << 8) +/* LCD Clock Enable Register */ +#define LCDC_CLKC_ENABLE_CORECLKEN BIT(0) +#define LCDC_CLKC_ENABLE_LIDDCLKEN BIT(1) +#define LCDC_CLKC_ENABLE_DMACLKEN BIT(2) +/* LCD DMA Control Register */ +#define LCDC_DMA_CTRL_BURST_SIZE(x) (((x) & GENMASK(2, 0)) << 4) +#define LCDC_DMA_CTRL_BURST_1 0x0 +#define LCDC_DMA_CTRL_BURST_2 0x1 +#define LCDC_DMA_CTRL_BURST_4 0x2 +#define LCDC_DMA_CTRL_BURST_8 0x3 +#define LCDC_DMA_CTRL_BURST_16 0x4 +#define LCDC_DMA_CTRL_FIFO_TH(x) (((x) & GENMASK(2, 0)) << 8) +/* LCD Timing_0 Register */ +#define LCDC_RASTER_TIMING_0_HORMSB(x) ((((x) - 1) & BIT(10)) >> 7) +#define LCDC_RASTER_TIMING_0_HORLSB(x) (((((x) >> 4) - 1) & GENMASK(5, 0)) << 4) +#define LCDC_RASTER_TIMING_0_HSWLSB(x) ((((x) - 1) & GENMASK(5, 0)) << 10) +#define LCDC_RASTER_TIMING_0_HFPLSB(x) ((((x) - 1) & GENMASK(7, 0)) << 16) +#define LCDC_RASTER_TIMING_0_HBPLSB(x) ((((x) - 1) & GENMASK(7, 0)) << 24) +/* LCD Timing_1 Register */ +#define LCDC_RASTER_TIMING_1_VERLSB(x) (((x) - 1) & GENMASK(9, 0)) +#define LCDC_RASTER_TIMING_1_VSW(x) ((((x) - 1) & GENMASK(5, 0)) << 10) +#define LCDC_RASTER_TIMING_1_VFP(x) (((x) & GENMASK(7, 0)) << 16) +#define LCDC_RASTER_TIMING_1_VBP(x) (((x) & GENMASK(7, 0)) << 24) +/* LCD Timing_2 Register */ +#define LCDC_RASTER_TIMING_2_HFPMSB(x) ((((x) - 1) & GENMASK(9, 8)) >> 8) +#define LCDC_RASTER_TIMING_2_HBPMSB(x) ((((x) - 1) & GENMASK(9, 8)) >> 4) +#define LCDC_RASTER_TIMING_2_ACB(x) (((x) & GENMASK(7, 0)) << 8) +#define LCDC_RASTER_TIMING_2_ACBI(x) (((x) & GENMASK(3, 0)) << 16) +#define LCDC_RASTER_TIMING_2_VSYNC_INVERT BIT(20) +#define LCDC_RASTER_TIMING_2_HSYNC_INVERT BIT(21) +#define LCDC_RASTER_TIMING_2_PXCLK_INVERT BIT(22) +#define LCDC_RASTER_TIMING_2_DE_INVERT BIT(23) +#define LCDC_RASTER_TIMING_2_HSVS_RISEFALL BIT(24) +#define LCDC_RASTER_TIMING_2_HSVS_CONTROL BIT(25) +#define LCDC_RASTER_TIMING_2_VERMSB(x) ((((x) - 1) & BIT(10)) << 16) +#define LCDC_RASTER_TIMING_2_HSWMSB(x) ((((x) - 1) & GENMASK(9, 6)) << 21) +/* LCD Raster Ctrl Register */ +#define LCDC_RASTER_CTRL_ENABLE BIT(0) +#define LCDC_RASTER_CTRL_TFT_MODE BIT(7) +#define LCDC_RASTER_CTRL_DATA_ORDER BIT(8) +#define LCDC_RASTER_CTRL_REQDLY(x) (((x) & GENMASK(7, 0)) << 12) +#define LCDC_RASTER_CTRL_PALMODE_RAWDATA (0x02 << 20) +#define LCDC_RASTER_CTRL_TFT_ALT_ENABLE BIT(23) +#define LCDC_RASTER_CTRL_TFT_24BPP_MODE BIT(25) +#define LCDC_RASTER_CTRL_TFT_24BPP_UNPACK BIT(26) + +enum { + LCDC_MAX_WIDTH = 2048, + LCDC_MAX_HEIGHT = 2048, + LCDC_MAX_LOG2_BPP = VIDEO_BPP32, +}; + +struct tilcdc_regs { + u32 pid; + u32 ctrl; + u32 gap0; + u32 lidd_ctrl; + u32 lidd_cs0_conf; + u32 lidd_cs0_addr; + u32 lidd_cs0_data; + u32 lidd_cs1_conf; + u32 lidd_cs1_addr; + u32 lidd_cs1_data; + u32 raster_ctrl; + u32 raster_timing0; + u32 raster_timing1; + u32 raster_timing2; + u32 raster_subpanel; + u32 raster_subpanel2; + u32 lcddma_ctrl; + u32 lcddma_fb0_base; + u32 lcddma_fb0_ceiling; + u32 lcddma_fb1_base; + u32 lcddma_fb1_ceiling; + u32 sysconfig; + u32 irqstatus_raw; + u32 irqstatus; + u32 irqenable_set; + u32 irqenable_clear; + u32 gap1; + u32 clkc_enable; + u32 clkc_reset; +}; + +struct tilcdc_priv { + struct tilcdc_regs *regs; + struct clk gclk; + struct clk dpll_m2_clk; +}; + +DECLARE_GLOBAL_DATA_PTR; + +static ulong tilcdc_set_pixel_clk_rate(struct udevice *dev, ulong rate) +{ + struct tilcdc_priv *priv = dev_get_priv(dev); + struct tilcdc_regs *regs = priv->regs; + ulong mult_rate, mult_round_rate, best_err, err; + u32 v; + int div, i; + + best_err = rate; + div = 0; + for (i = 2; i <= 255; i++) { + mult_rate = rate * i; + mult_round_rate = clk_round_rate(&priv->gclk, mult_rate); + if (IS_ERR_VALUE(mult_round_rate)) + return mult_round_rate; + + err = mult_rate - mult_round_rate; + if (err < best_err) { + best_err = err; + div = i; + if (err == 0) + break; + } + } + + if (div == 0) { + dev_err(dev, "failed to find a divisor\n"); + return -EFAULT; + } + + mult_rate = clk_set_rate(&priv->gclk, rate * div); + v = readl(®s->ctrl) & ~LCDC_CTRL_CLK_DIVISOR_MASK; + v |= LCDC_CTRL_CLK_DIVISOR(div); + writel(v, ®s->ctrl); + rate = mult_rate / div; + dev_dbg(dev, "rate=%ld, div=%d, err=%ld\n", rate, div, err); + return rate; +} + +static int tilcdc_remove(struct udevice *dev) +{ + struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct tilcdc_priv *priv = dev_get_priv(dev); + + uc_plat->base -= 0x20; + uc_plat->size += 0x20; + clk_release_all(&priv->gclk, 1); + clk_release_all(&priv->dpll_m2_clk, 1); + return 0; +} + +static int tilcdc_probe(struct udevice *dev) +{ + struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_priv *uc_priv = dev_get_uclass_priv(dev); + struct tilcdc_priv *priv = dev_get_priv(dev); + struct tilcdc_regs *regs = priv->regs; + struct udevice *panel, *clk_dev; + struct tilcdc_panel_info info; + struct display_timing timing; + ulong rate; + u32 reg; + int err; + + /* Before relocation we don't need to do anything */ + if (!(gd->flags & GD_FLG_RELOC)) + return 0; + + err = uclass_get_device(UCLASS_PANEL, 0, &panel); + if (err) { + dev_err(dev, "failed to get panel\n"); + return err; + } + + err = panel_get_display_timing(panel, &timing); + if (err) { + dev_err(dev, "failed to get display timing\n"); + return err; + } + + if (timing.pixelclock.typ > (LCDC_FMAX / 2)) { + dev_err(dev, "invalid display clock-frequency: %d Hz\n", + timing.pixelclock.typ); + return -EINVAL; + } + + if (timing.hactive.typ > LCDC_MAX_WIDTH) + timing.hactive.typ = LCDC_MAX_WIDTH; + + if (timing.vactive.typ > LCDC_MAX_HEIGHT) + timing.vactive.typ = LCDC_MAX_HEIGHT; + + err = tilcdc_panel_get_display_info(panel, &info); + if (err) { + dev_err(dev, "failed to get panel info\n"); + return err; + } + + switch (info.bpp) { + case 16: + case 24: + case 32: + break; + default: + dev_err(dev, "invalid seting, bpp: %d\n", info.bpp); + return -EINVAL; + } + + switch (info.dma_burst_sz) { + case 1: + case 2: + case 4: + case 8: + case 16: + break; + default: + dev_err(dev, "invalid setting, dma-burst-sz: %d\n", + info.dma_burst_sz); + return -EINVAL; + } + + err = uclass_get_device_by_name(UCLASS_CLK, "lcd_gclk@534", &clk_dev); + if (err) { + dev_err(dev, "failed to get lcd_gclk device\n"); + return err; + } + + err = clk_request(clk_dev, &priv->gclk); + if (err) { + dev_err(dev, "failed to get %s clock\n", clk_dev->name); + return err; + } + + rate = tilcdc_set_pixel_clk_rate(dev, timing.pixelclock.typ); + if (IS_ERR_VALUE(rate)) { + dev_err(dev, "failed to set pixel clock rate\n"); + return rate; + } + + err = uclass_get_device_by_name(UCLASS_CLK, "dpll_disp_m2_ck@4a4", + &clk_dev); + if (err) { + dev_err(dev, "failed to get dpll_disp_m2 clock device\n"); + return err; + } + + err = clk_request(clk_dev, &priv->dpll_m2_clk); + if (err) { + dev_err(dev, "failed to get %s clock\n", clk_dev->name); + return err; + } + + err = clk_set_parent(&priv->gclk, &priv->dpll_m2_clk); + if (err) { + dev_err(dev, "failed to set %s clock as %s's parent\n", + priv->dpll_m2_clk.dev->name, priv->gclk.dev->name); + return err; + } + + /* palette default entry */ + memset((void *)uc_plat->base, 0, 0x20); + *(unsigned int *)uc_plat->base = 0x4000; + /* point fb behind palette */ + uc_plat->base += 0x20; + uc_plat->size -= 0x20; + + writel(LCDC_CLKC_ENABLE_CORECLKEN | LCDC_CLKC_ENABLE_LIDDCLKEN | + LCDC_CLKC_ENABLE_DMACLKEN, ®s->clkc_enable); + writel(0, ®s->raster_ctrl); + + reg = readl(®s->ctrl) & LCDC_CTRL_CLK_DIVISOR_MASK; + reg |= LCDC_CTRL_RASTER_MODE; + writel(reg, ®s->ctrl); + + reg = (timing.hactive.typ * timing.vactive.typ * info.bpp) >> 3; + reg += uc_plat->base; + writel(uc_plat->base, ®s->lcddma_fb0_base); + writel(reg, ®s->lcddma_fb0_ceiling); + writel(uc_plat->base, ®s->lcddma_fb1_base); + writel(reg, ®s->lcddma_fb1_ceiling); + + reg = LCDC_DMA_CTRL_FIFO_TH(info.fifo_th); + switch (info.dma_burst_sz) { + case 1: + reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_1); + break; + case 2: + reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_2); + break; + case 4: + reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_4); + break; + case 8: + reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_8); + break; + case 16: + reg |= LCDC_DMA_CTRL_BURST_SIZE(LCDC_DMA_CTRL_BURST_16); + break; + } + + writel(reg, ®s->lcddma_ctrl); + + writel(LCDC_RASTER_TIMING_0_HORLSB(timing.hactive.typ) | + LCDC_RASTER_TIMING_0_HORMSB(timing.hactive.typ) | + LCDC_RASTER_TIMING_0_HFPLSB(timing.hfront_porch.typ) | + LCDC_RASTER_TIMING_0_HBPLSB(timing.hback_porch.typ) | + LCDC_RASTER_TIMING_0_HSWLSB(timing.hsync_len.typ), + ®s->raster_timing0); + + writel(LCDC_RASTER_TIMING_1_VBP(timing.vback_porch.typ) | + LCDC_RASTER_TIMING_1_VFP(timing.vfront_porch.typ) | + LCDC_RASTER_TIMING_1_VSW(timing.vsync_len.typ) | + LCDC_RASTER_TIMING_1_VERLSB(timing.vactive.typ), + ®s->raster_timing1); + + reg = LCDC_RASTER_TIMING_2_ACB(info.ac_bias) | + LCDC_RASTER_TIMING_2_ACBI(info.ac_bias_intrpt) | + LCDC_RASTER_TIMING_2_HSWMSB(timing.hsync_len.typ) | + LCDC_RASTER_TIMING_2_VERMSB(timing.vactive.typ) | + LCDC_RASTER_TIMING_2_HBPMSB(timing.hback_porch.typ) | + LCDC_RASTER_TIMING_2_HFPMSB(timing.hfront_porch.typ); + + if (timing.flags & DISPLAY_FLAGS_VSYNC_LOW) + reg |= LCDC_RASTER_TIMING_2_VSYNC_INVERT; + + if (timing.flags & DISPLAY_FLAGS_HSYNC_LOW) + reg |= LCDC_RASTER_TIMING_2_HSYNC_INVERT; + + if (info.invert_pxl_clk) + reg |= LCDC_RASTER_TIMING_2_PXCLK_INVERT; + + if (info.sync_edge) + reg |= LCDC_RASTER_TIMING_2_HSVS_RISEFALL; + + if (info.sync_ctrl) + reg |= LCDC_RASTER_TIMING_2_HSVS_CONTROL; + + writel(reg, ®s->raster_timing2); + + reg = LCDC_RASTER_CTRL_PALMODE_RAWDATA | LCDC_RASTER_CTRL_TFT_MODE | + LCDC_RASTER_CTRL_ENABLE | LCDC_RASTER_CTRL_REQDLY(info.fdd); + + if (info.tft_alt_mode) + reg |= LCDC_RASTER_CTRL_TFT_ALT_ENABLE; + + if (info.bpp == 24) + reg |= LCDC_RASTER_CTRL_TFT_24BPP_MODE; + else if (info.bpp == 32) + reg |= LCDC_RASTER_CTRL_TFT_24BPP_MODE | + LCDC_RASTER_CTRL_TFT_24BPP_UNPACK; + + if (info.raster_order) + reg |= LCDC_RASTER_CTRL_DATA_ORDER; + + writel(reg, ®s->raster_ctrl); + + uc_priv->xsize = timing.hactive.typ; + uc_priv->ysize = timing.vactive.typ; + uc_priv->bpix = log_2_n_round_up(info.bpp); + + err = panel_enable_backlight(panel); + if (err) { + dev_err(dev, "failed to enable panel backlight\n"); + return err; + } + + return 0; +} + +static int tilcdc_of_to_plat(struct udevice *dev) +{ + struct tilcdc_priv *priv = dev_get_priv(dev); + + priv->regs = (struct tilcdc_regs *)dev_read_addr(dev); + if ((fdt_addr_t)priv->regs == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get base address\n"); + return -EINVAL; + } + + dev_dbg(dev, "LCD: base address=0x%x\n", (unsigned int)priv->regs); + return 0; +} + +static int tilcdc_bind(struct udevice *dev) +{ + struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + + uc_plat->size = ((LCDC_MAX_WIDTH * LCDC_MAX_HEIGHT * + (1 << LCDC_MAX_LOG2_BPP)) >> 3) + 0x20; + + dev_dbg(dev, "frame buffer size 0x%x\n", uc_plat->size); + return 0; +} + +static const struct udevice_id tilcdc_ids[] = { + {.compatible = "ti,am33xx-tilcdc"}, + {} +}; + +U_BOOT_DRIVER(tilcdc) = { + .name = "tilcdc", + .id = UCLASS_VIDEO, + .of_match = tilcdc_ids, + .bind = tilcdc_bind, + .ofdata_to_platdata = tilcdc_of_to_plat, + .probe = tilcdc_probe, + .remove = tilcdc_remove, + .priv_auto = sizeof(struct tilcdc_priv) +}; diff --git a/drivers/video/ti/tilcdc.h b/drivers/video/ti/tilcdc.h new file mode 100644 index 0000000000..2645921df6 --- /dev/null +++ b/drivers/video/ti/tilcdc.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it> + */ + +#ifndef _TILCDC_H +#define _TILCDC_H + +/** + * tilcdc_panel_info: Panel parameters + * + * @ac_bias: AC Bias Pin Frequency + * @ac_bias_intrpt: AC Bias Pin Transitions per Interrupt + * @dma_burst_sz: DMA burst size + * @bpp: Bits per pixel + * @fdd: FIFO DMA Request Delay + * @tft_alt_mode: TFT Alternative Signal Mapping (Only for active) + * @invert_pxl_clk: Invert pixel clock + * @sync_edge: Horizontal and Vertical Sync Edge: 0=rising 1=falling + * @sync_ctrl: Horizontal and Vertical Sync: Control: 0=ignore + * @raster_order: Raster Data Order Select: 1=Most-to-least 0=Least-to-most + * @fifo_th: DMA FIFO threshold + */ +struct tilcdc_panel_info { + u32 ac_bias; + u32 ac_bias_intrpt; + u32 dma_burst_sz; + u32 bpp; + u32 fdd; + bool tft_alt_mode; + bool invert_pxl_clk; + u32 sync_edge; + u32 sync_ctrl; + u32 raster_order; + u32 fifo_th; +}; + +#endif /* _TILCDC_H */ diff --git a/drivers/video/vesa.c b/drivers/video/vesa.c index 9656326bdb..869e546973 100644 --- a/drivers/video/vesa.c +++ b/drivers/video/vesa.c @@ -13,7 +13,7 @@ static int vesa_video_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); ulong fbbase; int ret; @@ -31,7 +31,7 @@ static int vesa_video_probe(struct udevice *dev) static int vesa_video_bind(struct udevice *dev) { - struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); /* Set the maximum supported resolution */ uc_plat->size = 2560 * 1600 * 4; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 3a07f36ce2..81b65f5aae 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -89,9 +89,7 @@ static int vidconsole_back(struct udevice *dev) if (priv->ycur < 0) priv->ycur = 0; } - video_sync(dev->parent, false); - - return 0; + return video_sync(dev->parent, false); } /* Move to a newline, scrolling the display if necessary */ @@ -101,7 +99,7 @@ static void vidconsole_newline(struct udevice *dev) struct udevice *vid_dev = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); const int rows = CONFIG_CONSOLE_SCROLL_LINES; - int i; + int i, ret; priv->xcur_frac = priv->xstart_frac; priv->ycur += priv->y_charsize; @@ -116,7 +114,12 @@ static void vidconsole_newline(struct udevice *dev) } priv->last_ch = 0; - video_sync(dev->parent, false); + ret = video_sync(dev->parent, false); + if (ret) { +#ifdef DEBUG + console_puts_select_stderr(true, "[vc err: video_sync]"); +#endif + } } static const struct vid_rgb colors[VID_COLOR_COUNT] = { @@ -348,8 +351,15 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) parsenum(priv->escape_buf + 1, &mode); if (mode == 2) { + int ret; + video_clear(dev->parent); - video_sync(dev->parent, false); + ret = video_sync(dev->parent, false); + if (ret) { +#ifdef DEBUG + console_puts_select_stderr(true, "[vc err: video_sync]"); +#endif + } priv->ycur = 0; priv->xcur_frac = priv->xstart_frac; } else { @@ -565,7 +575,12 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch) console_puts_select_stderr(true, "[vc err: putc]"); #endif } - video_sync(dev->parent, false); + ret = video_sync(dev->parent, false); + if (ret) { +#ifdef DEBUG + console_puts_select_stderr(true, "[vc err: video_sync]"); +#endif + } } static void vidconsole_puts(struct stdio_dev *sdev, const char *s) @@ -582,7 +597,12 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s) console_puts_select_stderr(true, str); #endif } - video_sync(dev->parent, false); + ret = video_sync(dev->parent, false); + if (ret) { +#ifdef DEBUG + console_puts_select_stderr(true, "[vc err: video_sync]"); +#endif + } } /* Set up the number of rows and colours (rotated drivers override this) */ @@ -606,9 +626,9 @@ static int vidconsole_post_probe(struct udevice *dev) if (!priv->tab_width_frac) priv->tab_width_frac = VID_TO_POS(priv->x_charsize) * 8; - if (dev->seq) { + if (dev_seq(dev)) { snprintf(sdev->name, sizeof(sdev->name), "vidconsole%d", - dev->seq); + dev_seq(dev)); } else { strcpy(sdev->name, "vidconsole"); } @@ -626,7 +646,7 @@ UCLASS_DRIVER(vidconsole) = { .name = "vidconsole0", .pre_probe = vidconsole_pre_probe, .post_probe = vidconsole_post_probe, - .per_device_auto_alloc_size = sizeof(struct vidconsole_priv), + .per_device_auto = sizeof(struct vidconsole_priv), }; #ifdef CONFIG_VIDEO_COPY @@ -691,9 +711,7 @@ static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc, for (s = argv[1]; *s; s++) vidconsole_put_char(dev, *s); - video_sync(dev->parent, false); - - return 0; + return video_sync(dev->parent, false); } U_BOOT_CMD( diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 650891e49d..a1d527529f 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -15,6 +15,7 @@ #include <video_console.h> #include <asm/cache.h> #include <dm/lists.h> +#include <dm/device_compat.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> #ifdef CONFIG_SANDBOX @@ -25,7 +26,7 @@ * Theory of operation: * * Before relocation each device is bound. The driver for each device must - * set the @align and @size values in struct video_uc_platdata. This + * set the @align and @size values in struct video_uc_plat. This * information represents the requires size and alignment of the frame buffer * for the device. The values can be an over-estimate but cannot be too * small. The actual values will be suppled (in the same manner) by the bind() @@ -68,7 +69,7 @@ void video_set_flush_dcache(struct udevice *dev, bool flush) static ulong alloc_fb(struct udevice *dev, ulong *addrp) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); ulong base, align, size; if (!plat->size) @@ -142,7 +143,7 @@ int video_clear(struct udevice *dev) if (ret) return ret; - return 0; + return video_sync(dev, false); } void video_set_default_colors(struct udevice *dev, bool invert) @@ -172,8 +173,17 @@ void video_set_default_colors(struct udevice *dev, bool invert) } /* Flush video activity to the caches */ -void video_sync(struct udevice *vid, bool force) +int video_sync(struct udevice *vid, bool force) { + struct video_ops *ops = video_get_ops(vid); + int ret; + + if (ops && ops->video_sync) { + ret = ops->video_sync(vid); + if (ret) + return ret; + } + /* * flush_dcache_range() is declared in common.h but it seems that some * architectures do not actually implement it. Is there a way to find @@ -196,17 +206,22 @@ void video_sync(struct udevice *vid, bool force) last_sync = get_timer(0); } #endif + return 0; } void video_sync_all(void) { struct udevice *dev; + int ret; for (uclass_find_first_device(UCLASS_VIDEO, &dev); dev; uclass_find_next_device(&dev)) { - if (device_active(dev)) - video_sync(dev, true); + if (device_active(dev)) { + ret = video_sync(dev, true); + if (ret) + dev_dbg(dev, "Video sync failed\n"); + } } } @@ -301,7 +316,7 @@ static int video_pre_remove(struct udevice *dev) /* Set up the display ready for use */ static int video_post_probe(struct udevice *dev) { - struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_uc_plat *plat = dev_get_uclass_plat(dev); struct video_priv *priv = dev_get_uclass_priv(dev); char name[30], drv[15], *str; const char *drv_name = drv; @@ -378,7 +393,7 @@ static int video_post_bind(struct udevice *dev) return 0; /* Set up the video pointer, if this is the first device */ - uc_priv = dev->uclass->priv; + uc_priv = uclass_get_priv(dev->uclass); if (!uc_priv->video_ptr) uc_priv->video_ptr = gd->video_top; @@ -408,7 +423,7 @@ UCLASS_DRIVER(video) = { .pre_probe = video_pre_probe, .post_probe = video_post_probe, .pre_remove = video_pre_remove, - .priv_auto_alloc_size = sizeof(struct video_uc_priv), - .per_device_auto_alloc_size = sizeof(struct video_priv), - .per_device_platdata_auto_alloc_size = sizeof(struct video_uc_platdata), + .priv_auto = sizeof(struct video_uc_priv), + .per_device_auto = sizeof(struct video_priv), + .per_device_plat_auto = sizeof(struct video_uc_plat), }; diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index 5a4d12c68d..66de22318f 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -379,8 +379,5 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, if (ret) return log_ret(ret); - video_sync(dev, false); - - return 0; + return video_sync(dev, false); } - diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index 2636cbedfe..cf2cfaef2c 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -240,7 +240,7 @@ static int virtio_uclass_post_probe(struct udevice *udev) } snprintf(dev_name, sizeof(dev_name), "%s#%d", - virtio_drv_name[uc_priv->device], udev->seq); + virtio_drv_name[uc_priv->device], dev_seq(udev)); str = strdup(dev_name); if (!str) return -ENOMEM; @@ -369,5 +369,5 @@ UCLASS_DRIVER(virtio) = { .child_post_bind = virtio_uclass_child_post_bind, .child_pre_probe = virtio_uclass_child_pre_probe, .child_post_probe = virtio_uclass_child_post_probe, - .per_device_auto_alloc_size = sizeof(struct virtio_dev_priv), + .per_device_auto = sizeof(struct virtio_dev_priv), }; diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c index 1799f5c5eb..3ff74f4a97 100644 --- a/drivers/virtio/virtio_blk.c +++ b/drivers/virtio/virtio_blk.c @@ -72,7 +72,7 @@ static ulong virtio_blk_write(struct udevice *dev, lbaint_t start, static int virtio_blk_bind(struct udevice *dev) { struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(dev->parent); - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); int devnum; desc->if_type = IF_TYPE_VIRTIO; @@ -106,7 +106,7 @@ static int virtio_blk_bind(struct udevice *dev) static int virtio_blk_probe(struct udevice *dev) { struct virtio_blk_priv *priv = dev_get_priv(dev); - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); u64 cap; int ret; @@ -134,6 +134,6 @@ U_BOOT_DRIVER(virtio_blk) = { .bind = virtio_blk_bind, .probe = virtio_blk_probe, .remove = virtio_reset, - .priv_auto_alloc_size = sizeof(struct virtio_blk_priv), + .priv_auto = sizeof(struct virtio_blk_priv), .flags = DM_FLAG_ACTIVE_DMA, }; diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index b951ea3257..78c15c821b 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -334,7 +334,7 @@ static int virtio_mmio_notify(struct udevice *udev, struct virtqueue *vq) return 0; } -static int virtio_mmio_ofdata_to_platdata(struct udevice *udev) +static int virtio_mmio_of_to_plat(struct udevice *udev) { struct virtio_mmio_priv *priv = dev_get_priv(udev); @@ -411,6 +411,6 @@ U_BOOT_DRIVER(virtio_mmio) = { .of_match = virtio_mmio_ids, .ops = &virtio_mmio_ops, .probe = virtio_mmio_probe, - .ofdata_to_platdata = virtio_mmio_ofdata_to_platdata, - .priv_auto_alloc_size = sizeof(struct virtio_mmio_priv), + .of_to_plat = virtio_mmio_of_to_plat, + .priv_auto = sizeof(struct virtio_mmio_priv), }; diff --git a/drivers/virtio/virtio_net.c b/drivers/virtio/virtio_net.c index 0dbbd78023..1794f73a8d 100644 --- a/drivers/virtio/virtio_net.c +++ b/drivers/virtio/virtio_net.c @@ -145,7 +145,7 @@ static void virtio_net_stop(struct udevice *dev) static int virtio_net_write_hwaddr(struct udevice *dev) { struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(dev->parent); - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); int i; /* @@ -166,7 +166,7 @@ static int virtio_net_write_hwaddr(struct udevice *dev) static int virtio_net_read_rom_hwaddr(struct udevice *dev) { - struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_pdata *pdata = dev_get_plat(dev); if (!pdata) return -ENOSYS; @@ -233,7 +233,7 @@ U_BOOT_DRIVER(virtio_net) = { .probe = virtio_net_probe, .remove = virtio_reset, .ops = &virtio_net_ops, - .priv_auto_alloc_size = sizeof(struct virtio_net_priv), - .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .priv_auto = sizeof(struct virtio_net_priv), + .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ACTIVE_DMA, }; diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c index fa7f2429f1..03fa5cb608 100644 --- a/drivers/virtio/virtio_pci_legacy.c +++ b/drivers/virtio/virtio_pci_legacy.c @@ -292,7 +292,7 @@ static int virtio_pci_bind(struct udevice *udev) static int virtio_pci_probe(struct udevice *udev) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(udev); + struct pci_child_plat *pplat = dev_get_parent_plat(udev); struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(udev); struct virtio_pci_priv *priv = dev_get_priv(udev); u16 subvendor, subdevice; @@ -350,7 +350,7 @@ U_BOOT_DRIVER(virtio_pci_legacy) = { .ops = &virtio_pci_ops, .bind = virtio_pci_bind, .probe = virtio_pci_probe, - .priv_auto_alloc_size = sizeof(struct virtio_pci_priv), + .priv_auto = sizeof(struct virtio_pci_priv), }; static struct pci_device_id virtio_pci_supported[] = { diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 2e5bbade00..dfbbf8a625 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -456,7 +456,7 @@ static int virtio_pci_bind(struct udevice *udev) static int virtio_pci_probe(struct udevice *udev) { - struct pci_child_platdata *pplat = dev_get_parent_platdata(udev); + struct pci_child_plat *pplat = dev_get_parent_plat(udev); struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(udev); struct virtio_pci_priv *priv = dev_get_priv(udev); u16 subvendor; @@ -539,7 +539,7 @@ U_BOOT_DRIVER(virtio_pci_modern) = { .ops = &virtio_pci_ops, .bind = virtio_pci_bind, .probe = virtio_pci_probe, - .priv_auto_alloc_size = sizeof(struct virtio_pci_priv), + .priv_auto = sizeof(struct virtio_pci_priv), }; static struct pci_device_id virtio_pci_supported[] = { diff --git a/drivers/virtio/virtio_rng.c b/drivers/virtio/virtio_rng.c index fc3e19cfae..9314c0a03e 100644 --- a/drivers/virtio/virtio_rng.c +++ b/drivers/virtio/virtio_rng.c @@ -84,6 +84,6 @@ U_BOOT_DRIVER(virtio_rng) = { .probe = virtio_rng_probe, .remove = virtio_reset, .ops = &virtio_rng_ops, - .priv_auto_alloc_size = sizeof(struct virtio_rng_priv), + .priv_auto = sizeof(struct virtio_rng_priv), .flags = DM_FLAG_ACTIVE_DMA, }; diff --git a/drivers/virtio/virtio_sandbox.c b/drivers/virtio/virtio_sandbox.c index 2a2abb9d49..aafb7beb94 100644 --- a/drivers/virtio/virtio_sandbox.c +++ b/drivers/virtio/virtio_sandbox.c @@ -204,7 +204,7 @@ U_BOOT_DRIVER(virtio_sandbox1) = { .ops = &virtio_sandbox1_ops, .probe = virtio_sandbox_probe, .child_post_remove = virtio_sandbox_child_post_remove, - .priv_auto_alloc_size = sizeof(struct virtio_sandbox_priv), + .priv_auto = sizeof(struct virtio_sandbox_priv), }; /* this one without notify op */ @@ -231,5 +231,5 @@ U_BOOT_DRIVER(virtio_sandbox2) = { .of_match = virtio_sandbox2_ids, .ops = &virtio_sandbox2_ops, .probe = virtio_sandbox_probe, - .priv_auto_alloc_size = sizeof(struct virtio_sandbox_priv), + .priv_auto = sizeof(struct virtio_sandbox_priv), }; diff --git a/drivers/w1-eeprom/ds24xxx.c b/drivers/w1-eeprom/ds24xxx.c index 0967accdf0..d12fd5754e 100644 --- a/drivers/w1-eeprom/ds24xxx.c +++ b/drivers/w1-eeprom/ds24xxx.c @@ -31,7 +31,7 @@ static int ds24xxx_probe(struct udevice *dev) { struct w1_device *w1; - w1 = dev_get_parent_platdata(dev); + w1 = dev_get_parent_plat(dev); w1->id = 0; return 0; } diff --git a/drivers/w1-eeprom/ds2502.c b/drivers/w1-eeprom/ds2502.c index 19ee4b17ea..b3d68d7f05 100644 --- a/drivers/w1-eeprom/ds2502.c +++ b/drivers/w1-eeprom/ds2502.c @@ -222,7 +222,7 @@ static int ds2502_probe(struct udevice *dev) { struct w1_device *w1; - w1 = dev_get_parent_platdata(dev); + w1 = dev_get_parent_plat(dev); w1->id = 0; return 0; } diff --git a/drivers/w1-eeprom/w1-eeprom-uclass.c b/drivers/w1-eeprom/w1-eeprom-uclass.c index d515b4c536..97a9d43b03 100644 --- a/drivers/w1-eeprom/w1-eeprom-uclass.c +++ b/drivers/w1-eeprom/w1-eeprom-uclass.c @@ -53,7 +53,7 @@ int w1_eeprom_register_new_device(u64 id) if (dev_get_driver_data(dev) == family) { struct w1_device *w1; - w1 = dev_get_parent_platdata(dev); + w1 = dev_get_parent_plat(dev); if (w1->id) /* device already in use */ continue; w1->id = id; @@ -70,7 +70,7 @@ int w1_eeprom_register_new_device(u64 id) int w1_eeprom_get_id(struct udevice *dev, u64 *id) { - struct w1_device *w1 = dev_get_parent_platdata(dev); + struct w1_device *w1 = dev_get_parent_plat(dev); if (!w1) return -ENODEV; diff --git a/drivers/w1/mxc_w1.c b/drivers/w1/mxc_w1.c index 8e6372f0be..3637febc0c 100644 --- a/drivers/w1/mxc_w1.c +++ b/drivers/w1/mxc_w1.c @@ -79,7 +79,7 @@ static u8 mxc_w1_touch_bit(struct mxc_w1_pdata *pdata, u8 bit) static u8 mxc_w1_read_byte(struct udevice *dev) { - struct mxc_w1_pdata *pdata = dev_get_platdata(dev); + struct mxc_w1_pdata *pdata = dev_get_plat(dev); struct mxc_w1_regs *regs = pdata->regs; u16 status; @@ -106,7 +106,7 @@ static u8 mxc_w1_read_byte(struct udevice *dev) static void mxc_w1_write_byte(struct udevice *dev, u8 byte) { - struct mxc_w1_pdata *pdata = dev_get_platdata(dev); + struct mxc_w1_pdata *pdata = dev_get_plat(dev); struct mxc_w1_regs *regs = pdata->regs; u16 status; @@ -130,7 +130,7 @@ static void mxc_w1_write_byte(struct udevice *dev, u8 byte) static bool mxc_w1_reset(struct udevice *dev) { - struct mxc_w1_pdata *pdata = dev_get_platdata(dev); + struct mxc_w1_pdata *pdata = dev_get_plat(dev); u16 reg_val; writew(MXC_W1_CONTROL_RPP, &pdata->regs->control); @@ -144,7 +144,7 @@ static bool mxc_w1_reset(struct udevice *dev) static u8 mxc_w1_triplet(struct udevice *dev, bool bdir) { - struct mxc_w1_pdata *pdata = dev_get_platdata(dev); + struct mxc_w1_pdata *pdata = dev_get_plat(dev); u8 id_bit = mxc_w1_touch_bit(pdata, 1); u8 comp_bit = mxc_w1_touch_bit(pdata, 1); u8 retval; @@ -166,9 +166,9 @@ static u8 mxc_w1_triplet(struct udevice *dev, bool bdir) return retval; } -static int mxc_w1_ofdata_to_platdata(struct udevice *dev) +static int mxc_w1_of_to_plat(struct udevice *dev) { - struct mxc_w1_pdata *pdata = dev_get_platdata(dev); + struct mxc_w1_pdata *pdata = dev_get_plat(dev); fdt_addr_t addr; addr = dev_read_addr(dev); @@ -182,7 +182,7 @@ static int mxc_w1_ofdata_to_platdata(struct udevice *dev) static int mxc_w1_probe(struct udevice *dev) { - struct mxc_w1_pdata *pdata = dev_get_platdata(dev); + struct mxc_w1_pdata *pdata = dev_get_plat(dev); unsigned int clkrate = mxc_get_clock(MXC_IPG_PERCLK); unsigned int clkdiv; @@ -228,8 +228,8 @@ U_BOOT_DRIVER(mxc_w1_drv) = { .id = UCLASS_W1, .name = "mxc_w1_drv", .of_match = mxc_w1_id, - .ofdata_to_platdata = mxc_w1_ofdata_to_platdata, + .of_to_plat = mxc_w1_of_to_plat, .ops = &mxc_w1_ops, - .platdata_auto_alloc_size = sizeof(struct mxc_w1_pdata), + .plat_auto = sizeof(struct mxc_w1_pdata), .probe = mxc_w1_probe, }; diff --git a/drivers/w1/w1-gpio.c b/drivers/w1/w1-gpio.c index 45ad47a5d6..3b0ead6f6d 100644 --- a/drivers/w1/w1-gpio.c +++ b/drivers/w1/w1-gpio.c @@ -33,7 +33,7 @@ struct w1_gpio_pdata { static bool w1_gpio_read_bit(struct udevice *dev) { - struct w1_gpio_pdata *pdata = dev_get_platdata(dev); + struct w1_gpio_pdata *pdata = dev_get_plat(dev); int val; dm_gpio_set_dir_flags(&pdata->gpio, GPIOD_IS_OUT); @@ -63,7 +63,7 @@ static u8 w1_gpio_read_byte(struct udevice *dev) static void w1_gpio_write_bit(struct udevice *dev, bool bit) { - struct w1_gpio_pdata *pdata = dev_get_platdata(dev); + struct w1_gpio_pdata *pdata = dev_get_plat(dev); dm_gpio_set_dir_flags(&pdata->gpio, GPIOD_IS_OUT); @@ -84,7 +84,7 @@ static void w1_gpio_write_byte(struct udevice *dev, u8 byte) static bool w1_gpio_reset(struct udevice *dev) { - struct w1_gpio_pdata *pdata = dev_get_platdata(dev); + struct w1_gpio_pdata *pdata = dev_get_plat(dev); int val; /* initiate the reset pulse. first we must pull the bus to low */ @@ -151,9 +151,9 @@ static const struct w1_ops w1_gpio_ops = { .write_byte = w1_gpio_write_byte, }; -static int w1_gpio_ofdata_to_platdata(struct udevice *dev) +static int w1_gpio_of_to_plat(struct udevice *dev) { - struct w1_gpio_pdata *pdata = dev_get_platdata(dev); + struct w1_gpio_pdata *pdata = dev_get_plat(dev); int ret; ret = gpio_request_by_name(dev, "gpios", 0, &pdata->gpio, 0); @@ -172,7 +172,7 @@ U_BOOT_DRIVER(w1_gpio_drv) = { .id = UCLASS_W1, .name = "w1_gpio_drv", .of_match = w1_gpio_id, - .ofdata_to_platdata = w1_gpio_ofdata_to_platdata, + .of_to_plat = w1_gpio_of_to_plat, .ops = &w1_gpio_ops, - .platdata_auto_alloc_size = sizeof(struct w1_gpio_pdata), + .plat_auto = sizeof(struct w1_gpio_pdata), }; diff --git a/drivers/w1/w1-uclass.c b/drivers/w1/w1-uclass.c index 9478c93e9b..8bc6cb13f4 100644 --- a/drivers/w1/w1-uclass.c +++ b/drivers/w1/w1-uclass.c @@ -130,14 +130,14 @@ int w1_get_bus(int busnum, struct udevice **busp) u8 w1_get_device_family(struct udevice *dev) { - struct w1_device *w1 = dev_get_parent_platdata(dev); + struct w1_device *w1 = dev_get_parent_plat(dev); return w1->id & 0xff; } int w1_reset_select(struct udevice *dev) { - struct w1_device *w1 = dev_get_parent_platdata(dev); + struct w1_device *w1 = dev_get_parent_plat(dev); struct udevice *bus = dev_get_parent(dev); const struct w1_ops *ops = device_get_ops(bus); int i; @@ -230,10 +230,10 @@ UCLASS_DRIVER(w1) = { .name = "w1", .id = UCLASS_W1, .flags = DM_UC_FLAG_SEQ_ALIAS, - .per_device_auto_alloc_size = sizeof(struct w1_bus), + .per_device_auto = sizeof(struct w1_bus), .post_probe = w1_post_probe, #if CONFIG_IS_ENABLED(OF_CONTROL) .post_bind = dm_scan_fdt_dev, #endif - .per_child_platdata_auto_alloc_size = sizeof(struct w1_device), + .per_child_plat_auto = sizeof(struct w1_device), }; diff --git a/drivers/watchdog/armada-37xx-wdt.c b/drivers/watchdog/armada-37xx-wdt.c index 5da8e56505..dd97a17a70 100644 --- a/drivers/watchdog/armada-37xx-wdt.c +++ b/drivers/watchdog/armada-37xx-wdt.c @@ -196,6 +196,6 @@ U_BOOT_DRIVER(a37xx_wdt) = { .id = UCLASS_WDT, .of_match = a37xx_wdt_ids, .probe = a37xx_wdt_probe, - .priv_auto_alloc_size = sizeof(struct a37xx_wdt), + .priv_auto = sizeof(struct a37xx_wdt), .ops = &a37xx_wdt_ops, }; diff --git a/drivers/watchdog/ast_wdt.c b/drivers/watchdog/ast_wdt.c index 9b83d2ad44..f7b5a1adc1 100644 --- a/drivers/watchdog/ast_wdt.c +++ b/drivers/watchdog/ast_wdt.c @@ -86,7 +86,7 @@ static int ast_wdt_expire_now(struct udevice *dev, ulong flags) return ast_wdt_stop(dev); } -static int ast_wdt_ofdata_to_platdata(struct udevice *dev) +static int ast_wdt_of_to_plat(struct udevice *dev) { struct ast_wdt_priv *priv = dev_get_priv(dev); @@ -113,7 +113,7 @@ static const struct udevice_id ast_wdt_ids[] = { static int ast_wdt_probe(struct udevice *dev) { - debug("%s() wdt%u\n", __func__, dev->seq); + debug("%s() wdt%u\n", __func__, dev_seq(dev)); ast_wdt_stop(dev); return 0; @@ -124,7 +124,7 @@ U_BOOT_DRIVER(ast_wdt) = { .id = UCLASS_WDT, .of_match = ast_wdt_ids, .probe = ast_wdt_probe, - .priv_auto_alloc_size = sizeof(struct ast_wdt_priv), - .ofdata_to_platdata = ast_wdt_ofdata_to_platdata, + .priv_auto = sizeof(struct ast_wdt_priv), + .of_to_plat = ast_wdt_of_to_plat, .ops = &ast_wdt_ops, }; diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index 33f5c351d5..9e0d89be62 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -108,7 +108,7 @@ static int at91_wdt_probe(struct udevice *dev) if (!priv->regs) return -EINVAL; - debug("%s: Probing wdt%u\n", __func__, dev->seq); + debug("%s: Probing wdt%u\n", __func__, dev_seq(dev)); return 0; } @@ -117,7 +117,7 @@ U_BOOT_DRIVER(atmel_at91sam9260_wdt) = { .name = "atmel_at91sam9260_wdt", .id = UCLASS_WDT, .of_match = at91_wdt_ids, - .priv_auto_alloc_size = sizeof(struct at91_wdt_priv), + .priv_auto = sizeof(struct at91_wdt_priv), .ops = &at91_wdt_ops, .probe = at91_wdt_probe, }; diff --git a/drivers/watchdog/bcm6345_wdt.c b/drivers/watchdog/bcm6345_wdt.c index ee77f49a94..677b1347ca 100644 --- a/drivers/watchdog/bcm6345_wdt.c +++ b/drivers/watchdog/bcm6345_wdt.c @@ -112,6 +112,6 @@ U_BOOT_DRIVER(wdt_bcm6345) = { .id = UCLASS_WDT, .of_match = bcm6345_wdt_ids, .ops = &bcm6345_wdt_ops, - .priv_auto_alloc_size = sizeof(struct bcm6345_wdt_priv), + .priv_auto = sizeof(struct bcm6345_wdt_priv), .probe = bcm6345_wdt_probe, }; diff --git a/drivers/watchdog/cdns_wdt.c b/drivers/watchdog/cdns_wdt.c index 2abd5524f6..966d010e40 100644 --- a/drivers/watchdog/cdns_wdt.c +++ b/drivers/watchdog/cdns_wdt.c @@ -223,12 +223,12 @@ static int cdns_wdt_stop(struct udevice *dev) */ static int cdns_wdt_probe(struct udevice *dev) { - debug("%s: Probing wdt%u\n", __func__, dev->seq); + debug("%s: Probing wdt%u\n", __func__, dev_seq(dev)); return 0; } -static int cdns_wdt_ofdata_to_platdata(struct udevice *dev) +static int cdns_wdt_of_to_plat(struct udevice *dev) { struct cdns_wdt_priv *priv = dev_get_priv(dev); @@ -260,7 +260,7 @@ U_BOOT_DRIVER(cdns_wdt) = { .id = UCLASS_WDT, .of_match = cdns_wdt_ids, .probe = cdns_wdt_probe, - .priv_auto_alloc_size = sizeof(struct cdns_wdt_priv), - .ofdata_to_platdata = cdns_wdt_ofdata_to_platdata, + .priv_auto = sizeof(struct cdns_wdt_priv), + .of_to_plat = cdns_wdt_of_to_plat, .ops = &cdns_wdt_ops, }; diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c index 7caa6c550c..c020324973 100644 --- a/drivers/watchdog/designware_wdt.c +++ b/drivers/watchdog/designware_wdt.c @@ -168,7 +168,7 @@ U_BOOT_DRIVER(designware_wdt) = { .name = "designware_wdt", .id = UCLASS_WDT, .of_match = designware_wdt_ids, - .priv_auto_alloc_size = sizeof(struct designware_wdt_priv), + .priv_auto = sizeof(struct designware_wdt_priv), .probe = designware_wdt_probe, .ops = &designware_wdt_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index b90c2daece..5e0a096ce5 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -169,7 +169,7 @@ U_BOOT_DRIVER(imx_wdt) = { .of_match = imx_wdt_ids, .probe = imx_wdt_probe, .ops = &imx_wdt_ops, - .priv_auto_alloc_size = sizeof(struct imx_wdt_priv), + .priv_auto = sizeof(struct imx_wdt_priv), .flags = DM_FLAG_PRE_RELOC, }; #endif diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c index 1cd8866ef8..8b5ed28ebd 100644 --- a/drivers/watchdog/mt7621_wdt.c +++ b/drivers/watchdog/mt7621_wdt.c @@ -98,6 +98,6 @@ U_BOOT_DRIVER(mt762x_wdt) = { .id = UCLASS_WDT, .of_match = mt762x_wdt_ids, .probe = mt762x_wdt_probe, - .priv_auto_alloc_size = sizeof(struct mt762x_wdt), + .priv_auto = sizeof(struct mt762x_wdt), .ops = &mt762x_wdt_ops, }; diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c index a636cff354..b098b2e3cf 100644 --- a/drivers/watchdog/mtk_wdt.c +++ b/drivers/watchdog/mtk_wdt.c @@ -152,7 +152,7 @@ U_BOOT_DRIVER(mtk_wdt) = { .name = "mtk_wdt", .id = UCLASS_WDT, .of_match = mtk_wdt_ids, - .priv_auto_alloc_size = sizeof(struct mtk_wdt_priv), + .priv_auto = sizeof(struct mtk_wdt_priv), .probe = mtk_wdt_probe, .ops = &mtk_wdt_ops, .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/watchdog/octeontx_wdt.c b/drivers/watchdog/octeontx_wdt.c index 88708dc5e1..5f586ef683 100644 --- a/drivers/watchdog/octeontx_wdt.c +++ b/drivers/watchdog/octeontx_wdt.c @@ -137,7 +137,7 @@ U_BOOT_DRIVER(wdt_octeontx) = { .id = UCLASS_WDT, .of_match = octeontx_wdt_ids, .ops = &octeontx_wdt_ops, - .priv_auto_alloc_size = sizeof(struct octeontx_wdt), + .priv_auto = sizeof(struct octeontx_wdt), .probe = octeontx_wdt_probe, .remove = octeontx_wdt_remove, .flags = DM_FLAG_OS_PREPARE, diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index 9059a4c610..ca2bc7cfb5 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c @@ -242,7 +242,7 @@ static int omap3_wdt_probe(struct udevice *dev) return -EINVAL; priv->wdt_trgr_pattern = 0x1234; - debug("%s: Probing wdt%u\n", __func__, dev->seq); + debug("%s: Probing wdt%u\n", __func__, dev_seq(dev)); return 0; } @@ -263,6 +263,6 @@ U_BOOT_DRIVER(omap3_wdt) = { .of_match = omap3_wdt_ids, .ops = &omap3_wdt_ops, .probe = omap3_wdt_probe, - .priv_auto_alloc_size = sizeof(struct omap3_wdt_priv), + .priv_auto = sizeof(struct omap3_wdt_priv), }; #endif /* !CONFIG_IS_ENABLED(WDT) */ diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index d33e2ac3dc..167af904dc 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c @@ -133,7 +133,7 @@ static inline bool save_reg_from_ofdata(struct udevice *dev, int index, return true; } -static int orion_wdt_ofdata_to_platdata(struct udevice *dev) +static int orion_wdt_of_to_plat(struct udevice *dev) { struct orion_wdt_priv *priv = dev_get_priv(dev); @@ -158,7 +158,7 @@ static int orion_wdt_probe(struct udevice *dev) struct orion_wdt_priv *priv = dev_get_priv(dev); int ret; - debug("%s: Probing wdt%u\n", __func__, dev->seq); + debug("%s: Probing wdt%u\n", __func__, dev_seq(dev)); orion_wdt_stop(dev); ret = clk_get_by_name(dev, "fixed", &priv->clk); @@ -186,7 +186,7 @@ U_BOOT_DRIVER(orion_wdt) = { .id = UCLASS_WDT, .of_match = orion_wdt_ids, .probe = orion_wdt_probe, - .priv_auto_alloc_size = sizeof(struct orion_wdt_priv), - .ofdata_to_platdata = orion_wdt_ofdata_to_platdata, + .priv_auto = sizeof(struct orion_wdt_priv), + .of_to_plat = orion_wdt_of_to_plat, .ops = &orion_wdt_ops, }; diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c index ebe29c7409..f64a39f657 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -118,6 +118,6 @@ U_BOOT_DRIVER(rti_wdt) = { .of_match = rti_wdt_ids, .ops = &rti_wdt_ops, .probe = rti_wdt_probe, - .priv_auto_alloc_size = sizeof(struct rti_wdt_priv), + .priv_auto = sizeof(struct rti_wdt_priv), .flags = DM_FLAG_REMOVE_WITH_PD_ON, }; diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c index 96285c1a9b..b7cb199c92 100644 --- a/drivers/watchdog/sbsa_gwdt.c +++ b/drivers/watchdog/sbsa_gwdt.c @@ -88,12 +88,12 @@ static int sbsa_gwdt_expire_now(struct udevice *dev, ulong flags) static int sbsa_gwdt_probe(struct udevice *dev) { - debug("%s: Probing wdt%u (sbsa-gwdt)\n", __func__, dev->seq); + debug("%s: Probing wdt%u (sbsa-gwdt)\n", __func__, dev_seq(dev)); return 0; } -static int sbsa_gwdt_ofdata_to_platdata(struct udevice *dev) +static int sbsa_gwdt_of_to_plat(struct udevice *dev) { struct sbsa_gwdt_priv *priv = dev_get_priv(dev); @@ -125,7 +125,7 @@ U_BOOT_DRIVER(sbsa_gwdt) = { .id = UCLASS_WDT, .of_match = sbsa_gwdt_ids, .probe = sbsa_gwdt_probe, - .priv_auto_alloc_size = sizeof(struct sbsa_gwdt_priv), - .ofdata_to_platdata = sbsa_gwdt_ofdata_to_platdata, + .priv_auto = sizeof(struct sbsa_gwdt_priv), + .of_to_plat = sbsa_gwdt_of_to_plat, .ops = &sbsa_gwdt_ops, }; diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 23fef2147f..291aad7570 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -105,12 +105,12 @@ static int sp805_wdt_expire_now(struct udevice *dev, ulong flags) static int sp805_wdt_probe(struct udevice *dev) { - debug("%s: Probing wdt%u (sp805-wdt)\n", __func__, dev->seq); + debug("%s: Probing wdt%u (sp805-wdt)\n", __func__, dev_seq(dev)); return 0; } -static int sp805_wdt_ofdata_to_platdata(struct udevice *dev) +static int sp805_wdt_of_to_plat(struct udevice *dev) { struct sp805_wdt_priv *priv = dev_get_priv(dev); struct clk clk; @@ -142,7 +142,7 @@ U_BOOT_DRIVER(sp805_wdt) = { .id = UCLASS_WDT, .of_match = sp805_wdt_ids, .probe = sp805_wdt_probe, - .priv_auto_alloc_size = sizeof(struct sp805_wdt_priv), - .ofdata_to_platdata = sp805_wdt_ofdata_to_platdata, + .priv_auto = sizeof(struct sp805_wdt_priv), + .of_to_plat = sp805_wdt_of_to_plat, .ops = &sp805_wdt_ops, }; diff --git a/drivers/watchdog/stm32mp_wdt.c b/drivers/watchdog/stm32mp_wdt.c index f673fce327..53586fdbfc 100644 --- a/drivers/watchdog/stm32mp_wdt.c +++ b/drivers/watchdog/stm32mp_wdt.c @@ -131,7 +131,7 @@ U_BOOT_DRIVER(stm32mp_wdt) = { .name = "stm32mp-wdt", .id = UCLASS_WDT, .of_match = stm32mp_wdt_match, - .priv_auto_alloc_size = sizeof(struct stm32mp_wdt_priv), + .priv_auto = sizeof(struct stm32mp_wdt_priv), .probe = stm32mp_wdt_probe, .ops = &stm32mp_wdt_ops, }; diff --git a/drivers/watchdog/tangier_wdt.c b/drivers/watchdog/tangier_wdt.c index 358a9b90fd..bdc65597dc 100644 --- a/drivers/watchdog/tangier_wdt.c +++ b/drivers/watchdog/tangier_wdt.c @@ -80,7 +80,7 @@ static const struct udevice_id tangier_wdt_ids[] = { static int tangier_wdt_probe(struct udevice *dev) { - debug("%s: Probing wdt%u\n", __func__, dev->seq); + debug("%s: Probing wdt%u\n", __func__, dev_seq(dev)); return 0; } diff --git a/drivers/watchdog/xilinx_tb_wdt.c b/drivers/watchdog/xilinx_tb_wdt.c index ea4311c8ce..1687a4599f 100644 --- a/drivers/watchdog/xilinx_tb_wdt.c +++ b/drivers/watchdog/xilinx_tb_wdt.c @@ -26,7 +26,7 @@ struct watchdog_regs { u32 tbr; /* 0x8 */ }; -struct xlnx_wdt_platdata { +struct xlnx_wdt_plat { bool enable_once; struct watchdog_regs *regs; }; @@ -34,16 +34,16 @@ struct xlnx_wdt_platdata { static int xlnx_wdt_reset(struct udevice *dev) { u32 reg; - struct xlnx_wdt_platdata *platdata = dev_get_platdata(dev); + struct xlnx_wdt_plat *plat = dev_get_plat(dev); debug("%s ", __func__); /* Read the current contents of TCSR0 */ - reg = readl(&platdata->regs->twcsr0); + reg = readl(&plat->regs->twcsr0); /* Clear the watchdog WDS bit */ if (reg & (XWT_CSR0_EWDT1_MASK | XWT_CSRX_EWDT2_MASK)) - writel(reg | XWT_CSR0_WDS_MASK, &platdata->regs->twcsr0); + writel(reg | XWT_CSR0_WDS_MASK, &plat->regs->twcsr0); return 0; } @@ -51,18 +51,18 @@ static int xlnx_wdt_reset(struct udevice *dev) static int xlnx_wdt_stop(struct udevice *dev) { u32 reg; - struct xlnx_wdt_platdata *platdata = dev_get_platdata(dev); + struct xlnx_wdt_plat *plat = dev_get_plat(dev); - if (platdata->enable_once) { + if (plat->enable_once) { debug("Can't stop Xilinx watchdog.\n"); return -EBUSY; } /* Read the current contents of TCSR0 */ - reg = readl(&platdata->regs->twcsr0); + reg = readl(&plat->regs->twcsr0); - writel(reg & ~XWT_CSR0_EWDT1_MASK, &platdata->regs->twcsr0); - writel(~XWT_CSRX_EWDT2_MASK, &platdata->regs->twcsr1); + writel(reg & ~XWT_CSR0_EWDT1_MASK, &plat->regs->twcsr0); + writel(~XWT_CSRX_EWDT2_MASK, &plat->regs->twcsr1); debug("Watchdog disabled!\n"); @@ -71,37 +71,37 @@ static int xlnx_wdt_stop(struct udevice *dev) static int xlnx_wdt_start(struct udevice *dev, u64 timeout, ulong flags) { - struct xlnx_wdt_platdata *platdata = dev_get_platdata(dev); + struct xlnx_wdt_plat *plat = dev_get_plat(dev); debug("%s:\n", __func__); writel((XWT_CSR0_WRS_MASK | XWT_CSR0_WDS_MASK | XWT_CSR0_EWDT1_MASK), - &platdata->regs->twcsr0); + &plat->regs->twcsr0); - writel(XWT_CSRX_EWDT2_MASK, &platdata->regs->twcsr1); + writel(XWT_CSRX_EWDT2_MASK, &plat->regs->twcsr1); return 0; } static int xlnx_wdt_probe(struct udevice *dev) { - debug("%s: Probing wdt%u\n", __func__, dev->seq); + debug("%s: Probing wdt%u\n", __func__, dev_seq(dev)); return 0; } -static int xlnx_wdt_ofdata_to_platdata(struct udevice *dev) +static int xlnx_wdt_of_to_plat(struct udevice *dev) { - struct xlnx_wdt_platdata *platdata = dev_get_platdata(dev); + struct xlnx_wdt_plat *plat = dev_get_plat(dev); - platdata->regs = (struct watchdog_regs *)dev_read_addr(dev); - if (IS_ERR(platdata->regs)) - return PTR_ERR(platdata->regs); + plat->regs = (struct watchdog_regs *)dev_read_addr(dev); + if (IS_ERR(plat->regs)) + return PTR_ERR(plat->regs); - platdata->enable_once = dev_read_u32_default(dev, - "xlnx,wdt-enable-once", 0); + plat->enable_once = dev_read_u32_default(dev, "xlnx,wdt-enable-once", + 0); - debug("%s: wdt-enable-once %d\n", __func__, platdata->enable_once); + debug("%s: wdt-enable-once %d\n", __func__, plat->enable_once); return 0; } @@ -123,7 +123,7 @@ U_BOOT_DRIVER(xlnx_wdt) = { .id = UCLASS_WDT, .of_match = xlnx_wdt_ids, .probe = xlnx_wdt_probe, - .platdata_auto_alloc_size = sizeof(struct xlnx_wdt_platdata), - .ofdata_to_platdata = xlnx_wdt_ofdata_to_platdata, + .plat_auto = sizeof(struct xlnx_wdt_plat), + .of_to_plat = xlnx_wdt_of_to_plat, .ops = &xlnx_wdt_ops, }; diff --git a/drivers/watchdog/xilinx_wwdt.c b/drivers/watchdog/xilinx_wwdt.c index d8a585a483..9137d87697 100644 --- a/drivers/watchdog/xilinx_wwdt.c +++ b/drivers/watchdog/xilinx_wwdt.c @@ -36,7 +36,7 @@ struct xlnx_wwdt_priv { struct clk clk; }; -struct xlnx_wwdt_platdata { +struct xlnx_wwdt_plat { bool enable_once; }; @@ -125,10 +125,10 @@ static int xlnx_wwdt_start(struct udevice *dev, u64 timeout, ulong flags) static int xlnx_wwdt_probe(struct udevice *dev) { int ret; - struct xlnx_wwdt_platdata *platdata = dev_get_platdata(dev); + struct xlnx_wwdt_plat *plat = dev_get_plat(dev); struct xlnx_wwdt_priv *wdt = dev_get_priv(dev); - dev_dbg(dev, "%s: Probing wdt%u\n", __func__, dev->seq); + dev_dbg(dev, "%s: Probing wdt%u\n", __func__, dev_seq(dev)); ret = regmap_init_mem(dev_ofnode(dev), &wdt->regs); if (ret) { @@ -136,7 +136,7 @@ static int xlnx_wwdt_probe(struct udevice *dev) return ret; } - wdt->enable_once = platdata->enable_once; + wdt->enable_once = plat->enable_once; ret = clk_get_by_index(dev, 0, &wdt->clk); if (ret < 0) @@ -145,13 +145,13 @@ static int xlnx_wwdt_probe(struct udevice *dev) return ret; } -static int xlnx_wwdt_ofdata_to_platdata(struct udevice *dev) +static int xlnx_wwdt_of_to_plat(struct udevice *dev) { - struct xlnx_wwdt_platdata *platdata = dev_get_platdata(dev); + struct xlnx_wwdt_plat *plat = dev_get_plat(dev); - platdata->enable_once = dev_read_u32_default(dev, - "xlnx,wdt-enable-once", 0); - dev_dbg(dev, "wdt-enable-once %d\n", platdata->enable_once); + plat->enable_once = dev_read_u32_default(dev, "xlnx,wdt-enable-once", + 0); + dev_dbg(dev, "wdt-enable-once %d\n", plat->enable_once); return 0; } @@ -172,8 +172,8 @@ U_BOOT_DRIVER(xlnx_wwdt) = { .id = UCLASS_WDT, .of_match = xlnx_wwdt_ids, .probe = xlnx_wwdt_probe, - .priv_auto_alloc_size = sizeof(struct xlnx_wwdt_priv), - .platdata_auto_alloc_size = sizeof(struct xlnx_wwdt_platdata), - .ofdata_to_platdata = xlnx_wwdt_ofdata_to_platdata, + .priv_auto = sizeof(struct xlnx_wwdt_priv), + .plat_auto = sizeof(struct xlnx_wwdt_plat), + .of_to_plat = xlnx_wwdt_of_to_plat, .ops = &xlnx_wwdt_ops, }; diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c index 1b3325bbe2..6455dfd5c9 100644 --- a/drivers/xen/pvblock.c +++ b/drivers/xen/pvblock.c @@ -70,7 +70,7 @@ struct blkfront_dev { u8 *bounce_buffer; }; -struct blkfront_platdata { +struct blkfront_plat { unsigned int devid; }; @@ -600,7 +600,7 @@ static ulong pvblock_iop(struct udevice *udev, lbaint_t blknr, lbaint_t blkcnt, void *buffer, int write) { struct blkfront_dev *blk_dev = dev_get_priv(udev); - struct blk_desc *desc = dev_get_uclass_platdata(udev); + struct blk_desc *desc = dev_get_uclass_plat(udev); struct blkfront_aiocb aiocb; lbaint_t blocks_todo; bool unaligned; @@ -658,7 +658,7 @@ ulong pvblock_blk_write(struct udevice *udev, lbaint_t blknr, lbaint_t blkcnt, static int pvblock_blk_bind(struct udevice *udev) { - struct blk_desc *desc = dev_get_uclass_platdata(udev); + struct blk_desc *desc = dev_get_uclass_plat(udev); int devnum; desc->if_type = IF_TYPE_PVBLOCK; @@ -685,12 +685,12 @@ static int pvblock_blk_bind(struct udevice *udev) static int pvblock_blk_probe(struct udevice *udev) { struct blkfront_dev *blk_dev = dev_get_priv(udev); - struct blkfront_platdata *platdata = dev_get_platdata(udev); - struct blk_desc *desc = dev_get_uclass_platdata(udev); + struct blkfront_plat *plat = dev_get_plat(udev); + struct blk_desc *desc = dev_get_uclass_plat(udev); int ret, devid; - devid = platdata->devid; - free(platdata); + devid = plat->devid; + free(plat); ret = init_blkfront(devid, blk_dev); if (ret < 0) @@ -723,7 +723,7 @@ U_BOOT_DRIVER(pvblock_blk) = { .bind = pvblock_blk_bind, .probe = pvblock_blk_probe, .remove = pvblock_blk_remove, - .priv_auto_alloc_size = sizeof(struct blkfront_dev), + .priv_auto = sizeof(struct blkfront_dev), .flags = DM_FLAG_OS_PREPARE, }; @@ -737,27 +737,27 @@ static int on_new_vbd(struct udevice *parent, unsigned int devid) { struct driver_info info; struct udevice *udev; - struct blkfront_platdata *platdata; + struct blkfront_plat *plat; int ret; debug("New " DRV_NAME_BLK ", device ID %d\n", devid); - platdata = malloc(sizeof(struct blkfront_platdata)); - if (!platdata) { + plat = malloc(sizeof(struct blkfront_plat)); + if (!plat) { printf("Failed to allocate platform data\n"); return -ENOMEM; } - platdata->devid = devid; + plat->devid = devid; info.name = DRV_NAME_BLK; - info.platdata = platdata; + info.plat = plat; ret = device_bind_by_name(parent, false, &info, &udev); if (ret < 0) { printf("Failed to bind " DRV_NAME_BLK " to device with ID %d, ret: %d\n", devid, ret); - free(platdata); + free(plat); } return ret; } @@ -802,7 +802,7 @@ static void print_pvblock_devices(void) class_name = uclass_get_name(UCLASS_PVBLOCK); for (blk_first_device(IF_TYPE_PVBLOCK, &udev); udev; blk_next_device(&udev), first = false) { - struct blk_desc *desc = dev_get_uclass_platdata(udev); + struct blk_desc *desc = dev_get_uclass_plat(udev); if (!first) puts(", "); diff --git a/dts/Kconfig b/dts/Kconfig index aeda542f98..71f50552e4 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -346,13 +346,13 @@ config SPL_OF_PLATDATA former can add 3KB or more to a Thumb 2 Image. This option enables generation of platform data from the device - tree as C code. This code creates devices using U_BOOT_DEVICE() + tree as C code. This code creates devices using U_BOOT_DRVINFO() declarations. The benefit is that it allows driver code to access the platform data directly in C structures, avoidin the libfdt overhead. This option works by generating C structure declarations for each - compatible string, then adding platform data and U_BOOT_DEVICE + compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. config SPL_OF_PLATDATA_PARENT @@ -376,13 +376,13 @@ config TPL_OF_PLATDATA former can add 3KB or more to a Thumb 2 Image. This option enables generation of platform data from the device - tree as C code. This code creates devices using U_BOOT_DEVICE() + tree as C code. This code creates devices using U_BOOT_DRVINFO() declarations. The benefit is that it allows driver code to access the platform data directly in C structures, avoidin the libfdt overhead. This option works by generating C structure declarations for each - compatible string, then adding platform data and U_BOOT_DEVICE + compatible string, then adding platform data and U_BOOT_DRVINFO declarations for each node. See of-plat.txt for more information. config TPL_OF_PLATDATA_PARENT diff --git a/dts/Makefile b/dts/Makefile index a20930eb9a..94967cf656 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -16,7 +16,8 @@ else DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb endif -$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE +$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE + mkdir -p $(dir $@) $(call if_changed,fdtgrep) ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y) @@ -27,7 +28,7 @@ $(obj)/dt.dtb: $(DTB) FORCE $(call if_changed,shipped) endif -targets += dt.dtb dt-spl.dtb +targets += dt.dtb $(DTB): arch-dtbs $(Q)test -e $@ || ( \ @@ -51,10 +52,15 @@ else obj-$(CONFIG_OF_EMBED) := dt.dtb.o endif -dtbs: $(obj)/dt.dtb $(obj)/dt-spl.dtb +# Target for U-Boot proper +dtbs: $(obj)/dt.dtb @: -clean-files := dt.dtb.S dt-spl.dtb.S +# Target for SPL/TPL +spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb + @: + +clean-files := dt.dtb.S # Let clean descend into dts directories subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts diff --git a/fs/fat/fat.c b/fs/fat/fat.c index fb6ba89466..157dad60a4 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -621,7 +621,7 @@ static int get_fs_info(fsdata *mydata) /* * The root directory is not cluster-aligned and may be on a * "negative" cluster, this will be handled specially in - * next_cluster(). + * fat_next_cluster(). */ mydata->root_cluster = 0; } @@ -647,44 +647,88 @@ static int get_fs_info(fsdata *mydata) return 0; } - -/* - * Directory iterator, to simplify filesystem traversal +/** + * struct fat_itr - directory iterator, to simplify filesystem traversal * * Implements an iterator pattern to traverse directory tables, * transparently handling directory tables split across multiple * clusters, and the difference between FAT12/FAT16 root directory * (contiguous) and subdirectories + FAT32 root (chained). * - * Rough usage: + * Rough usage * - * for (fat_itr_root(&itr, fsdata); fat_itr_next(&itr); ) { - * // to traverse down to a subdirectory pointed to by - * // current iterator position: - * fat_itr_child(&itr, &itr); - * } + * .. code-block:: c * - * For more complete example, see fat_itr_resolve() + * for (fat_itr_root(&itr, fsdata); fat_itr_next(&itr); ) { + * // to traverse down to a subdirectory pointed to by + * // current iterator position: + * fat_itr_child(&itr, &itr); + * } + * + * For a more complete example, see fat_itr_resolve(). */ - -typedef struct { - fsdata *fsdata; /* filesystem parameters */ - unsigned start_clust; /* first cluster */ - unsigned clust; /* current cluster */ - unsigned next_clust; /* next cluster if remaining == 0 */ - int last_cluster; /* set once we've read last cluster */ - int is_root; /* is iterator at root directory */ - int remaining; /* remaining dent's in current cluster */ - - /* current iterator position values: */ - dir_entry *dent; /* current directory entry */ - char l_name[VFAT_MAXLEN_BYTES]; /* long (vfat) name */ - char s_name[14]; /* short 8.3 name */ - char *name; /* l_name if there is one, else s_name */ - - /* storage for current cluster in memory: */ - u8 block[MAX_CLUSTSIZE] __aligned(ARCH_DMA_MINALIGN); -} fat_itr; +struct fat_itr { + /** + * @fsdata: filesystem parameters + */ + fsdata *fsdata; + /** + * @start_clust: first cluster + */ + unsigned int start_clust; + /** + * @clust: current cluster + */ + unsigned int clust; + /** + * @next_clust: next cluster if remaining == 0 + */ + unsigned int next_clust; + /** + * @last_cluster: set if last cluster of directory reached + */ + int last_cluster; + /** + * @is_root: is iterator at root directory + */ + int is_root; + /** + * @remaining: remaining directory entries in current cluster + */ + int remaining; + /** + * @dent: current directory entry + */ + dir_entry *dent; + /** + * @dent_rem: remaining entries after long name start + */ + int dent_rem; + /** + * @dent_clust: cluster of long name start + */ + unsigned int dent_clust; + /** + * @dent_start: first directory entry for long name + */ + dir_entry *dent_start; + /** + * @l_name: long name of current directory entry + */ + char l_name[VFAT_MAXLEN_BYTES]; + /** + * @s_name: short 8.3 name of current directory entry + */ + char s_name[14]; + /** + * @name: l_name if there is one, else s_name + */ + char *name; + /** + * @block: buffer for current cluster + */ + u8 block[MAX_CLUSTSIZE] __aligned(ARCH_DMA_MINALIGN); +}; static int fat_itr_isdir(fat_itr *itr); @@ -702,7 +746,7 @@ static int fat_itr_root(fat_itr *itr, fsdata *fsdata) return -ENXIO; itr->fsdata = fsdata; - itr->start_clust = 0; + itr->start_clust = fsdata->root_cluster; itr->clust = fsdata->root_cluster; itr->next_clust = fsdata->root_cluster; itr->dent = NULL; @@ -746,6 +790,7 @@ static void fat_itr_child(fat_itr *itr, fat_itr *parent) } else { itr->clust = parent->fsdata->root_cluster; itr->next_clust = parent->fsdata->root_cluster; + itr->start_clust = parent->fsdata->root_cluster; itr->is_root = 1; } itr->dent = NULL; @@ -753,9 +798,18 @@ static void fat_itr_child(fat_itr *itr, fat_itr *parent) itr->last_cluster = 0; } -static void *next_cluster(fat_itr *itr, unsigned *nbytes) +/** + * fat_next_cluster() - load next FAT cluster + * + * The function is used when iterating through directories. It loads the + * next cluster with directory entries + * + * @itr: directory iterator + * @nbytes: number of bytes read, 0 on error + * Return: first directory entry, NULL on error + */ +void *fat_next_cluster(fat_itr *itr, unsigned int *nbytes) { - fsdata *mydata = itr->fsdata; /* for silly macros */ int ret; u32 sect; u32 read_size; @@ -783,8 +837,8 @@ static void *next_cluster(fat_itr *itr, unsigned *nbytes) read_size = itr->fsdata->clust_size; } - debug("FAT read(sect=%d), clust_size=%d, read_size=%u, DIRENTSPERBLOCK=%zd\n", - sect, itr->fsdata->clust_size, read_size, DIRENTSPERBLOCK); + log_debug("FAT read(sect=%d), clust_size=%d, read_size=%u\n", + sect, itr->fsdata->clust_size, read_size); /* * NOTE: do_fat_read_at() had complicated logic to deal w/ @@ -825,7 +879,7 @@ static dir_entry *next_dent(fat_itr *itr) { if (itr->remaining == 0) { unsigned nbytes; - struct dir_entry *dent = next_cluster(itr, &nbytes); + struct dir_entry *dent = fat_next_cluster(itr, &nbytes); /* have we reached the last cluster? */ if (!dent) { @@ -923,9 +977,13 @@ static int fat_itr_next(fat_itr *itr) while (1) { dent = next_dent(itr); - if (!dent) + if (!dent) { + itr->dent_start = NULL; return 0; - + } + itr->dent_rem = itr->remaining; + itr->dent_start = itr->dent; + itr->dent_clust = itr->clust; if (dent->name[0] == DELETED_FLAG) continue; @@ -1025,6 +1083,7 @@ static int fat_itr_resolve(fat_itr *itr, const char *path, unsigned type) /* point back to itself */ itr->clust = itr->fsdata->root_cluster; itr->next_clust = itr->fsdata->root_cluster; + itr->start_clust = itr->fsdata->root_cluster; itr->dent = NULL; itr->remaining = 0; itr->last_cluster = 0; @@ -1318,3 +1377,21 @@ void fat_closedir(struct fs_dir_stream *dirs) void fat_close(void) { } + +int fat_uuid(char *uuid_str) +{ + boot_sector bs; + volume_info volinfo; + int fatsize; + int ret; + u8 *id; + + ret = read_bootsectandvi(&bs, &volinfo, &fatsize); + if (ret) + return ret; + + id = volinfo.volume_id; + sprintf(uuid_str, "%02X%02X-%02X%02X", id[3], id[2], id[1], id[0]); + + return 0; +} diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index 7afc8388b2..20a54a2418 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -8,25 +8,185 @@ #include <common.h> #include <command.h> #include <config.h> +#include <div64.h> #include <fat.h> #include <log.h> #include <malloc.h> -#include <asm/byteorder.h> #include <part.h> +#include <rand.h> +#include <asm/byteorder.h> #include <asm/cache.h> #include <linux/ctype.h> -#include <div64.h> #include <linux/math64.h> #include "fat.c" -static void uppercase(char *str, int len) +static dir_entry *find_directory_entry(fat_itr *itr, char *filename); +static int new_dir_table(fat_itr *itr); + +/* Characters that may only be used in long file names */ +static const char LONG_ONLY_CHARS[] = "+,;=[]"; + +/* Combined size of the name and ext fields in the directory entry */ +#define SHORT_NAME_SIZE 11 + +/** + * str2fat() - convert string to valid FAT name characters + * + * Stop when reaching end of @src or a period. + * Ignore spaces. + * Replace characters that may only be used in long names by underscores. + * Convert lower case characters to upper case. + * + * To avoid assumptions about the code page we do not use characters + * above 0x7f for the short name. + * + * @dest: destination buffer + * @src: source buffer + * @length: size of destination buffer + * Return: number of bytes in destination buffer + */ +static int str2fat(char *dest, char *src, int length) { int i; - for (i = 0; i < len; i++) { - *str = toupper(*str); - str++; + for (i = 0; i < length; ++src) { + char c = *src; + + if (!c || c == '.') + break; + if (c == ' ') + continue; + if (strchr(LONG_ONLY_CHARS, c) || c > 0x7f) + c = '_'; + else if (c >= 'a' && c <= 'z') + c &= 0xdf; + dest[i] = c; + ++i; + } + return i; +} + +/** + * fat_move_to_cluster() - position to first directory entry in cluster + * + * @itr: directory iterator + * @cluster cluster + * Return: 0 for success, -EIO on error + */ +static int fat_move_to_cluster(fat_itr *itr, unsigned int cluster) +{ + unsigned int nbytes; + + /* position to the start of the directory */ + itr->next_clust = cluster; + itr->last_cluster = 0; + if (!fat_next_cluster(itr, &nbytes)) + return -EIO; + itr->dent = (dir_entry *)itr->block; + itr->remaining = nbytes / sizeof(dir_entry) - 1; + return 0; +} + +/** + * set_name() - set short name in directory entry + * + * The function determines if the @filename is a valid short name. + * In this case no long name is needed. + * + * If a long name is needed, a short name is constructed. + * + * @itr: directory iterator + * @filename: long file name + * @shortname: buffer of 11 bytes to receive chosen short name and extension + * Return: number of directory entries needed, negative on error + */ +static int set_name(fat_itr *itr, const char *filename, char *shortname) +{ + char *period; + char *pos; + int period_location; + char buf[13]; + int i; + int ret; + struct { + char name[8]; + char ext[3]; + } dirent; + + if (!filename) + return -EIO; + + /* Initialize buffer */ + memset(&dirent, ' ', sizeof(dirent)); + + /* Convert filename to upper case short name */ + period = strrchr(filename, '.'); + pos = (char *)filename; + if (*pos == '.') { + pos = period + 1; + period = 0; + } + if (period) + str2fat(dirent.ext, period + 1, sizeof(dirent.ext)); + period_location = str2fat(dirent.name, pos, sizeof(dirent.name)); + if (period_location < 0) + return period_location; + if (*dirent.name == ' ') + *dirent.name = '_'; + /* 0xe5 signals a deleted directory entry. Replace it by 0x05. */ + if (*dirent.name == 0xe5) + *dirent.name = 0x05; + + /* If filename and short name are the same, quit. */ + sprintf(buf, "%.*s.%.3s", period_location, dirent.name, dirent.ext); + if (!strcmp(buf, filename)) { + ret = 1; + goto out; + } + + /* Construct an indexed short name */ + for (i = 1; i < 0x200000; ++i) { + int suffix_len; + int suffix_start; + int j; + + /* To speed up the search use random numbers */ + if (i < 10) { + j = i; + } else { + j = 30 - fls(i); + j = 10 + (rand() >> j); + } + sprintf(buf, "~%d", j); + suffix_len = strlen(buf); + suffix_start = 8 - suffix_len; + if (suffix_start > period_location) + suffix_start = period_location; + memcpy(dirent.name + suffix_start, buf, suffix_len); + if (*dirent.ext != ' ') + sprintf(buf, "%.*s.%.3s", suffix_start + suffix_len, + dirent.name, dirent.ext); + else + sprintf(buf, "%.*s", suffix_start + suffix_len, + dirent.name); + debug("generated short name: %s\n", buf); + + /* Check that the short name does not exist yet. */ + ret = fat_move_to_cluster(itr, itr->start_clust); + if (ret) + return ret; + if (find_directory_entry(itr, buf)) + continue; + + debug("chosen short name: %s\n", buf); + /* Each long name directory entry takes 13 characters. */ + ret = (strlen(filename) + 25) / 13; + goto out; } + return -EIO; +out: + memcpy(shortname, dirent.name, SHORT_NAME_SIZE); + return ret; } static int total_sector; @@ -50,67 +210,6 @@ static int disk_write(__u32 block, __u32 nr_blocks, void *buf) return ret; } -/** - * set_name() - set short name in directory entry - * - * @dirent: directory entry - * @filename: long file name - */ -static void set_name(dir_entry *dirent, const char *filename) -{ - char s_name[VFAT_MAXLEN_BYTES]; - char *period; - int period_location, len, i, ext_num; - - if (filename == NULL) - return; - - len = strlen(filename); - if (len == 0) - return; - - strncpy(s_name, filename, VFAT_MAXLEN_BYTES - 1); - s_name[VFAT_MAXLEN_BYTES - 1] = '\0'; - uppercase(s_name, len); - - period = strchr(s_name, '.'); - if (period == NULL) { - period_location = len; - ext_num = 0; - } else { - period_location = period - s_name; - ext_num = len - period_location - 1; - } - - /* Pad spaces when the length of file name is shorter than eight */ - if (period_location < 8) { - memcpy(dirent->name, s_name, period_location); - for (i = period_location; i < 8; i++) - dirent->name[i] = ' '; - } else if (period_location == 8) { - memcpy(dirent->name, s_name, period_location); - } else { - memcpy(dirent->name, s_name, 6); - /* - * TODO: Translating two long names with the same first six - * characters to the same short name is utterly wrong. - * Short names must be unique. - */ - dirent->name[6] = '~'; - dirent->name[7] = '1'; - } - - if (ext_num < 3) { - memcpy(dirent->ext, s_name + period_location + 1, ext_num); - for (i = ext_num; i < 3; i++) - dirent->ext[i] = ' '; - } else - memcpy(dirent->ext, s_name + period_location + 1, 3); - - debug("name : %s\n", dirent->name); - debug("ext : %s\n", dirent->ext); -} - /* * Write fat buffer into block device */ @@ -152,6 +251,66 @@ static int flush_dirty_fat_buffer(fsdata *mydata) return 0; } +/** + * fat_find_empty_dentries() - find a sequence of available directory entries + * + * @itr: directory iterator + * @count: number of directory entries to find + * Return: 0 on success or negative error number + */ +static int fat_find_empty_dentries(fat_itr *itr, int count) +{ + unsigned int cluster; + dir_entry *dent; + int remaining; + unsigned int n = 0; + int ret; + + ret = fat_move_to_cluster(itr, itr->start_clust); + if (ret) + return ret; + + for (;;) { + if (!itr->dent) { + log_debug("Not enough directory entries available\n"); + return -ENOSPC; + } + switch (itr->dent->name[0]) { + case 0x00: + case DELETED_FLAG: + if (!n) { + /* Remember first deleted directory entry */ + cluster = itr->clust; + dent = itr->dent; + remaining = itr->remaining; + } + ++n; + if (n == count) + goto out; + break; + default: + n = 0; + break; + } + + next_dent(itr); + if (!itr->dent && + (!itr->is_root || itr->fsdata->fatsize == 32) && + new_dir_table(itr)) + return -ENOSPC; + } +out: + /* Position back to first directory entry */ + if (itr->clust != cluster) { + ret = fat_move_to_cluster(itr, cluster); + if (ret) + return ret; + } + itr->dent = dent; + itr->remaining = remaining; + return 0; +} + /* * Set the file name information from 'name' into 'slotptr', */ @@ -221,15 +380,18 @@ name11_12: return 1; } -static int new_dir_table(fat_itr *itr); static int flush_dir(fat_itr *itr); -/* - * Fill dir_slot entries with appropriate name, id, and attr - * 'itr' will point to a next entry +/** + * fill_dir_slot() - fill directory entries for long name + * + * @itr: directory iterator + * @l_name: long name + * @shortname: short name + * Return: 0 for success, -errno otherwise */ static int -fill_dir_slot(fat_itr *itr, const char *l_name) +fill_dir_slot(fat_itr *itr, const char *l_name, const char *shortname) { __u8 temp_dir_slot_buffer[MAX_LFN_SLOT * sizeof(dir_slot)]; dir_slot *slotptr = (dir_slot *)temp_dir_slot_buffer; @@ -237,7 +399,7 @@ fill_dir_slot(fat_itr *itr, const char *l_name) int idx = 0, ret; /* Get short file name checksum value */ - checksum = mkcksum(itr->dent->name, itr->dent->ext); + checksum = mkcksum(shortname, shortname + 8); do { memset(slotptr, 0x00, sizeof(dir_slot)); @@ -259,11 +421,9 @@ fill_dir_slot(fat_itr *itr, const char *l_name) if (itr->remaining == 0) flush_dir(itr); - /* allocate a cluster for more entries */ - if (!fat_itr_next(itr) && !itr->dent) - if ((itr->is_root && itr->fsdata->fatsize != 32) || - new_dir_table(itr)) - return -1; + next_dent(itr); + if (!itr->dent) + return -EIO; } return 0; @@ -636,17 +796,32 @@ static int find_empty_cluster(fsdata *mydata) return entry; } -/* - * Allocate a cluster for additional directory entries +/** + * new_dir_table() - allocate a cluster for additional directory entries + * + * @itr: directory iterator + * Return: 0 on success, -EIO otherwise */ static int new_dir_table(fat_itr *itr) { fsdata *mydata = itr->fsdata; int dir_newclust = 0; + int dir_oldclust = itr->clust; unsigned int bytesperclust = mydata->clust_size * mydata->sect_size; dir_newclust = find_empty_cluster(mydata); - set_fatent_value(mydata, itr->clust, dir_newclust); + + /* + * Flush before updating FAT to ensure valid directory structure + * in case of failure. + */ + itr->clust = dir_newclust; + itr->next_clust = dir_newclust; + memset(itr->block, 0x00, bytesperclust); + if (flush_dir(itr)) + return -EIO; + + set_fatent_value(mydata, dir_oldclust, dir_newclust); if (mydata->fatsize == 32) set_fatent_value(mydata, dir_newclust, 0xffffff8); else if (mydata->fatsize == 16) @@ -654,13 +829,8 @@ static int new_dir_table(fat_itr *itr) else if (mydata->fatsize == 12) set_fatent_value(mydata, dir_newclust, 0xff8); - itr->clust = dir_newclust; - itr->next_clust = dir_newclust; - if (flush_dirty_fat_buffer(mydata) < 0) - return -1; - - memset(itr->block, 0x00, bytesperclust); + return -EIO; itr->dent = (dir_entry *)itr->block; itr->last_cluster = 1; @@ -961,24 +1131,35 @@ getit: return 0; } -/* - * Fill dir_entry +/** + * fill_dentry() - fill directory entry with shortname + * + * @mydata: private filesystem parameters + * @dentptr: directory entry + * @shortname: chosen short name + * @start_cluster: first cluster of file + * @size: file size + * @attr: file attributes */ static void fill_dentry(fsdata *mydata, dir_entry *dentptr, - const char *filename, __u32 start_cluster, __u32 size, __u8 attr) + const char *shortname, __u32 start_cluster, __u32 size, __u8 attr) { + memset(dentptr, 0, sizeof(*dentptr)); + set_start_cluster(mydata, dentptr, start_cluster); dentptr->size = cpu_to_le32(size); dentptr->attr = attr; - set_name(dentptr, filename); + memcpy(dentptr->name, shortname, SHORT_NAME_SIZE); } -/* - * Find a directory entry based on filename or start cluster number - * If the directory entry is not found, - * the new position for writing a directory entry will be returned +/** + * find_directory_entry() - find a directory entry by filename + * + * @itr: directory iterator + * @filename: name of file to find + * Return: directory entry or NULL */ static dir_entry *find_directory_entry(fat_itr *itr, char *filename) { @@ -1001,13 +1182,6 @@ static dir_entry *find_directory_entry(fat_itr *itr, char *filename) return itr->dent; } - /* allocate a cluster for more entries */ - if (!itr->dent && - (!itr->is_root || itr->fsdata->fatsize == 32) && - new_dir_table(itr)) - /* indicate that allocating dent failed */ - itr->dent = NULL; - return NULL; } @@ -1157,6 +1331,8 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer, retdent->size = cpu_to_le32(pos + size); } else { /* Create a new file */ + char shortname[SHORT_NAME_SIZE]; + int ndent; if (itr->is_root) { /* root dir cannot have "." or ".." */ @@ -1167,31 +1343,30 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer, } } - if (!itr->dent) { - printf("Error: allocating new dir entry\n"); - ret = -EIO; - goto exit; - } - if (pos) { /* No hole allowed */ ret = -EINVAL; goto exit; } - memset(itr->dent, 0, sizeof(*itr->dent)); - - /* Calculate checksum for short name */ - set_name(itr->dent, filename); - - /* Set long name entries */ - if (fill_dir_slot(itr, filename)) { - ret = -EIO; + /* Check if long name is needed */ + ndent = set_name(itr, filename, shortname); + if (ndent < 0) { + ret = ndent; goto exit; } + ret = fat_find_empty_dentries(itr, ndent); + if (ret) + goto exit; + if (ndent > 1) { + /* Set long name entries */ + ret = fill_dir_slot(itr, filename, shortname); + if (ret) + goto exit; + } /* Set short name entry */ - fill_dentry(itr->fsdata, itr->dent, filename, 0, size, + fill_dentry(itr->fsdata, itr->dent, shortname, 0, size, ATTR_ARCH); retdent = itr->dent; @@ -1270,27 +1445,91 @@ exit: return count; } -static int delete_dentry(fat_itr *itr) +/** + * delete_single_dentry() - delete a single directory entry + * + * @itr: directory iterator + * Return: 0 for success + */ +static int delete_single_dentry(fat_itr *itr) +{ + struct dir_entry *dent = itr->dent; + + memset(dent, 0, sizeof(*dent)); + dent->name[0] = DELETED_FLAG; + + if (!itr->remaining) { + if (flush_dir(itr)) { + printf("error: writing directory entry\n"); + return -EIO; + } + } + return 0; +} + +/** + * delete_long_name() - delete long name directory entries + * + * @itr: directory iterator + * Return: 0 for success + */ +static int delete_long_name(fat_itr *itr) +{ + struct dir_entry *dent = itr->dent; + int seqn = itr->dent->name[0] & ~LAST_LONG_ENTRY_MASK; + + while (seqn--) { + int ret; + + ret = delete_single_dentry(itr); + if (ret) + return ret; + dent = next_dent(itr); + if (!dent) + return -EIO; + } + return 0; +} + +/** + * delete_dentry_long() - remove directory entry + * + * @itr: directory iterator + * Return: 0 for success + */ +static int delete_dentry_long(fat_itr *itr) { fsdata *mydata = itr->fsdata; - dir_entry *dentptr = itr->dent; + dir_entry *dent = itr->dent; /* free cluster blocks */ - clear_fatent(mydata, START(dentptr)); + clear_fatent(mydata, START(dent)); if (flush_dirty_fat_buffer(mydata) < 0) { printf("Error: flush fat buffer\n"); return -EIO; } + /* Position to first directory entry for long name */ + if (itr->clust != itr->dent_clust) { + int ret; - /* - * update a directory entry - * TODO: - * - long file name support - * - find and mark the "new" first invalid entry as name[0]=0x00 - */ - memset(dentptr, 0, sizeof(*dentptr)); - dentptr->name[0] = 0xe5; + ret = fat_move_to_cluster(itr, itr->dent_clust); + if (ret) + return ret; + } + itr->dent = itr->dent_start; + itr->remaining = itr->dent_rem; + dent = itr->dent_start; + /* Delete long name */ + if ((dent->attr & ATTR_VFAT) == ATTR_VFAT && + (dent->name[0] & LAST_LONG_ENTRY_MASK)) { + int ret; + ret = delete_long_name(itr); + if (ret) + return ret; + } + /* Delete short name */ + delete_single_dentry(itr); if (flush_dir(itr)) { printf("error: writing directory entry\n"); return -EIO; @@ -1360,7 +1599,7 @@ int fat_unlink(const char *filename) } } - ret = delete_dentry(itr); + ret = delete_dentry_long(itr); exit: free(fsdata.fatbuf); @@ -1424,6 +1663,9 @@ int fat_mkdir(const char *new_dirname) ret = -EEXIST; goto exit; } else { + char shortname[SHORT_NAME_SIZE]; + int ndent; + if (itr->is_root) { /* root dir cannot have "." or ".." */ if (!strcmp(l_dirname, ".") || @@ -1433,20 +1675,24 @@ int fat_mkdir(const char *new_dirname) } } - if (!itr->dent) { - printf("Error: allocating new dir entry\n"); - ret = -EIO; + /* Check if long name is needed */ + ndent = set_name(itr, dirname, shortname); + if (ndent < 0) { + ret = ndent; goto exit; } - - memset(itr->dent, 0, sizeof(*itr->dent)); - - /* Set short name to set alias checksum field in dir_slot */ - set_name(itr->dent, dirname); - fill_dir_slot(itr, dirname); + ret = fat_find_empty_dentries(itr, ndent); + if (ret) + goto exit; + if (ndent > 1) { + /* Set long name entries */ + ret = fill_dir_slot(itr, dirname, shortname); + if (ret) + goto exit; + } /* Set attribute as archive for regular file */ - fill_dentry(itr->fsdata, itr->dent, dirname, 0, 0, + fill_dentry(itr->fsdata, itr->dent, shortname, 0, 0, ATTR_DIR | ATTR_ARCH); retdent = itr->dent; @@ -1468,7 +1714,11 @@ int fat_mkdir(const char *new_dirname) memcpy(dotdent[1].name, ".. ", 8); memcpy(dotdent[1].ext, " ", 3); dotdent[1].attr = ATTR_DIR | ATTR_ARCH; - set_start_cluster(mydata, &dotdent[1], itr->start_clust); + + if (itr->is_root) + set_start_cluster(mydata, &dotdent[1], 0); + else + set_start_cluster(mydata, &dotdent[1], itr->start_clust); ret = set_contents(mydata, retdent, 0, (__u8 *)dotdent, bytesperclust, &actwrite); @@ -194,7 +194,7 @@ static struct fstype_info fstypes[] = { .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, #endif - .uuid = fs_uuid_unsupported, + .uuid = fat_uuid, .opendir = fat_opendir, .readdir = fat_readdir, .closedir = fat_closedir, diff --git a/include/adc.h b/include/adc.h index 5841dfb54b..0d1a666908 100644 --- a/include/adc.h +++ b/include/adc.h @@ -40,7 +40,7 @@ struct adc_channel { }; /** - * struct adc_uclass_platdata - basic ADC info + * struct adc_uclass_plat - basic ADC info * * Note: The positive/negative reference Voltage is only a name and it doesn't * provide an information about the value polarity. It is possible, for both @@ -71,7 +71,7 @@ struct adc_channel { * @vdd_microvolts - positive reference Voltage value * @vss_microvolts - negative reference Voltage value */ -struct adc_uclass_platdata { +struct adc_uclass_plat { int data_format; unsigned int data_mask; unsigned int data_timeout_us; diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 887b5c268d..efa09a1943 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -184,6 +184,12 @@ struct global_data { #ifdef CONFIG_DM /** + * @dm_flags: additional flags for Driver Model + * + * See &enum gd_dm_flags + */ + unsigned long dm_flags; + /** * @dm_root: root instance for Driver Model */ struct udevice *dm_root; @@ -194,7 +200,13 @@ struct global_data { /** * @uclass_root: head of core tree */ - struct list_head uclass_root; + struct list_head uclass_root_s; + /** + * @uclass_root: pointer to head of core tree, if uclasses are in + * read-only memory and cannot be adjusted to use @uclass_root as a + * list head. + */ + struct list_head *uclass_root; # if CONFIG_IS_ENABLED(OF_PLATDATA) /** @dm_driver_rt: Dynamic info about the driver */ struct driver_rt *dm_driver_rt; @@ -465,6 +477,12 @@ struct global_data { #define gd_acpi_ctx() NULL #endif +#if CONFIG_IS_ENABLED(DM) +#define gd_size_cells_0() (gd->dm_flags & GD_DM_FLG_SIZE_CELLS_0) +#else +#define gd_size_cells_0() (0) +#endif + /** * enum gd_flags - global data flags * @@ -549,6 +567,18 @@ enum gd_flags { GD_FLG_SMP_READY = 0x40000, }; +/** + * enum gd_dm_flags - global data flags for Driver Model + * + * See field dm_flags of &struct global_data. + */ +enum gd_dm_flags { + /** + * @GD_DM_FLG_SIZE_CELLS_0: Enable #size-cells=<0> translation + */ + GD_DM_FLG_SIZE_CELLS_0 = 0x00001, +}; + #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_GBL_DATA_H */ diff --git a/include/atf_common.h b/include/atf_common.h index fd5454c55b..d69892fac6 100644 --- a/include/atf_common.h +++ b/include/atf_common.h @@ -14,8 +14,14 @@ #define ATF_PARAM_EP 0x01 #define ATF_PARAM_IMAGE_BINARY 0x02 #define ATF_PARAM_BL31 0x03 +#define ATF_PARAM_BL_PARAMS 0x05 #define ATF_VERSION_1 0x01 +#define ATF_VERSION_2 0x02 + +#define ATF_BL31_IMAGE_ID 0x03 +#define ATF_BL32_IMAGE_ID 0x04 +#define ATF_BL33_IMAGE_ID 0x05 #define ATF_EP_SECURE 0x0 #define ATF_EP_NON_SECURE 0x1 @@ -121,6 +127,9 @@ struct atf_image_info { struct param_header h; uintptr_t image_base; /* physical address of base of image */ uint32_t image_size; /* bytes read from image file */ +#if CONFIG_IS_ENABLED(ATF_LOAD_IMAGE_V2) + uint32_t image_max_size; +#endif }; /***************************************************************************** @@ -162,21 +171,28 @@ struct bl31_params { struct atf_image_info *bl33_image_info; }; -/******************************************************************************* - * This structure represents the superset of information that is passed to - * BL31, e.g. while passing control to it from BL2, bl31_params - * and other platform specific params - ******************************************************************************/ -struct bl2_to_bl31_params_mem { - struct bl31_params bl31_params; - struct atf_image_info bl31_image_info; - struct atf_image_info bl32_image_info; - struct atf_image_info bl33_image_info; - struct entry_point_info bl33_ep_info; - struct entry_point_info bl32_ep_info; - struct entry_point_info bl31_ep_info; +/* BL image node in the BL image execution sequence */ +struct bl_params_node { + unsigned int image_id; + struct atf_image_info *image_info; + struct entry_point_info *ep_info; + struct bl_params_node *next_params_info; +}; + +/* + * BL image head node in the BL image execution sequence + * It is also used to pass information to next BL image. + */ +struct bl_params { + struct param_header h; + struct bl_params_node *head; }; +#define for_each_bl_params_node(bl_params, node) \ + for ((node) = (bl_params)->head; \ + (node); \ + (node) = (node)->next_params_info) + #endif /*__ASSEMBLY__ */ #endif /* __BL_COMMON_H__ */ diff --git a/include/atmel_lcd.h b/include/atmel_lcd.h index 4aa955b6b2..66436b9b27 100644 --- a/include/atmel_lcd.h +++ b/include/atmel_lcd.h @@ -10,11 +10,11 @@ #define _ATMEL_LCD_H_ /** - * struct atmel_lcd_platdata - platform data for Atmel LCDs with driver model + * struct atmel_lcd_plat - platform data for Atmel LCDs with driver model * * @timing_index: Index of LCD timing to use in device tree node */ -struct atmel_lcd_platdata { +struct atmel_lcd_plat { int timing_index; }; diff --git a/include/blk.h b/include/blk.h index 9ee10fb80e..c4401b0025 100644 --- a/include/blk.h +++ b/include/blk.h @@ -56,7 +56,7 @@ enum sig_type { /* * With driver model (CONFIG_BLK) this is uclass platform data, accessible - * with dev_get_uclass_platdata(dev) + * with dev_get_uclass_plat(dev) */ struct blk_desc { /* diff --git a/include/bootm.h b/include/bootm.h index a812a6bf24..7f88ec718b 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -75,6 +75,14 @@ void board_quiesce_devices(void); */ void switch_to_non_secure_mode(void); +/* Flags to control bootm_process_cmdline() */ +enum bootm_cmdline_t { + BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */ + BOOTM_CL_SUBST = 1 << 1, /* Do substitution */ + + BOOTM_CL_ALL = 3, /* All substitutions */ +}; + /** * arch_preboot_os() - arch specific configuration before booting */ @@ -85,4 +93,36 @@ void arch_preboot_os(void); */ void board_preboot_os(void); +/* + * bootm_process_cmdline() - Process fix-ups for the command line + * + * This handles: + * + * - making Linux boot silently if requested ('silent_linux' envvar) + * - performing substitutions in the command line ('bootargs_subst' envvar) + * + * @maxlen must provide enough space for the string being processed plus the + * resulting string + * + * @buf: buffer holding commandline string to adjust + * @maxlen: Maximum length of buffer at @buf (including \0) + * @flags: Flags to control what happens (see bootm_cmdline_t) + * @return 0 if OK, -ENOMEM if out of memory, -ENOSPC if the commandline is too + * long + */ +int bootm_process_cmdline(char *buf, int maxlen, int flags); + +/** + * bootm_process_cmdline_env() - Process fix-ups for the command line + * + * Updates the 'bootargs' envvar as required. This handles: + * + * - making Linux boot silently if requested ('silent_linux' envvar) + * - performing substitutions in the command line ('bootargs_subst' envvar) + * + * @flags: Flags to control what happens (see bootm_cmdline_t) + * @return 0 if OK, -ENOMEM if out of memory + */ +int bootm_process_cmdline_env(int flags); + #endif diff --git a/include/cli.h b/include/cli.h index 39b913743b..3449fa6ae7 100644 --- a/include/cli.h +++ b/include/cli.h @@ -34,8 +34,10 @@ int cli_simple_run_command(const char *cmd, int flag); * * @param input Input string possible containing $() / ${} vars * @param output Output string with $() / ${} vars expanded + * @param max_size Maximum size of @output (including terminator) + * @return 0 if OK, -ENOSPC if we ran out of space in @output */ -void cli_simple_process_macros(const char *input, char *output); +int cli_simple_process_macros(const char *input, char *output, int max_size); /** * cli_simple_run_command_list() - Execute a list of command diff --git a/include/clk-uclass.h b/include/clk-uclass.h index dac42dab36..50e8681b55 100644 --- a/include/clk-uclass.h +++ b/include/clk-uclass.h @@ -62,6 +62,14 @@ struct clk_ops { */ int (*rfree)(struct clk *clock); /** + * round_rate() - Adjust a rate to the exact rate a clock can provide. + * + * @clk: The clock to manipulate. + * @rate: Desidered clock rate in Hz. + * @return rounded rate in Hz, or -ve error code. + */ + ulong (*round_rate)(struct clk *clk, ulong rate); + /** * get_rate() - Get current clock rate. * * @clk: The clock to query. diff --git a/include/clk.h b/include/clk.h index a62e2efa2c..ca6b85fa6f 100644 --- a/include/clk.h +++ b/include/clk.h @@ -367,6 +367,29 @@ struct clk *clk_get_parent(struct clk *clk); long long clk_get_parent_rate(struct clk *clk); /** + * clk_round_rate() - Adjust a rate to the exact rate a clock can provide + * + * This answers the question "if I were to pass @rate to clk_set_rate(), + * what clock rate would I end up with?" without changing the hardware + * in any way. In other words: + * + * rate = clk_round_rate(clk, r); + * + * and: + * + * rate = clk_set_rate(clk, r); + * + * are equivalent except the former does not modify the clock hardware + * in any way. + * + * @clk: A clock struct that was previously successfully requested by + * clk_request/get_by_*(). + * @rate: desired clock rate in Hz. + * @return rounded rate in Hz, or -ve error code. + */ +ulong clk_round_rate(struct clk *clk, ulong rate); + +/** * clk_set_rate() - Set current clock rate. * * @clk: A clock struct that was previously successfully requested by @@ -482,6 +505,11 @@ static inline long long clk_get_parent_rate(struct clk *clk) return -ENOSYS; } +static inline ulong clk_round_rate(struct clk *clk, ulong rate) +{ + return -ENOSYS; +} + static inline ulong clk_set_rate(struct clk *clk, ulong rate) { return -ENOSYS; diff --git a/include/command.h b/include/command.h index b9b5ec1afa..e229bf2825 100644 --- a/include/command.h +++ b/include/command.h @@ -117,7 +117,31 @@ int cmd_process_error(struct cmd_tbl *cmdtp, int err); defined(CONFIG_CMD_PCI) || \ defined(CONFIG_CMD_SETEXPR) #define CMD_DATA_SIZE -extern int cmd_get_data_size(char* arg, int default_size); +#define CMD_DATA_SIZE_ERR (-1) +#define CMD_DATA_SIZE_STR (-2) + +/** + * cmd_get_data_size() - Get the data-size specifier from a command + * + * This reads a '.x' size specifier appended to a command. For example 'md.b' + * is the 'md' command with a '.b' specifier, meaning that the command should + * use bytes. + * + * Valid characters are: + * + * b - byte + * w - word (16 bits) + * l - long (32 bits) + * q - quad (64 bits) + * s - string + * + * @arg: Pointers to the command to check. If a valid specifier is present it + * will be the last character of the string, following a '.' + * @default_size: Default size to return if there is no specifier + * @return data size in bytes (1, 2, 4, 8) or CMD_DATA_SIZE_ERR for an invalid + * character, or CMD_DATA_SIZE_STR for a string + */ +int cmd_get_data_size(char *arg, int default_size); #endif #ifdef CONFIG_CMD_BOOTD @@ -159,6 +183,23 @@ extern int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); #endif +/** + * setexpr_regex_sub() - Replace a regex pattern with a string + * + * @data: Buffer containing the string to update + * @data_size: Size of buffer (must be large enough for the new string) + * @nbuf: Back-reference buffer + * @nbuf_size: Size of back-reference buffer (must be larger enough for @s plus + * all back-reference expansions) + * @r: Regular expression to find + * @s: String to replace with + * @global: true to replace all matches in @data, false to replace just the + * first + * @return 0 if OK, 1 on error + */ +int setexpr_regex_sub(char *data, uint data_size, char *nbuf, uint nbuf_size, + const char *r, const char *s, bool global); + /* * Error codes that commands return to cmd_process(). We use the standard 0 * and 1 for success and failure, but add one more case - failure with a diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h index 9eed0ea203..b39a5b4ca4 100644 --- a/include/configs/am65x_evm.h +++ b/include/configs/am65x_evm.h @@ -56,6 +56,12 @@ #define CONFIG_SKIP_LOWLEVEL_INIT #endif +/* + * If the maximum size is not declared then it is defined as + * CONFIG_SYS_DFU_DATA_BUF_SIZE. + */ +#define CONFIG_SYS_DFU_MAX_FILE_SIZE (1024 * 1024 * 8) /* 8 MiB */ + #define CONFIG_SPL_MAX_SIZE CONFIG_SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE #define CONFIG_SYS_BOOTM_LEN SZ_64M diff --git a/include/configs/apalis-imx8.h b/include/configs/apalis-imx8.h index db4e9011c0..b474b2f522 100644 --- a/include/configs/apalis-imx8.h +++ b/include/configs/apalis-imx8.h @@ -98,7 +98,6 @@ #define PHYS_SDRAM_2_SIZE SZ_2G /* 2 GB */ /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE SZ_2K #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h index 29a37ed44f..fc2c191594 100644 --- a/include/configs/colibri-imx8x.h +++ b/include/configs/colibri-imx8x.h @@ -132,7 +132,6 @@ #define PHYS_SDRAM_2_SIZE 0x00000000 /* 0 GB */ /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE SZ_2K #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mm_beacon.h b/include/configs/imx8mm_beacon.h index 3c9541187f..9a93dba1c5 100644 --- a/include/configs/imx8mm_beacon.h +++ b/include/configs/imx8mm_beacon.h @@ -119,7 +119,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h index 83521ad401..92eb85553e 100644 --- a/include/configs/imx8mm_evk.h +++ b/include/configs/imx8mm_evk.h @@ -120,7 +120,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mn_evk.h b/include/configs/imx8mn_evk.h index a6333085fe..cda8fc2ef7 100644 --- a/include/configs/imx8mn_evk.h +++ b/include/configs/imx8mn_evk.h @@ -124,7 +124,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h index 8253c6aa2f..92091dfd6b 100644 --- a/include/configs/imx8mp_evk.h +++ b/include/configs/imx8mp_evk.h @@ -135,7 +135,6 @@ #define CONFIG_MXC_UART_BASE UART2_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 2048 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mq_evk.h b/include/configs/imx8mq_evk.h index 3f9a3bc100..96bfff749c 100644 --- a/include/configs/imx8mq_evk.h +++ b/include/configs/imx8mq_evk.h @@ -175,7 +175,6 @@ /* Monitor Command Prompt */ #undef CONFIG_SYS_PROMPT #define CONFIG_SYS_PROMPT "u-boot=> " -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 1024 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/imx8mq_phanbell.h b/include/configs/imx8mq_phanbell.h index e8b65a4ba5..66c2c3a8d8 100644 --- a/include/configs/imx8mq_phanbell.h +++ b/include/configs/imx8mq_phanbell.h @@ -169,7 +169,6 @@ #define CONFIG_MXC_UART_BASE UART1_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 1024 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/k2g_evm.h b/include/configs/k2g_evm.h index 83466b9e0c..4471eb4f6a 100644 --- a/include/configs/k2g_evm.h +++ b/include/configs/k2g_evm.h @@ -35,6 +35,8 @@ "setenv name_fdt keystone-k2g-evm.dtb; " \ "else if test $board_name = 66AK2GIC; then " \ "setenv name_fdt keystone-k2g-ice.dtb; " \ + "else if test $board_name = 66AK2GI1; then " \ + "setenv name_fdt keystone-k2g-ice.dtb; " \ "else if test $name_fdt = undefined; then " \ "echo WARNING: Could not determine device tree to use;"\ "fi;fi;fi;fi; setenv fdtfile ${name_fdt}\0" \ diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index ad0041d8a9..d321ebdb63 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -181,9 +181,9 @@ "cramfsloadfdt=" \ "cramfsload ${fdt_addr_r} " \ "fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb\0" \ - "fdt_addr_r="__stringify(CONFIG_KM_FDT_ADDR) "\0" \ + "fdt_addr_r=" __stringify(CONFIG_KM_FDT_ADDR) "\0" \ "init=/sbin/init-overlay.sh\0" \ - "load_addr_r="__stringify(CONFIG_KM_KERNEL_ADDR) "\0" \ + "load_addr_r=" __stringify(CONFIG_KM_KERNEL_ADDR) "\0" \ "load=tftpboot ${load_addr_r} ${u-boot}\0" \ "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \ "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \ diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 98e0ce1c24..29060fa96b 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -48,7 +48,7 @@ " boardid=0x${IVM_BoardId} hwkey=0x${IVM_HWKey}" #define CONFIG_KM_DEF_ENV_CPU \ - "u-boot="CONFIG_HOSTNAME "/u-boot.kwb\0" \ + "u-boot=" CONFIG_HOSTNAME "/u-boot.kwb\0" \ CONFIG_KM_UPDATE_UBOOT \ "set_fdthigh=setenv fdt_high ${kernelmem}\0" \ "checkfdt=" \ diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index bc0bf04973..59b20cf116 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -81,6 +81,20 @@ # define BOOT_TARGET_DEVICES_QSPI(func) #endif +#if defined(CONFIG_MTD_NOR_FLASH) +# define BOOT_TARGET_DEVICES_NOR(func) func(NOR, nor, na) +#else +# define BOOT_TARGET_DEVICES_NOR(func) +#endif + +#define BOOTENV_DEV_NOR(devtypeu, devtypel, instance) \ + "bootcmd_nor=cp.b ${script_offset_nor} ${scriptaddr} ${script_size_f} && " \ + "echo NOR: Trying to boot script at ${scriptaddr} && " \ + "source ${scriptaddr}; echo NOR: SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_NOR(devtypeu, devtypel, instance) \ + "nor " + #define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \ "bootcmd_qspi=sf probe 0 0 0 && " \ "sf read ${scriptaddr} ${script_offset_f} ${script_size_f} && " \ @@ -101,7 +115,8 @@ #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_DEVICES_JTAG(func) \ - BOOT_TARGET_DEVICES_QSPI(func) \ + BOOT_TARGET_DEVICES_QSPI(func) \ + BOOT_TARGET_DEVICES_NOR(func) \ BOOT_TARGET_DEVICES_DHCP(func) \ BOOT_TARGET_DEVICES_PXE(func) diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h index 6879f52a0c..3f2700d8e2 100644 --- a/include/configs/nokia_rx51.h +++ b/include/configs/nokia_rx51.h @@ -169,8 +169,6 @@ int rx51_kp_getc(struct stdio_dev *sdev); "trymmcboot=if run switchmmc; then " \ "setenv mmctype fat;" \ "run trymmcallpartboot;" \ - "setenv mmctype ext2;" \ - "run trymmcallpartboot;" \ "setenv mmctype ext4;" \ "run trymmcallpartboot;" \ "fi\0" \ @@ -179,19 +177,10 @@ int rx51_kp_getc(struct stdio_dev *sdev); "preboot=setenv mmcnum 1; setenv mmcpart 1;" \ "setenv mmcscriptfile bootmenu.scr;" \ "if run switchmmc; then " \ - "setenv mmcdone true;" \ "setenv mmctype fat;" \ - "if run scriptload; then true; else " \ - "setenv mmctype ext2;" \ - "if run scriptload; then true; else " \ - "setenv mmctype ext4;" \ - "if run scriptload; then true; else " \ - "setenv mmcdone false;" \ - "fi;" \ - "fi;" \ - "fi;" \ - "if ${mmcdone}; then " \ - "run scriptboot;" \ + "if run scriptload; then run scriptboot; else " \ + "setenv mmctype ext4;" \ + "if run scriptload; then run scriptboot; fi;" \ "fi;" \ "fi;" \ "if run slide; then true; else " \ diff --git a/include/configs/pdu001.h b/include/configs/pdu001.h index e4b14c5ecd..53342ce193 100644 --- a/include/configs/pdu001.h +++ b/include/configs/pdu001.h @@ -37,9 +37,10 @@ #define CONFIG_BOOTCOMMAND \ "run eval_boot_device;" \ + "part uuid mmc ${mmc_boot}:${root_fs_partition} root_fs_partuuid;" \ "setenv bootargs console=${console} " \ "vt.global_cursor_default=0 " \ - "root=/dev/mmcblk${mmc_boot}p${root_fs_partition} " \ + "root=PARTUUID=${root_fs_partuuid} " \ "rootfstype=ext4 " \ "rootwait " \ "rootdelay=1;" \ diff --git a/include/configs/s5p4418_nanopi2.h b/include/configs/s5p4418_nanopi2.h index 6dd1f3bc04..1e2180b970 100644 --- a/include/configs/s5p4418_nanopi2.h +++ b/include/configs/s5p4418_nanopi2.h @@ -102,10 +102,6 @@ /* Boot Argument Buffer Size */ #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE -#ifdef CONFIG_HUSH_PARSER -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " -#endif - /*----------------------------------------------------------------------- * Etc Command definition */ diff --git a/include/configs/sama7g5ek.h b/include/configs/sama7g5ek.h new file mode 100644 index 0000000000..ef3bfa36fd --- /dev/null +++ b/include/configs/sama7g5ek.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Configuration file for the SAMA7G5EK Board. + * + * Copyright (C) 2020 Microchip Corporation + * Eugen Hristev <eugen.hristev@microchip.com> + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#define CONFIG_SYS_AT91_SLOW_CLOCK 32768 +#define CONFIG_SYS_AT91_MAIN_CLOCK 24000000 /* from 24 MHz crystal */ + +/* SDRAM */ +#define CONFIG_SYS_SDRAM_BASE 0x60000000 +#define CONFIG_SYS_SDRAM_SIZE 0x20000000 + +#ifdef CONFIG_SPL_BUILD +#define CONFIG_SYS_INIT_SP_ADDR 0x218000 +#else +#define CONFIG_SYS_INIT_SP_ADDR \ + (CONFIG_SYS_SDRAM_BASE + 16 * 1024 + CONFIG_SYS_MALLOC_F_LEN - \ + GENERATED_GBL_DATA_SIZE) +#endif + +#define CONFIG_SYS_LOAD_ADDR 0x62000000 /* load address */ + +#undef CONFIG_BOOTCOMMAND +#ifdef CONFIG_SD_BOOT +/* u-boot env in sd/mmc card */ + +/* bootstrap + u-boot + env in sd card */ +#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x61000000 at91-sama7g5ek.dtb; " \ + "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x62000000 zImage; " \ + "bootz 0x62000000 - 0x61000000" +#endif + +/* Size of malloc() pool */ +#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024) + +#define CONFIG_ARP_TIMEOUT 200 +#define CONFIG_NET_RETRY_COUNT 50 + +#endif diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index a6a4879523..203cb10fba 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -163,9 +163,7 @@ #define CONFIG_SYS_MONITOR_LEN (768 << 10) /* 768 KiB */ -#ifndef CONFIG_ARM64 /* AArch64 FEL support is not ready yet */ #define CONFIG_SPL_BOARD_LOAD_IMAGE -#endif /* * We cannot use expressions here, because expressions won't be evaluated in diff --git a/include/configs/verdin-imx8mm.h b/include/configs/verdin-imx8mm.h index fd8405433d..4751bf5a5a 100644 --- a/include/configs/verdin-imx8mm.h +++ b/include/configs/verdin-imx8mm.h @@ -98,7 +98,6 @@ #define CONFIG_MXC_UART_BASE UART1_BASE_ADDR /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE SZ_2K #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/configs/xenguest_arm64.h b/include/configs/xenguest_arm64.h index c44381e966..d76ce13d14 100644 --- a/include/configs/xenguest_arm64.h +++ b/include/configs/xenguest_arm64.h @@ -27,7 +27,6 @@ #define CONFIG_SYS_MALLOC_LEN (32 * 1024 * 1024) /* Monitor Command Prompt */ -#define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #define CONFIG_SYS_CBSIZE 1024 #define CONFIG_SYS_MAXARGS 64 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE diff --git a/include/cpu.h b/include/cpu.h index 78e88b9ed0..5831bfa742 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -8,7 +8,7 @@ #define __CPU_H /** - * struct cpu_platdata - platform data for a CPU + * struct cpu_plat - platform data for a CPU * @cpu_id: Platform-specific way of identifying the CPU. * @ucode_version: Microcode version, if CPU_FEAT_UCODE is set * @device_id: Driver-defined device identifier @@ -17,10 +17,10 @@ * @timebase_freq: the current frequency at which the cpu timer timebase * registers are updated (in Hz) * - * This can be accessed with dev_get_parent_platdata() for any UCLASS_CPU + * This can be accessed with dev_get_parent_plat() for any UCLASS_CPU * device. */ -struct cpu_platdata { +struct cpu_plat { int cpu_id; int ucode_version; ulong device_id; diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index c5d7ec0650..639bbd293d 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -19,8 +19,8 @@ struct udevice; * device_bind() - Create a device and bind it to a driver * * Called to set up a new device attached to a driver. The device will either - * have platdata, or a device tree node which can be used to create the - * platdata. + * have plat, or a device tree node which can be used to create the + * plat. * * Once bound a device exists but is not yet active until device_probe() is * called. @@ -28,22 +28,18 @@ struct udevice; * @parent: Pointer to device's parent, under which this driver will exist * @drv: Device's driver * @name: Name of device (e.g. device tree node name) - * @platdata: Pointer to data for this device - the structure is device- + * @plat: Pointer to data for this device - the structure is device- * specific but may include the device's I/O address, etc.. This is NULL for * devices which use device tree. - * @of_offset: Offset of device tree node for this device. This is -1 for - * devices which don't use device tree. + * @ofnode: Devicetree node for this device. This is ofnode_null() for + * devices which don't use devicetree or don't have a node. * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ int device_bind(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, int of_offset, + const char *name, void *plat, ofnode node, struct udevice **devp); -int device_bind_ofnode(struct udevice *parent, const struct driver *drv, - const char *name, void *platdata, ofnode node, - struct udevice **devp); - /** * device_bind_with_driver_data() - Create a device and bind it to a driver * @@ -76,7 +72,7 @@ int device_bind_with_driver_data(struct udevice *parent, * @parent: Pointer to device's parent * @pre_reloc_only: If true, bind the driver only if its DM_FLAG_PRE_RELOC flag * is set. If false bind the driver always. - * @info: Name and platdata for this device + * @info: Name and plat for this device * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ @@ -93,7 +89,7 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, int device_reparent(struct udevice *dev, struct udevice *new_parent); /** - * device_ofdata_to_platdata() - Read platform data for a device + * device_of_to_plat() - Read platform data for a device * * Read platform data for a device (typically from the device tree) so that * the information needed to probe the device is present. @@ -106,7 +102,7 @@ int device_reparent(struct udevice *dev, struct udevice *new_parent); * @dev: Pointer to device to process * @return 0 if OK, -ve on error */ -int device_ofdata_to_platdata(struct udevice *dev); +int device_of_to_plat(struct udevice *dev); /** * device_probe() - Probe a device, activating it @@ -194,6 +190,90 @@ static inline int device_chld_remove(struct udevice *dev, struct driver *drv, #endif /** + * dev_set_priv() - Set the private data for a device + * + * This is normally handled by driver model, which automatically allocates + * private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev Device to check + * @priv New private-data pointer + */ +void dev_set_priv(struct udevice *dev, void *priv); + +/** + * dev_set_parent_priv() - Set the parent-private data for a device + * + * This is normally handled by driver model, which automatically allocates + * parent-private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @parent_priv: New parent-private data + */ +void dev_set_parent_priv(struct udevice *dev, void *parent_priv); + +/** + * dev_set_uclass_priv() - Set the uclass private data for a device + * + * This is normally handled by driver model, which automatically allocates + * uclass-private data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @uclass_priv: New uclass private data + */ +void dev_set_uclass_priv(struct udevice *dev, void *uclass_priv); + +/** + * dev_set_plat() - Set the platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev Device to check + * @plat New platform-data pointer + */ +void dev_set_plat(struct udevice *dev, void *priv); + +/** + * dev_set_parent_plat() - Set the parent platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * parent platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @parent_plat: New parent platform data + */ +void dev_set_parent_plat(struct udevice *dev, void *parent_plat); + +/** + * dev_set_uclass_plat() - Set the uclass platform data for a device + * + * This is normally handled by driver model, which automatically allocates + * uclass platform data when an 'auto' size if provided by the driver. + * + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @dev: Device to update + * @uclass_plat: New uclass platform data + */ +void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat); + +/** * simple_bus_translate() - translate a bus address to a system address * * This handles the 'ranges' property in a simple bus. It translates the @@ -208,6 +288,7 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr); /* Cast away any volatile pointer */ #define DM_ROOT_NON_CONST (((gd_t *)gd)->dm_root) #define DM_UCLASS_ROOT_NON_CONST (((gd_t *)gd)->uclass_root) +#define DM_UCLASS_ROOT_S_NON_CONST (((gd_t *)gd)->uclass_root_s) /* device resource management */ #ifdef CONFIG_DEVRES diff --git a/include/dm/device.h b/include/dm/device.h index 5bef484247..f5b4cd6876 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -23,16 +23,16 @@ struct driver_info; /* Driver is active (probed). Cleared when it is removed */ #define DM_FLAG_ACTIVATED (1 << 0) -/* DM is responsible for allocating and freeing platdata */ +/* DM is responsible for allocating and freeing plat */ #define DM_FLAG_ALLOC_PDATA (1 << 1) /* DM should init this device prior to relocation */ #define DM_FLAG_PRE_RELOC (1 << 2) -/* DM is responsible for allocating and freeing parent_platdata */ +/* DM is responsible for allocating and freeing parent_plat */ #define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3) -/* DM is responsible for allocating and freeing uclass_platdata */ +/* DM is responsible for allocating and freeing uclass_plat */ #define DM_FLAG_ALLOC_UCLASS_PDATA (1 << 4) /* Allocate driver private data on a DMA boundary */ @@ -64,7 +64,7 @@ struct driver_info; /* DM does not enable/disable the power domains corresponding to this device */ #define DM_FLAG_DEFAULT_PD_CTRL_OFF (1 << 11) -/* Driver platdata has been read. Cleared when the device is removed */ +/* Driver plat has been read. Cleared when the device is removed */ #define DM_FLAG_PLATDATA_VALID (1 << 12) /* @@ -104,36 +104,46 @@ enum { * particular port or peripheral (essentially a driver instance). * * A device will come into existence through a 'bind' call, either due to - * a U_BOOT_DEVICE() macro (in which case platdata is non-NULL) or a node + * a U_BOOT_DRVINFO() macro (in which case plat is non-NULL) or a node * in the device tree (in which case of_offset is >= 0). In the latter case - * we translate the device tree information into platdata in a function - * implemented by the driver ofdata_to_platdata method (called just before the + * we translate the device tree information into plat in a function + * implemented by the driver of_to_plat method (called just before the * probe method if the device has a device tree node. * - * All three of platdata, priv and uclass_priv can be allocated by the + * All three of plat, priv and uclass_priv can be allocated by the * driver, or you can use the auto_alloc_size members of struct driver and * struct uclass_driver to have driver model do this automatically. * * @driver: The driver used by this device * @name: Name of device, typically the FDT node name - * @platdata: Configuration data for this device - * @parent_platdata: The parent bus's configuration data for this device - * @uclass_platdata: The uclass's configuration data for this device - * @node: Reference to device tree node for this device + * @plat_: Configuration data for this device (do not access outside driver + * model) + * @parent_plat_: The parent bus's configuration data for this device (do not + * access outside driver model) + * @uclass_plat_: The uclass's configuration data for this device (do not access + * outside driver model) * @driver_data: Driver data word for the entry that matched this device with * its driver * @parent: Parent of this device, or NULL for the top level device - * @priv: Private data for this device + * @priv_: Private data for this device (do not access outside driver model) * @uclass: Pointer to uclass for this device - * @uclass_priv: The uclass's private data for this device - * @parent_priv: The parent's private data for this device + * @uclass_priv_: The uclass's private data for this device (do not access + * outside driver model) + * @parent_priv_: The parent's private data for this device (do not access + * outside driver model) * @uclass_node: Used by uclass to link its devices * @child_head: List of children of this device * @sibling_node: Next device in list of all devices - * @flags: Flags for this device DM_FLAG_... - * @req_seq: Requested sequence number for this device (-1 = any) - * @seq: Allocated sequence number for this device (-1 = none). This is set up - * when the device is probed and will be unique within the device's uclass. + * @flags_: Flags for this device DM_FLAG_... (do not access outside driver + * model) + * @seq_: Allocated sequence number for this device (-1 = none). This is set up + * when the device is bound and is unique within the device's uclass. If the + * device has an alias in the devicetree then that is used to set the sequence + * number. Otherwise, the next available number is used. Sequence numbers are + * used by certain commands that need device to be numbered (e.g. 'mmc dev'). + * (do not access outside driver model) + * @node_: Reference to device tree node for this device (do not access outside + * driver model) * @devres_head: List of memory allocations associated with this device. * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed @@ -142,22 +152,23 @@ enum { struct udevice { const struct driver *driver; const char *name; - void *platdata; - void *parent_platdata; - void *uclass_platdata; - ofnode node; + void *plat_; + void *parent_plat_; + void *uclass_plat_; ulong driver_data; struct udevice *parent; - void *priv; + void *priv_; struct uclass *uclass; - void *uclass_priv; - void *parent_priv; + void *uclass_priv_; + void *parent_priv_; struct list_head uclass_node; struct list_head child_head; struct list_head sibling_node; - uint32_t flags; - int req_seq; - int seq; + u32 flags_; + int seq_; +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + ofnode node_; +#endif #ifdef CONFIG_DEVRES struct list_head devres_head; #endif @@ -169,22 +180,67 @@ struct udevice { /* Returns the operations for a device */ #define device_get_ops(dev) (dev->driver->ops) +static inline u32 dev_get_flags(const struct udevice *dev) +{ + return dev->flags_; +} + +static inline void dev_or_flags(struct udevice *dev, u32 or) +{ + dev->flags_ |= or; +} + +static inline void dev_bic_flags(struct udevice *dev, u32 bic) +{ + dev->flags_ &= ~bic; +} + +/** + * dev_ofnode() - get the DT node reference associated with a udevice + * + * @dev: device to check + * @return reference of the the device's DT node + */ +static inline ofnode dev_ofnode(const struct udevice *dev) +{ +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + return dev->node_; +#else + return ofnode_null(); +#endif +} + /* Returns non-zero if the device is active (probed and not removed) */ -#define device_active(dev) ((dev)->flags & DM_FLAG_ACTIVATED) +#define device_active(dev) (dev_get_flags(dev) & DM_FLAG_ACTIVATED) static inline int dev_of_offset(const struct udevice *dev) { - return ofnode_to_offset(dev->node); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + return ofnode_to_offset(dev_ofnode(dev)); +#else + return -1; +#endif } -static inline void dev_set_of_offset(struct udevice *dev, int of_offset) +static inline bool dev_has_ofnode(const struct udevice *dev) { - dev->node = offset_to_ofnode(of_offset); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + return ofnode_valid(dev_ofnode(dev)); +#else + return false; +#endif } -static inline bool dev_has_of_node(struct udevice *dev) +static inline void dev_set_ofnode(struct udevice *dev, ofnode node) { - return ofnode_valid(dev->node); +#if !CONFIG_IS_ENABLED(OF_PLATDATA) + dev->node_ = node; +#endif +} + +static inline int dev_seq(const struct udevice *dev) +{ + return dev->seq_; } /** @@ -208,7 +264,7 @@ struct udevice_id { * * This holds methods for setting up a new device, and also removing it. * The device needs information to set itself up - this is provided either - * by platdata or a device tree node (which we find by looking up + * by plat or a device tree node (which we find by looking up * matching compatible strings with of_match). * * Drivers all belong to a uclass, representing a class of devices of the @@ -224,26 +280,26 @@ struct udevice_id { * @probe: Called to probe a device, i.e. activate it * @remove: Called to remove a device, i.e. de-activate it * @unbind: Called to unbind a device from its driver - * @ofdata_to_platdata: Called before probe to decode device tree data + * @of_to_plat: Called before probe to decode device tree data * @child_post_bind: Called after a new child has been bound * @child_pre_probe: Called before a child device is probed. The device has * memory allocated but it has not yet been probed. * @child_post_remove: Called after a child device is removed. The device * has memory allocated but its device_remove() method has been called. - * @priv_auto_alloc_size: If non-zero this is the size of the private data + * @priv_auto: If non-zero this is the size of the private data * to be allocated in the device's ->priv pointer. If zero, then the driver * is responsible for allocating any data required. - * @platdata_auto_alloc_size: If non-zero this is the size of the - * platform data to be allocated in the device's ->platdata pointer. + * @plat_auto: If non-zero this is the size of the + * platform data to be allocated in the device's ->plat pointer. * This is typically only useful for device-tree-aware drivers (those with - * an of_match), since drivers which use platdata will have the data - * provided in the U_BOOT_DEVICE() instantiation. - * @per_child_auto_alloc_size: Each device can hold private data owned by + * an of_match), since drivers which use plat will have the data + * provided in the U_BOOT_DRVINFO() instantiation. + * @per_child_auto: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero. - * @per_child_platdata_auto_alloc_size: A bus likes to store information about + * @per_child_plat_auto: A bus likes to store information about * its children. If non-zero this is the size of this data, to be allocated - * in the child's parent_platdata pointer. + * in the child's parent_plat pointer. * @ops: Driver-specific operations. This is typically a list of function * pointers defined by the driver, to implement driver functions required by * the uclass. @@ -259,14 +315,14 @@ struct driver { int (*probe)(struct udevice *dev); int (*remove)(struct udevice *dev); int (*unbind)(struct udevice *dev); - int (*ofdata_to_platdata)(struct udevice *dev); + int (*of_to_plat)(struct udevice *dev); int (*child_post_bind)(struct udevice *dev); int (*child_pre_probe)(struct udevice *dev); int (*child_post_remove)(struct udevice *dev); - int priv_auto_alloc_size; - int platdata_auto_alloc_size; - int per_child_auto_alloc_size; - int per_child_platdata_auto_alloc_size; + int priv_auto; + int plat_auto; + int per_child_auto; + int per_child_plat_auto; const void *ops; /* driver-specific operations */ uint32_t flags; #if CONFIG_IS_ENABLED(ACPIGEN) @@ -279,7 +335,7 @@ struct driver { ll_entry_declare(struct driver, __name, driver) /* Get a pointer to a given driver */ -#define DM_GET_DRIVER(__name) \ +#define DM_DRIVER_GET(__name) \ ll_entry_get(struct driver, __name, driver) /** @@ -287,37 +343,37 @@ struct driver { * produce no code but its information will be parsed by tools like * dtoc */ -#define U_BOOT_DRIVER_ALIAS(__name, __alias) +#define DM_DRIVER_ALIAS(__name, __alias) /** - * dev_get_platdata() - Get the platform data for a device + * dev_get_plat() - Get the platform data for a device * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check * @return platform data, or NULL if none */ -void *dev_get_platdata(const struct udevice *dev); +void *dev_get_plat(const struct udevice *dev); /** - * dev_get_parent_platdata() - Get the parent platform data for a device + * dev_get_parent_plat() - Get the parent platform data for a device * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check * @return parent's platform data, or NULL if none */ -void *dev_get_parent_platdata(const struct udevice *dev); +void *dev_get_parent_plat(const struct udevice *dev); /** - * dev_get_uclass_platdata() - Get the uclass platform data for a device + * dev_get_uclass_plat() - Get the uclass platform data for a device * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check * @return uclass's platform data, or NULL if none */ -void *dev_get_uclass_platdata(const struct udevice *dev); +void *dev_get_uclass_plat(const struct udevice *dev); /** * dev_get_priv() - Get the private data for a device @@ -444,24 +500,16 @@ int device_get_child_count(const struct udevice *parent); /** * device_find_child_by_seq() - Find a child device based on a sequence * - * This searches for a device with the given seq or req_seq. - * - * For seq, if an active device has this sequence it will be returned. - * If there is no such device then this will return -ENODEV. - * - * For req_seq, if a device (whether activated or not) has this req_seq - * value, that device will be returned. This is a strong indication that - * the device will receive that sequence when activated. + * This searches for a device with the given seq. * * @parent: Parent device - * @seq_or_req_seq: Sequence number to find (0=first) - * @find_req_seq: true to find req_seq, false to find seq + * @seq: Sequence number to find (0=first) * @devp: Returns pointer to device (there is only one per for each seq). * Set to NULL if none is found - * @return 0 if OK, -ve on error + * @return 0 if OK, -ENODEV if not found */ -int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp); +int device_find_child_by_seq(const struct udevice *parent, int seq, + struct udevice **devp); /** * device_get_child_by_seq() - Get a child device based on a sequence @@ -627,9 +675,9 @@ int device_find_child_by_name(const struct udevice *parent, const char *name, struct udevice **devp); /** - * device_first_child_ofdata_err() - Find the first child and reads its platdata + * device_first_child_ofdata_err() - Find the first child and reads its plat * - * The ofdata_to_platdata() method is called on the child before it is returned, + * The of_to_plat() method is called on the child before it is returned, * but the child is not probed. * * @parent: Parent to check @@ -640,9 +688,9 @@ int device_first_child_ofdata_err(struct udevice *parent, struct udevice **devp); /* - * device_next_child_ofdata_err() - Find the next child and read its platdata + * device_next_child_ofdata_err() - Find the next child and read its plat * - * The ofdata_to_platdata() method is called on the child before it is returned, + * The of_to_plat() method is called on the child before it is returned, * but the child is not probed. * * @devp: On entry, points to the previous child; on exit returns the child that @@ -803,19 +851,19 @@ static inline bool device_is_on_pci_bus(const struct udevice *dev) list_for_each_entry(pos, &parent->child_head, sibling_node) /** - * device_foreach_child_ofdata_to_platdata() - iterate through children + * device_foreach_child_of_to_plat() - iterate through children * * This stops when it gets an error, with @pos set to the device that failed to * read ofdata. * This creates a for() loop which works through the available children of * a device in order from start to end. Device ofdata is read by calling - * device_ofdata_to_platdata() on each one. The devices are not probed. + * device_of_to_plat() on each one. The devices are not probed. * * @pos: struct udevice * for the current device * @parent: parent device to scan */ -#define device_foreach_child_ofdata_to_platdata(pos, parent) \ +#define device_foreach_child_of_to_plat(pos, parent) \ for (int _ret = device_first_child_ofdata_err(parent, &dev); !_ret; \ _ret = device_next_child_ofdata_err(&dev)) diff --git a/include/dm/lists.h b/include/dm/lists.h index 810e244d9e..1a86552546 100644 --- a/include/dm/lists.h +++ b/include/dm/lists.h @@ -16,7 +16,7 @@ * lists_driver_lookup_name() - Return u_boot_driver corresponding to name * * This function returns a pointer to a driver given its name. This is used - * for binding a driver given its name and platdata. + * for binding a driver given its name and plat. * * @name: Name of driver to look up * @return pointer to driver, or NULL if not found @@ -35,7 +35,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id); /** * lists_bind_drivers() - search for and bind all drivers to parent * - * This searches the U_BOOT_DEVICE() structures and creates new devices for + * This searches the U_BOOT_DRVINFO() structures and creates new devices for * each one. The devices will have @parent as their parent. * * @parent: parent device (root) diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index ced7f6ffb2..5b088650d3 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -10,6 +10,7 @@ /* TODO(sjg@chromium.org): Drop fdtdec.h include */ #include <fdtdec.h> #include <dm/of.h> +#include <dm/of_access.h> #include <log.h> /* Enable checks to protect against invalid calls */ @@ -218,6 +219,18 @@ static inline ofnode ofnode_null(void) return node; } +static inline ofnode ofnode_root(void) +{ + ofnode node; + + if (of_live_active()) + node.np = gd_of_root(); + else + node.of_offset = 0; + + return node; +} + /** * ofnode_read_u32() - Read a 32-bit integer from a property * @@ -365,6 +378,49 @@ bool ofnode_read_bool(ofnode node, const char *propname); */ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name); +#if CONFIG_IS_ENABLED(DM_INLINE_OFNODE) +static inline bool ofnode_is_enabled(ofnode node) +{ + if (ofnode_is_np(node)) { + return of_device_is_available(ofnode_to_np(node)); + } else { + return fdtdec_get_is_enabled(gd->fdt_blob, + ofnode_to_offset(node)); + } +} + +static inline ofnode ofnode_first_subnode(ofnode node) +{ + assert(ofnode_valid(node)); + if (ofnode_is_np(node)) + return np_to_ofnode(node.np->child); + + return offset_to_ofnode( + fdt_first_subnode(gd->fdt_blob, ofnode_to_offset(node))); +} + +static inline ofnode ofnode_next_subnode(ofnode node) +{ + assert(ofnode_valid(node)); + if (ofnode_is_np(node)) + return np_to_ofnode(node.np->sibling); + + return offset_to_ofnode( + fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node))); +} +#else +/** + * ofnode_is_enabled() - Checks whether a node is enabled. + * This looks for a 'status' property. If this exists, then returns true if + * the status is 'okay' and false otherwise. If there is no status property, + * it returns true on the assumption that anything mentioned should be enabled + * by default. + * + * @node: node to examine + * @return false (not enabled) or true (enabled) + */ +bool ofnode_is_enabled(ofnode node); + /** * ofnode_first_subnode() - find the first subnode of a parent node * @@ -382,6 +438,7 @@ ofnode ofnode_first_subnode(ofnode node); * has no more siblings) */ ofnode ofnode_next_subnode(ofnode node); +#endif /* DM_INLINE_OFNODE */ /** * ofnode_get_parent() - get the ofnode's parent (enclosing ofnode) diff --git a/include/dm/pci.h b/include/dm/pci.h index 10f9fd9e37..bddacbf599 100644 --- a/include/dm/pci.h +++ b/include/dm/pci.h @@ -30,7 +30,7 @@ int pci_get_devfn(struct udevice *dev); * * This returns an int to avoid a dependency on pci.h * - * @reg: reg value from dt-platdata.c array (first member). This is not a + * @reg: reg value from dt-plat.c array (first member). This is not a * pointer type, since the caller may use fdt32_t or fdt64_t depending on * the address sizes. * @return device/function for that device (pci_dev_t format) diff --git a/include/dm/platdata.h b/include/dm/platdata.h index 216efa8ef7..3821a56f2c 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -20,15 +20,15 @@ * available). U-Boot's driver model uses device tree for configuration. * * @name: Driver name - * @platdata: Driver-specific platform data - * @platdata_size: Size of platform data structure + * @plat: Driver-specific platform data + * @plat_size: Size of platform data structure * @parent_idx: Index of the parent driver_info structure */ struct driver_info { const char *name; - const void *platdata; + const void *plat; #if CONFIG_IS_ENABLED(OF_PLATDATA) - unsigned short platdata_size; + unsigned short plat_size; short parent_idx; #endif }; @@ -56,46 +56,34 @@ struct driver_rt { * is not feasible (e.g. serial driver in SPL where <8KB of SRAM is * available). U-Boot's driver model uses device tree for configuration. * - * When of-platdata is in use, U_BOOT_DEVICE() cannot be used outside of the - * dt-platdata.c file created by dtoc + * When of-platdata is in use, U_BOOT_DRVINFO() cannot be used outside of the + * dt-plat.c file created by dtoc */ -#if CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(DT_PLATDATA_C) -#define U_BOOT_DEVICE(__name) _Static_assert(false, \ - "Cannot use U_BOOT_DEVICE with of-platdata. Please use devicetree instead") +#if CONFIG_IS_ENABLED(OF_PLATDATA) && !defined(DT_PLAT_C) +#define U_BOOT_DRVINFO(__name) _Static_assert(false, \ + "Cannot use U_BOOT_DRVINFO with of-platdata. Please use devicetree instead") #else -#define U_BOOT_DEVICE(__name) \ +#define U_BOOT_DRVINFO(__name) \ ll_entry_declare(struct driver_info, __name, driver_info) #endif /* Declare a list of devices. The argument is a driver_info[] array */ -#define U_BOOT_DEVICES(__name) \ +#define U_BOOT_DRVINFOS(__name) \ ll_entry_declare_list(struct driver_info, __name, driver_info) /** * Get a pointer to a given device info given its name * - * With the declaration U_BOOT_DEVICE(name), DM_GET_DEVICE(name) will return a + * With the declaration U_BOOT_DRVINFO(name), DM_DRVINFO_GET(name) will return a * pointer to the struct driver_info created by that declaration. * * if OF_PLATDATA is enabled, from this it is possible to use the @dev member of * struct driver_info to find the device pointer itself. * - * TODO(sjg@chromium.org): U_BOOT_DEVICE() tells U-Boot to create a device, so - * the naming seems sensible, but DM_GET_DEVICE() is a bit of misnomer, since it - * finds the driver_info record, not the device. - * * @__name: Driver name (C identifier, not a string. E.g. gpio7_at_ff7e0000) * @return struct driver_info * to the driver that created the device */ -#define DM_GET_DEVICE(__name) \ +#define DM_DRVINFO_GET(__name) \ ll_entry_get(struct driver_info, __name, driver_info) -/** - * dm_populate_phandle_data() - Populates phandle data in platda - * - * This populates phandle data with an U_BOOT_DEVICE entry get by - * DM_GET_DEVICE. The implementation of this function will be done - * by dtoc when parsing dtb. - */ -void dm_populate_phandle_data(void); #endif diff --git a/include/dm/platform_data/fsl_espi.h b/include/dm/platform_data/fsl_espi.h index 812933f51c..de2307f7fb 100644 --- a/include/dm/platform_data/fsl_espi.h +++ b/include/dm/platform_data/fsl_espi.h @@ -6,7 +6,7 @@ #ifndef __fsl_espi_h #define __fsl_espi_h -struct fsl_espi_platdata { +struct fsl_espi_plat { uint flags; uint speed_hz; uint num_chipselect; diff --git a/include/dm/platform_data/lpc32xx_hsuart.h b/include/dm/platform_data/lpc32xx_hsuart.h index 9bfd62833c..6f41e0e734 100644 --- a/include/dm/platform_data/lpc32xx_hsuart.h +++ b/include/dm/platform_data/lpc32xx_hsuart.h @@ -7,11 +7,11 @@ #define _LPC32XX_HSUART_PLAT_H /** - * struct lpc32xx_hsuart_platdata - NXP LPC32xx HSUART platform data + * struct lpc32xx_hsuart_plat - NXP LPC32xx HSUART platform data * * @base: Base register address */ -struct lpc32xx_hsuart_platdata { +struct lpc32xx_hsuart_plat { unsigned long base; }; diff --git a/include/dm/platform_data/pxa_mmc_gen.h b/include/dm/platform_data/pxa_mmc_gen.h index 9875bab2cf..d15c1551f4 100644 --- a/include/dm/platform_data/pxa_mmc_gen.h +++ b/include/dm/platform_data/pxa_mmc_gen.h @@ -9,7 +9,7 @@ #include <mmc.h> /* - * struct pxa_mmc_platdata - information about a PXA MMC controller + * struct pxa_mmc_plat - information about a PXA MMC controller * * @base: MMC controller base register address */ diff --git a/include/dm/platform_data/serial_bcm283x_mu.h b/include/dm/platform_data/serial_bcm283x_mu.h index 37f5174dbf..6c77272e80 100644 --- a/include/dm/platform_data/serial_bcm283x_mu.h +++ b/include/dm/platform_data/serial_bcm283x_mu.h @@ -14,7 +14,7 @@ * * @base: Register base address */ -struct bcm283x_mu_serial_platdata { +struct bcm283x_mu_serial_plat { unsigned long base; unsigned int clock; bool skip_init; diff --git a/include/dm/platform_data/serial_coldfire.h b/include/dm/platform_data/serial_coldfire.h index ba916fece3..5e265e9087 100644 --- a/include/dm/platform_data/serial_coldfire.h +++ b/include/dm/platform_data/serial_coldfire.h @@ -7,13 +7,13 @@ #define __serial_coldfire_h /* - * struct coldfire_serial_platdata - information about a coldfire port + * struct coldfire_serial_plat - information about a coldfire port * * @base: Uart port base register address * @port: Uart port index, for cpu with pinmux for uart / gpio * baudrtatre: Uart port baudrate */ -struct coldfire_serial_platdata { +struct coldfire_serial_plat { unsigned long base; int port; int baudrate; diff --git a/include/dm/platform_data/serial_mxc.h b/include/dm/platform_data/serial_mxc.h index 86cd3bcf62..cc59eeb1dd 100644 --- a/include/dm/platform_data/serial_mxc.h +++ b/include/dm/platform_data/serial_mxc.h @@ -7,7 +7,7 @@ #define __serial_mxc_h /* Information about a serial port */ -struct mxc_serial_platdata { +struct mxc_serial_plat { struct mxc_uart *reg; /* address of registers in physical memory */ bool use_dte; }; diff --git a/include/dm/platform_data/serial_pl01x.h b/include/dm/platform_data/serial_pl01x.h index 77d96c49f0..e3d4e308a1 100644 --- a/include/dm/platform_data/serial_pl01x.h +++ b/include/dm/platform_data/serial_pl01x.h @@ -20,7 +20,7 @@ enum pl01x_type { * @skip_init: Don't attempt to change port configuration (also means @clock * is ignored) */ -struct pl01x_serial_platdata { +struct pl01x_serial_plat { unsigned long base; enum pl01x_type type; unsigned int clock; diff --git a/include/dm/platform_data/serial_pxa.h b/include/dm/platform_data/serial_pxa.h index b78bdb6409..0d7dc4c462 100644 --- a/include/dm/platform_data/serial_pxa.h +++ b/include/dm/platform_data/serial_pxa.h @@ -40,13 +40,13 @@ #endif /* - * struct pxa_serial_platdata - information about a PXA port + * struct pxa_serial_plat - information about a PXA port * * @base: Uart port base register address * @port: Uart port index, for cpu with pinmux for uart / gpio * baudrtatre: Uart port baudrate */ -struct pxa_serial_platdata { +struct pxa_serial_plat { struct pxa_uart_regs *base; int port; int baudrate; diff --git a/include/dm/platform_data/serial_sh.h b/include/dm/platform_data/serial_sh.h index 711435d8f6..69cd012fc5 100644 --- a/include/dm/platform_data/serial_sh.h +++ b/include/dm/platform_data/serial_sh.h @@ -27,7 +27,7 @@ enum sh_serial_type { * @clk_mode: Clock mode, set internal (INT) or external (EXT) * @type: Type of SCIF */ -struct sh_serial_platdata { +struct sh_serial_plat { unsigned long base; unsigned int clk; enum sh_clk_mode clk_mode; diff --git a/include/dm/platform_data/spi_coldfire.h b/include/dm/platform_data/spi_coldfire.h index 8ad8eaedfd..da514bad0d 100644 --- a/include/dm/platform_data/spi_coldfire.h +++ b/include/dm/platform_data/spi_coldfire.h @@ -10,14 +10,14 @@ #define MAX_CTAR_FIELDS 8 /* - * struct coldfire_spi_platdata - information about a coldfire spi module + * struct coldfire_spi_plat - information about a coldfire spi module * * @regs_addr: base address for module registers * @speed_hz: default SCK frequency * @mode: default SPI mode * @num_cs: number of DSPI chipselect signals */ -struct coldfire_spi_platdata { +struct coldfire_spi_plat { fdt_addr_t regs_addr; uint speed_hz; uint mode; diff --git a/include/dm/platform_data/spi_davinci.h b/include/dm/platform_data/spi_davinci.h index fbc62c262a..42a467e40b 100644 --- a/include/dm/platform_data/spi_davinci.h +++ b/include/dm/platform_data/spi_davinci.h @@ -7,7 +7,7 @@ #ifndef __spi_davinci_h #define __spi_davinci_h -struct davinci_spi_platdata { +struct davinci_spi_plat { struct davinci_spi_regs *regs; u8 num_cs; /* total no. of CS available */ }; diff --git a/include/dm/platform_data/spi_pl022.h b/include/dm/platform_data/spi_pl022.h index 63a58ee453..7f74b3cbc5 100644 --- a/include/dm/platform_data/spi_pl022.h +++ b/include/dm/platform_data/spi_pl022.h @@ -3,8 +3,8 @@ * (C) Copyright 2018 * Quentin Schulz, Bootlin, quentin.schulz@bootlin.com * - * Structure for use with U_BOOT_DEVICE for pl022 SPI devices or to use - * in ofdata_to_platdata. + * Structure for use with U_BOOT_DRVINFO for pl022 SPI devices or to use + * in of_to_plat. */ #ifndef __spi_pl022_h diff --git a/include/dm/read.h b/include/dm/read.h index 0585eb1228..c875e11a13 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -21,7 +21,7 @@ struct resource; #if CONFIG_IS_ENABLED(OF_LIVE) static inline const struct device_node *dev_np(const struct udevice *dev) { - return ofnode_to_np(dev->node); + return ofnode_to_np(dev_ofnode(dev)); } #else static inline const struct device_node *dev_np(const struct udevice *dev) @@ -30,22 +30,6 @@ static inline const struct device_node *dev_np(const struct udevice *dev) } #endif -/** - * dev_ofnode() - get the DT node reference associated with a udevice - * - * @dev: device to check - * @return reference of the the device's DT node - */ -static inline ofnode dev_ofnode(const struct udevice *dev) -{ - return dev->node; -} - -static inline bool dev_of_valid(const struct udevice *dev) -{ - return ofnode_valid(dev_ofnode(dev)); -} - #ifndef CONFIG_DM_DEV_READ_INLINE /** @@ -694,6 +678,23 @@ int dev_get_child_count(const struct udevice *dev); */ int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res); +/** + * dev_decode_display_timing() - decode display timings + * + * Decode display timings from the supplied 'display-timings' node. + * See doc/device-tree-bindings/video/display-timing.txt for binding + * information. + * + * @dev: device to read DT display timings from. The node linked to the device + * contains a child node called 'display-timings' which in turn contains + * one or more display timing nodes. + * @index: index number to read (0=first timing subnode) + * @config: place to put timings + * @return 0 if OK, -FDT_ERR_NOTFOUND if not found + */ +int dev_decode_display_timing(const struct udevice *dev, int index, + struct display_timing *config); + #else /* CONFIG_DM_DEV_READ_INLINE is enabled */ static inline int dev_read_u32(const struct udevice *dev, @@ -1016,6 +1017,13 @@ static inline int dev_get_child_count(const struct udevice *dev) return ofnode_get_child_count(dev_ofnode(dev)); } +static inline int dev_decode_display_timing(const struct udevice *dev, + int index, + struct display_timing *config) +{ + return ofnode_decode_display_timing(dev_ofnode(dev), index, config); +} + #endif /* CONFIG_DM_DEV_READ_INLINE */ /** diff --git a/include/dm/root.h b/include/dm/root.h index c8d629ba9b..89afbee619 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -31,15 +31,15 @@ struct global_data; void dm_fixup_for_gd_move(struct global_data *new_gd); /** - * dm_scan_platdata() - Scan all platform data and bind drivers + * dm_scan_plat() - Scan all platform data and bind drivers * - * This scans all available platdata and creates drivers for each + * This scans all available plat and creates drivers for each * * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC * flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_scan_platdata(bool pre_reloc_only); +int dm_scan_plat(bool pre_reloc_only); /** * dm_scan_fdt() - Scan the device tree and bind drivers @@ -47,26 +47,24 @@ int dm_scan_platdata(bool pre_reloc_only); * This scans the device tree and creates a driver for each node. Only * the top-level subnodes are examined. * - * @blob: Pointer to device tree blob * @pre_reloc_only: If true, bind only nodes with special devicetree properties, * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_scan_fdt(const void *blob, bool pre_reloc_only); +int dm_scan_fdt(bool pre_reloc_only); /** - * dm_extended_scan_fdt() - Scan the device tree and bind drivers + * dm_extended_scan() - Scan the device tree and bind drivers * * This calls dm_scna_dft() which scans the device tree and creates a driver * for each node. the top-level subnodes are examined and also all sub-nodes * of "clocks" node. * - * @blob: Pointer to device tree blob * @pre_reloc_only: If true, bind only nodes with special devicetree properties, * or drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_extended_scan_fdt(const void *blob, bool pre_reloc_only); +int dm_extended_scan(bool pre_reloc_only); /** * dm_scan_other() - Scan for other devices diff --git a/include/dm/simple_bus.h b/include/dm/simple_bus.h new file mode 100644 index 0000000000..4ad4cc4051 --- /dev/null +++ b/include/dm/simple_bus.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 Google LLC + */ + +#ifndef __DM_SIMPLE_BUS_H +#define __DM_SIMPLE_BUS_H + +struct simple_bus_plat { + u32 base; + u32 size; + u32 target; +}; + +#endif diff --git a/include/dm/test.h b/include/dm/test.h index b2adce730a..6ac6672cd6 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -134,14 +134,12 @@ extern struct unit_test_state global_dm_test_state; * @testdev: Test device * @force_fail_alloc: Force all memory allocs to fail * @skip_post_probe: Skip uclass post-probe processing - * @removed: Used to keep track of a device that was removed */ struct dm_test_state { struct udevice *root; struct udevice *testdev; int force_fail_alloc; int skip_post_probe; - struct udevice *removed; }; /* Declare a new driver model test */ @@ -169,6 +167,24 @@ struct sandbox_sdl_plat { int font_size; }; +/** + * struct dm_test_parent_plat - Used to track state in bus tests + * + * @count: + * @bind_flag: Indicates that the child post-bind method was called + * @uclass_bind_flag: Also indicates that the child post-bind method was called + */ +struct dm_test_parent_plat { + int count; + int bind_flag; + int uclass_bind_flag; +}; + +enum { + TEST_FLAG_CHILD_PROBED = 10, + TEST_FLAG_CHILD_REMOVED = -7, +}; + /* Declare ping methods for the drivers */ int test_ping(struct udevice *dev, int pingval, int *pingret); int testfdt_ping(struct udevice *dev, int pingval, int *pingret); diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index e952a9967c..ae4425d7a5 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -16,6 +16,7 @@ enum uclass_id { UCLASS_DEMO, UCLASS_TEST, UCLASS_TEST_FDT, + UCLASS_TEST_FDT_MANUAL, UCLASS_TEST_BUS, UCLASS_TEST_PROBE, UCLASS_TEST_DUMMY, diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 6e3f15c2b0..c5a464be7c 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -12,17 +12,34 @@ #include <dm/ofnode.h> /** - * uclass_find_next_free_req_seq() - Get the next free req_seq number + * uclass_set_priv() - Set the private data for a uclass * - * This returns the next free req_seq number. This is useful only if - * OF_CONTROL is not used. The next free req_seq number is simply the - * maximum req_seq of the uclass + 1. - * This allows assiging req_seq number in the binding order. + * This is normally handled by driver model, which automatically allocates + * private data when an 'auto' size if provided by the uclass driver. * - * @id: Id number of the uclass - * @return The next free req_seq number + * Use this function to override normal operation for special situations, such + * as needing to allocate a variable amount of data. + * + * @uc Uclass to update + * @priv New private-data pointer */ -int uclass_find_next_free_req_seq(enum uclass_id id); +void uclass_set_priv(struct uclass *uc, void *priv); + +/** + * uclass_find_next_free_seq() - Get the next free sequence number + * + * This returns the next free sequence number. This is useful only if + * OF_CONTROL is not used. The next free sequence number is simply the + * maximum sequence number used by all devices in the uclass + 1. The value + * returned is always greater than the largest alias, if DM_SEQ_ALIAS is enabled + * and the uclass has the DM_UC_FLAG_SEQ_ALIAS flag. + * + * This allows assigning the sequence number in the binding order. + * + * @uc: uclass to check + * @return The next free sequence number + */ +int uclass_find_next_free_seq(struct uclass *uc); /** * uclass_get_device_tail() - handle the end of a get_device call @@ -103,25 +120,17 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, /** * uclass_find_device_by_seq() - Find uclass device based on ID and sequence * - * This searches for a device with the given seq or req_seq. - * - * For seq, if an active device has this sequence it will be returned. - * If there is no such device then this will return -ENODEV. - * - * For req_seq, if a device (whether activated or not) has this req_seq - * value, that device will be returned. This is a strong indication that - * the device will receive that sequence when activated. + * This searches for a device with the given seq. * * The device is NOT probed, it is merely returned. * * @id: ID to look up - * @seq_or_req_seq: Sequence number to find (0=first) - * @find_req_seq: true to find req_seq, false to find seq + * @seq: Sequence number to find (0=first) * @devp: Returns pointer to device (there is only one per for each seq) - * @return 0 if OK, -ve on error + * @return 0 if OK, -ENODEV if not found */ -int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp); +int uclass_find_device_by_seq(enum uclass_id id, int seq, + struct udevice **devp); /** * uclass_find_device_by_of_offset() - Find a uclass device by device tree node diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 7188304304..b5f066dbf4 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -24,7 +24,7 @@ * There may be drivers for on-chip SoC GPIO banks, I2C GPIO expanders and * PMIC IO lines, all made available in a unified way through the uclass. * - * @priv: Private data for this uclass + * @priv_: Private data for this uclass (do not access outside driver model) * @uc_drv: The driver for the uclass itself, not to be confused with a * 'struct driver' * @dev_head: List of devices in this uclass (devices are attached to their @@ -32,7 +32,7 @@ * @sibling_node: Next uclass in the linked list of uclasses */ struct uclass { - void *priv; + void *priv_; struct uclass_driver *uc_drv; struct list_head dev_head; struct list_head sibling_node; @@ -44,6 +44,9 @@ struct udevice; /* Members of this uclass sequence themselves with aliases */ #define DM_UC_FLAG_SEQ_ALIAS (1 << 0) +/* Members of this uclass without aliases don't get a sequence number */ +#define DM_UC_FLAG_NO_AUTO_SEQ (1 << 1) + /* Same as DM_FLAG_ALLOC_PRIV_DMA */ #define DM_UC_FLAG_ALLOC_PRIV_DMA (1 << 5) @@ -65,21 +68,21 @@ struct udevice; * @child_post_probe: Called after a child in this uclass is probed * @init: Called to set up the uclass * @destroy: Called to destroy the uclass - * @priv_auto_alloc_size: If non-zero this is the size of the private data + * @priv_auto: If non-zero this is the size of the private data * to be allocated in the uclass's ->priv pointer. If zero, then the uclass * driver is responsible for allocating any data required. - * @per_device_auto_alloc_size: Each device can hold private data owned + * @per_device_auto: Each device can hold private data owned * by the uclass. If required this will be automatically allocated if this * value is non-zero. - * @per_device_platdata_auto_alloc_size: Each device can hold platform data - * owned by the uclass as 'dev->uclass_platdata'. If the value is non-zero, + * @per_device_plat_auto: Each device can hold platform data + * owned by the uclass as 'dev->uclass_plat'. If the value is non-zero, * then this will be automatically allocated. - * @per_child_auto_alloc_size: Each child device (of a parent in this + * @per_child_auto: Each child device (of a parent in this * uclass) can hold parent data for the device/uclass. This value is only * used as a fallback if this member is 0 in the driver. - * @per_child_platdata_auto_alloc_size: A bus likes to store information about + * @per_child_plat_auto: A bus likes to store information about * its children. If non-zero this is the size of this data, to be allocated - * in the child device's parent_platdata pointer. This value is only used as + * in the child device's parent_plat pointer. This value is only used as * a fallback if this member is 0 in the driver. * @ops: Uclass operations, providing the consistent interface to devices * within the uclass. @@ -98,18 +101,26 @@ struct uclass_driver { int (*child_post_probe)(struct udevice *dev); int (*init)(struct uclass *class); int (*destroy)(struct uclass *class); - int priv_auto_alloc_size; - int per_device_auto_alloc_size; - int per_device_platdata_auto_alloc_size; - int per_child_auto_alloc_size; - int per_child_platdata_auto_alloc_size; + int priv_auto; + int per_device_auto; + int per_device_plat_auto; + int per_child_auto; + int per_child_plat_auto; const void *ops; uint32_t flags; }; /* Declare a new uclass_driver */ #define UCLASS_DRIVER(__name) \ - ll_entry_declare(struct uclass_driver, __name, uclass) + ll_entry_declare(struct uclass_driver, __name, uclass_driver) + +/** + * uclass_get_priv() - Get the private data for a uclass + * + * @uc Uclass to check + * @return private data, or NULL if none + */ +void *uclass_get_priv(const struct uclass *uc); /** * uclass_get() - Get a uclass based on an ID, creating it if needed @@ -253,7 +264,7 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent, * uclass_get_device_by_driver() - Get a uclass device for a driver * * This searches the devices in the uclass for one that uses the given - * driver. Use DM_GET_DRIVER(name) for the @drv argument, where 'name' is + * driver. Use DM_DRIVER_GET(name) for the @drv argument, where 'name' is * the driver name - as used in U_BOOT_DRIVER(name). * * The device is probed to activate it ready for use. @@ -366,21 +377,6 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data, struct udevice **devp); /** - * uclass_resolve_seq() - Resolve a device's sequence number - * - * On entry dev->seq is -1, and dev->req_seq may be -1 (to allocate a - * sequence number automatically, or >= 0 to select a particular number. - * If the requested sequence number is in use, then this device will - * be allocated another one. - * - * Note that the device's seq value is not changed by this function. - * - * @dev: Device for which to allocate sequence number - * @return sequence number allocated, or -ve on error - */ -int uclass_resolve_seq(struct udevice *dev); - -/** * uclass_id_foreach_dev() - Helper function to iteration through devices * * This creates a for() loop which works through the available devices in diff --git a/include/dt-bindings/bus/ti-sysc.h b/include/dt-bindings/bus/ti-sysc.h index 2c005376ac..eae4274543 100644 --- a/include/dt-bindings/bus/ti-sysc.h +++ b/include/dt-bindings/bus/ti-sysc.h @@ -15,6 +15,12 @@ /* SmartReflex sysc found on 36xx and later */ #define SYSC_OMAP3_SR_ENAWAKEUP (1 << 26) +#define SYSC_DRA7_MCAN_ENAWAKEUP (1 << 4) + +/* PRUSS sysc found on AM33xx/AM43xx/AM57xx */ +#define SYSC_PRUSS_SUB_MWAIT (1 << 5) +#define SYSC_PRUSS_STANDBY_INIT (1 << 4) + /* SYSCONFIG STANDBYMODE/MIDLEMODE/SIDLEMODE supported by hardware */ #define SYSC_IDLE_FORCE 0 #define SYSC_IDLE_NO 1 diff --git a/include/dwmmc.h b/include/dwmmc.h index d8a8355a0a..51ab74ead3 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -256,10 +256,10 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg) * ... * * Inside U_BOOT_DRIVER(): - * .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), + * .plat_auto = sizeof(struct rockchip_mmc_plat), * * To access platform data: - * struct rockchip_mmc_plat *plat = dev_get_platdata(dev); + * struct rockchip_mmc_plat *plat = dev_get_plat(dev); * * See rockchip_dw_mmc.c for an example. * diff --git a/include/efi_api.h b/include/efi_api.h index 5744f6aed8..ecb43a0607 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -217,6 +217,21 @@ enum efi_reset_type { #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 +#define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001 +#define CAPSULE_SUPPORT_DEPENDENCY 0x0000000000000002 + +#define EFI_CAPSULE_REPORT_GUID \ + EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \ + 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3) + +#define EFI_MEMORY_RANGE_CAPSULE_GUID \ + EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \ + 0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72) + +#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \ + EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ + 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a) + struct efi_capsule_header { efi_guid_t capsule_guid; u32 header_size; @@ -224,6 +239,54 @@ struct efi_capsule_header { u32 capsule_image_size; } __packed; +struct efi_capsule_result_variable_header { + u32 variable_total_size; + u32 reserved; + efi_guid_t capsule_guid; + struct efi_time capsule_processed; + efi_status_t capsule_status; +} __packed; + +struct efi_memory_range { + efi_physical_addr_t address; + u64 length; +}; + +struct efi_memory_range_capsule { + struct efi_capsule_header *header; + /* EFI_MEMORY_TYPE: 0x80000000-0xFFFFFFFF */ + enum efi_mem_type os_requested_memory_type; + u64 number_of_memory_ranges; + struct efi_memory_range memory_ranges[]; +} __packed; + +struct efi_firmware_management_capsule_header { + u32 version; + u16 embedded_driver_count; + u16 payload_item_count; + u64 item_offset_list[]; +} __packed; + +struct efi_firmware_management_capsule_image_header { + u32 version; + efi_guid_t update_image_type_id; + u8 update_image_index; + u8 reserved[3]; + u32 update_image_size; + u32 update_vendor_code_size; + u64 update_hardware_instance; + u64 image_capsule_support; +} __packed; + +struct efi_capsule_result_variable_fmp { + u16 version; + u8 payload_index; + u8 update_image_index; + efi_guid_t update_image_type_id; + // u16 capsule_file_name[]; + // u16 capsule_target[]; +} __packed; + #define EFI_RT_SUPPORTED_GET_TIME 0x0001 #define EFI_RT_SUPPORTED_SET_TIME 0x0002 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004 @@ -356,6 +419,10 @@ struct efi_runtime_services { EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, \ 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d) +#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \ + EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \ + 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25) + struct efi_configuration_table { efi_guid_t guid; void *table; @@ -1746,6 +1813,24 @@ struct efi_variable_authentication_2 { } __attribute__((__packed__)); /** + * efi_firmware_image_authentication - Capsule authentication method + * descriptor + * + * This structure describes an authentication information for + * a capsule with IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED set + * and should be included as part of the capsule. + * Only EFI_CERT_TYPE_PKCS7_GUID is accepted. + * + * @monotonic_count: Count to prevent replay + * @auth_info: Authentication info + */ +struct efi_firmware_image_authentication { + uint64_t monotonic_count; + struct win_certificate_uefi_guid auth_info; +} __attribute__((__packed__)); + + +/** * efi_signature_data - A format of signature * * This structure describes a single signature in signature database. @@ -1779,4 +1864,107 @@ struct efi_signature_list { /* struct efi_signature_data signatures[...][signature_size]; */ } __attribute__((__packed__)); +/* + * Firmware management protocol + */ +#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \ + EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \ + 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7) + +#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \ + EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \ + 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47) + +#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \ + EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \ + 0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f) + +#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001 +#define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 +#define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 +#define IMAGE_ATTRIBUTE_IN_USE 0x0000000000000008 +#define IMAGE_ATTRIBUTE_UEFI_IMAGE 0x0000000000000010 +#define IMAGE_ATTRIBUTE_DEPENDENCY 0x0000000000000020 + +#define IMAGE_COMPATIBILITY_CHECK_SUPPORTED 0x0000000000000001 + +#define IMAGE_UPDATABLE_VALID 0x0000000000000001 +#define IMAGE_UPDATABLE_INVALID 0x0000000000000002 +#define IMAGE_UPDATABLE_INVALID_TYPE 0x0000000000000004 +#define IMAGE_UPDATABLE_INVALID_OLLD 0x0000000000000008 +#define IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE 0x0000000000000010 + +#define PACKAGE_ATTRIBUTE_VERSION_UPDATABLE 0x0000000000000001 +#define PACKAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 +#define PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 + +#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION 4 + +typedef struct efi_firmware_image_dependencies { + u8 dependencies[0]; +} efi_firmware_image_dep_t; + +struct efi_firmware_image_descriptor { + u8 image_index; + efi_guid_t image_type_id; + u64 image_id; + u16 *image_id_name; + u32 version; + u16 *version_name; + efi_uintn_t size; + u64 attributes_supported; + u64 attributes_setting; + u64 compatibilities; + u32 lowest_supported_image_version; + u32 last_attempt_version; + u32 last_attempt_status; + u64 hardware_instance; + efi_firmware_image_dep_t *dependencies; +}; + +struct efi_firmware_management_protocol { + efi_status_t (EFIAPI *get_image_info)( + struct efi_firmware_management_protocol *this, + efi_uintn_t *image_info_size, + struct efi_firmware_image_descriptor *image_info, + u32 *descriptor_version, + u8 *descriptor_count, + efi_uintn_t *descriptor_size, + u32 *package_version, + u16 **package_version_name); + efi_status_t (EFIAPI *get_image)( + struct efi_firmware_management_protocol *this, + u8 image_index, + void *image, + efi_uintn_t *image_size); + efi_status_t (EFIAPI *set_image)( + struct efi_firmware_management_protocol *this, + u8 image_index, + const void *image, + efi_uintn_t image_size, + const void *vendor_code, + efi_status_t (*progress)(efi_uintn_t completion), + u16 **abort_reason); + efi_status_t (EFIAPI *check_image)( + struct efi_firmware_management_protocol *this, + u8 image_index, + const void *image, + efi_uintn_t *image_size, + u32 *image_updatable); + efi_status_t (EFIAPI *get_package_info)( + struct efi_firmware_management_protocol *this, + u32 *package_version, + u16 **package_version_name, + u32 *package_version_name_maxlen, + u64 *attributes_supported, + u64 *attributes_setting); + efi_status_t (EFIAPI *set_package_info)( + struct efi_firmware_management_protocol *this, + const void *image, + efi_uintn_t *image_size, + const void *vendor_code, + u32 package_version, + const u16 *package_version_name); +}; + #endif diff --git a/include/efi_loader.h b/include/efi_loader.h index 0fc2255f3f..4719fa93f0 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -195,6 +195,9 @@ extern const efi_guid_t efi_file_system_info_guid; extern const efi_guid_t efi_guid_device_path_utilities_protocol; /* GUID of the deprecated Unicode collation protocol */ extern const efi_guid_t efi_guid_unicode_collation_protocol; +/* GUIDs of the Load File and Load File2 protocol */ +extern const efi_guid_t efi_guid_load_file_protocol; +extern const efi_guid_t efi_guid_load_file2_protocol; /* GUID of the Unicode collation protocol */ extern const efi_guid_t efi_guid_unicode_collation_protocol2; extern const efi_guid_t efi_guid_hii_config_routing_protocol; @@ -210,6 +213,10 @@ extern const efi_guid_t efi_guid_cert_type_pkcs7; /* GUID of RNG protocol */ extern const efi_guid_t efi_guid_rng_protocol; +/* GUID of capsule update result */ +extern const efi_guid_t efi_guid_capsule_report; +/* GUID of firmware management protocol */ +extern const efi_guid_t efi_guid_firmware_management_protocol; extern unsigned int __efi_runtime_start, __efi_runtime_stop; extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; @@ -495,6 +502,11 @@ efi_status_t efi_search_protocol(const efi_handle_t handle, efi_status_t efi_add_protocol(const efi_handle_t handle, const efi_guid_t *protocol, void *protocol_interface); +/* Open protocol */ +efi_status_t efi_protocol_open(struct efi_handler *handler, + void **protocol_interface, void *agent_handle, + void *controller_handle, uint32_t attributes); + /* Delete protocol from a handle */ efi_status_t efi_remove_protocol(const efi_handle_t handle, const efi_guid_t *protocol, @@ -801,18 +813,50 @@ efi_status_t efi_image_region_add(struct efi_image_regions *regs, int nocheck); void efi_sigstore_free(struct efi_signature_store *sigstore); +struct efi_signature_store *efi_build_signature_store(void *sig_list, + efi_uintn_t size); struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name); bool efi_secure_boot_enabled(void); +bool efi_capsule_auth_enabled(void); + bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp, WIN_CERTIFICATE **auth, size_t *auth_len); +struct pkcs7_message *efi_parse_pkcs7_header(const void *buf, + size_t buflen, + u8 **tmpbuf); + /* runtime implementation of memcpy() */ void efi_memcpy_runtime(void *dest, const void *src, size_t n); /* commonly used helper function */ -u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int index); +u16 *efi_create_indexed_name(u16 *buffer, size_t buffer_size, const char *name, + unsigned int index); + +extern const struct efi_firmware_management_protocol efi_fmp_fit; +extern const struct efi_firmware_management_protocol efi_fmp_raw; + +/* Capsule update */ +efi_status_t EFIAPI efi_update_capsule( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 scatter_gather_list); +efi_status_t EFIAPI efi_query_capsule_caps( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 *maximum_capsule_size, + u32 *reset_type); + +efi_status_t efi_capsule_authenticate(const void *capsule, + efi_uintn_t capsule_size, + void **image, efi_uintn_t *image_size); + +#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" + +/* Hook at initialization */ +efi_status_t efi_launch_capsules(void); #else /* CONFIG_IS_ENABLED(EFI_LOADER) */ @@ -830,6 +874,10 @@ static inline void efi_set_bootdev(const char *dev, const char *devnr, const char *path) { } static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } static inline void efi_print_image_infos(void *pc) { } +static inline efi_status_t efi_launch_capsules(void) +{ + return EFI_SUCCESS; +} #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h index 86b8fe4c01..40e241ce31 100644 --- a/include/efi_tcg2.h +++ b/include/efi_tcg2.h @@ -17,6 +17,8 @@ /* TPMV2 only */ #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002 +#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001 +#define PE_COFF_IMAGE 0x0000000000000010 /* Algorithm Registry */ #define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001 @@ -25,6 +27,10 @@ #define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008 #define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010 +#define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1 + +#define TPM2_EVENT_LOG_SIZE CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE + typedef u32 efi_tcg_event_log_bitmap; typedef u32 efi_tcg_event_log_format; typedef u32 efi_tcg_event_algorithm_bitmap; @@ -65,6 +71,68 @@ struct efi_tcg2_boot_service_capability { sizeof(struct efi_tcg2_boot_service_capability) - \ offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks) +#define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03" +#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2 +#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0 +#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2 + +/** + * struct TCG_EfiSpecIdEventAlgorithmSize + * + * @algorithm_id: algorithm defined in enum tpm2_algorithms + * @digest_size: size of the algorithm + */ +struct tcg_efi_spec_id_event_algorithm_size { + u16 algorithm_id; + u16 digest_size; +} __packed; + +/** + * struct TCG_EfiSpecIDEventStruct + * + * @signature: signature, set to Spec ID Event03 + * @platform_class: class defined in TCG ACPI Specification + * Client Common Header. + * @spec_version_minor: minor version + * @spec_version_major: major version + * @spec_version_errata: major version + * @uintn_size: size of the efi_uintn_t fields used in various + * data structures used in this specification. + * 0x01 indicates u32 and 0x02 indicates u64 + * @number_of_algorithms: hashing algorithms used in this event log + * @digest_sizes: array of number_of_algorithms pairs + * 1st member defines the algorithm id + * 2nd member defines the algorithm size + * @vendor_info_size: size in bytes for vendor specific info + * @vendor_info: vendor specific info + */ +struct tcg_efi_spec_id_event { + u8 signature[16]; + u32 platform_class; + u8 spec_version_minor; + u8 spec_version_major; + u8 spec_errata; + u8 uintn_size; + u32 number_of_algorithms; + struct tcg_efi_spec_id_event_algorithm_size digest_sizes[TPM2_NUM_PCR_BANKS]; + u8 vendor_info_size; + /* U-Boot does not provide any vendor info */ + u8 vendor_info[]; +} __packed; + +/** + * struct tdEFI_TCG2_FINAL_EVENTS_TABLE + * @version: version number for this structure + * @number_of_events: number of events recorded after invocation of + * GetEventLog() + * @event: List of events of type tcg_pcr_event2 + */ +struct efi_tcg2_final_events_table { + u64 version; + u64 number_of_events; + struct tcg_pcr_event2 event[]; +}; + struct efi_tcg2_protocol { efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this, struct efi_tcg2_boot_service_capability *capability); @@ -73,7 +141,8 @@ struct efi_tcg2_protocol { u64 *event_log_location, u64 *event_log_last_entry, bool *event_log_truncated); efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this, - u64 flags, u64 data_to_hash, + u64 flags, + efi_physical_addr_t data_to_hash, u64 data_to_hash_len, struct efi_tcg2_event *efi_tcg_event); efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this, diff --git a/include/fat.h b/include/fat.h index 02742f92a5..b9f273f381 100644 --- a/include/fat.h +++ b/include/fat.h @@ -9,8 +9,9 @@ #ifndef _FAT_H_ #define _FAT_H_ -#include <asm/byteorder.h> #include <fs.h> +#include <asm/byteorder.h> +#include <asm/cache.h> struct disk_partition; @@ -21,7 +22,6 @@ struct disk_partition; #define MAX_CLUSTSIZE CONFIG_FS_FAT_MAX_CLUSTSIZE -#define DIRENTSPERBLOCK (mydata->sect_size / sizeof(dir_entry)) #define DIRENTSPERCLUST ((mydata->clust_size * mydata->sect_size) / \ sizeof(dir_entry)) @@ -179,6 +179,9 @@ typedef struct { int fats; /* Number of FATs */ } fsdata; +struct fat_itr; +typedef struct fat_itr fat_itr; + static inline u32 clust_to_sect(fsdata *fsdata, u32 clust) { return fsdata->data_begin + clust * fsdata->clust_size; @@ -208,4 +211,17 @@ void fat_closedir(struct fs_dir_stream *dirs); int fat_unlink(const char *filename); int fat_mkdir(const char *dirname); void fat_close(void); +void *fat_next_cluster(fat_itr *itr, unsigned int *nbytes); + +/** + * fat_uuid() - get FAT volume ID + * + * The FAT volume ID returned in @uuid_str as hexadecimal number in XXXX-XXXX + * format. + * + * @uuid_str: caller allocated buffer of at least 10 bytes for the volume ID + * Return: 0 on success + */ +int fat_uuid(char *uuid_str); + #endif /* _FAT_H_ */ diff --git a/include/fs_loader.h b/include/fs_loader.h index 1b3c58086f..8de7cb18dc 100644 --- a/include/fs_loader.h +++ b/include/fs_loader.h @@ -31,7 +31,7 @@ struct phandle_part { * @mtdpart: MTD partition for ubi partition. * @ubivol: UBI volume-name for ubifsmount. */ -struct device_platdata { +struct device_plat { struct phandle_part phandlepart; char *mtdpart; char *ubivol; diff --git a/include/i2c.h b/include/i2c.h index 880aa8032b..e45e33f503 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -71,7 +71,7 @@ struct udevice; * An I2C chip is a device on the I2C bus. It sits at a particular address * and normally supports 7-bit or 10-bit addressing. * - * To obtain this structure, use dev_get_parent_platdata(dev) where dev is + * To obtain this structure, use dev_get_parent_plat(dev) where dev is * the chip to examine. * * @chip_addr: Chip address on bus @@ -521,17 +521,17 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, struct udevice **devp); /** - * i2c_chip_ofdata_to_platdata() - Decode standard I2C platform data + * i2c_chip_of_to_plat() - Decode standard I2C platform data * * This decodes the chip address from a device tree node and puts it into * its dm_i2c_chip structure. This should be called in your driver's - * ofdata_to_platdata() method. + * of_to_plat() method. * * @blob: Device tree blob * @node: Node offset to read from * @spi: Place to put the decoded information */ -int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip); +int i2c_chip_of_to_plat(struct udevice *dev, struct dm_i2c_chip *chip); /** * i2c_dump_msgs() - Dump a list of I2C messages @@ -568,7 +568,7 @@ struct udevice *i2c_emul_get_device(struct udevice *emul); extern struct acpi_ops i2c_acpi_ops; /** - * acpi_i2c_ofdata_to_platdata() - Read properties intended for ACPI + * acpi_i2c_of_to_plat() - Read properties intended for ACPI * * This reads the generic I2C properties from the device tree, so that these * can be used to create ACPI information for the device. @@ -579,7 +579,7 @@ extern struct acpi_ops i2c_acpi_ops; * @dev: I2C device to process * @return 0 if OK, -EINVAL if acpi,hid is not present */ -int acpi_i2c_ofdata_to_platdata(struct udevice *dev); +int acpi_i2c_of_to_plat(struct udevice *dev); #ifndef CONFIG_DM_I2C diff --git a/include/image.h b/include/image.h index 41473dbb9c..856bc3e1b2 100644 --- a/include/image.h +++ b/include/image.h @@ -308,6 +308,7 @@ enum { IH_TYPE_IMX8MIMAGE, /* Freescale IMX8MBoot Image */ IH_TYPE_IMX8IMAGE, /* Freescale IMX8Boot Image */ IH_TYPE_COPRO, /* Coprocessor Image for remoteproc*/ + IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */ IH_TYPE_COUNT, /* Number of image types */ }; diff --git a/include/linker_lists.h b/include/linker_lists.h index d775d041e0..fd98ecd297 100644 --- a/include/linker_lists.h +++ b/include/linker_lists.h @@ -124,7 +124,8 @@ */ #define ll_entry_start(_type, _list) \ ({ \ - static char start[0] __aligned(4) __attribute__((unused, \ + static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __attribute__((unused, \ section(".u_boot_list_2_"#_list"_1"))); \ (_type *)&start; \ }) diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 79dce8f0ad..c871ea646d 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -76,6 +76,19 @@ struct clk_mux { extern const struct clk_ops clk_mux_ops; u8 clk_mux_get_parent(struct clk *clk); +/** + * clk_mux_index_to_val() - Convert the parent index to the register value + * + * It returns the value to write in the hardware register to output the selected + * input clock parent. + * + * @table: array of register values corresponding to the parent index (optional) + * @flags: hardware-specific flags + * @index: parent clock index + * @return the register value + */ +unsigned int clk_mux_index_to_val(u32 *table, unsigned int flags, u8 index); + struct clk_gate { struct clk clk; void __iomem *reg; @@ -125,6 +138,50 @@ struct clk_divider { #define CLK_DIVIDER_READ_ONLY BIT(5) #define CLK_DIVIDER_MAX_AT_ZERO BIT(6) extern const struct clk_ops clk_divider_ops; + +/** + * clk_divider_get_table_div() - convert the register value to the divider + * + * @table: array of register values corresponding to valid dividers + * @val: value to convert + * @return the divider + */ +unsigned int clk_divider_get_table_div(const struct clk_div_table *table, + unsigned int val); + +/** + * clk_divider_get_table_val() - convert the divider to the register value + * + * It returns the value to write in the hardware register to divide the input + * clock rate by @div. + * + * @table: array of register values corresponding to valid dividers + * @div: requested divider + * @return the register value + */ +unsigned int clk_divider_get_table_val(const struct clk_div_table *table, + unsigned int div); + +/** + * clk_divider_is_valid_div() - check if the divider is valid + * + * @table: array of valid dividers (optional) + * @div: divider to check + * @flags: hardware-specific flags + * @return true if the divider is valid, false otherwise + */ +bool clk_divider_is_valid_div(const struct clk_div_table *table, + unsigned int div, unsigned long flags); + +/** + * clk_divider_is_valid_table_div - check if the divider is in the @table array + * + * @table: array of valid dividers + * @div: divider to check + * @return true if the divider is found in the @table array, false otherwise + */ +bool clk_divider_is_valid_table_div(const struct clk_div_table *table, + unsigned int div); unsigned long divider_recalc_rate(struct clk *hw, unsigned long parent_rate, unsigned int val, const struct clk_div_table *table, @@ -144,7 +201,7 @@ struct clk_fixed_rate { unsigned long fixed_rate; }; -#define to_clk_fixed_rate(dev) ((struct clk_fixed_rate *)dev_get_platdata(dev)) +#define to_clk_fixed_rate(dev) ((struct clk_fixed_rate *)dev_get_plat(dev)) struct clk_composite { struct clk clk; diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 1b9151714c..927854950a 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -332,15 +332,14 @@ struct mtd_info { }; #if IS_ENABLED(CONFIG_DM) -static inline void mtd_set_of_node(struct mtd_info *mtd, - const struct device_node *np) +static inline void mtd_set_ofnode(struct mtd_info *mtd, ofnode node) { - mtd->dev->node.np = np; + dev_set_ofnode(mtd->dev, node); } -static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd) +static inline const ofnode mtd_get_ofnode(struct mtd_info *mtd) { - return mtd->dev->node.np; + return dev_ofnode(mtd->dev); } #else struct device_node; diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 13e8dd1103..7774c17ad5 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -389,6 +389,7 @@ static inline int nanddev_unregister(struct nand_device *nand) return mtd_device_unregister(nand->mtd); } +#ifndef __UBOOT__ /** * nanddev_set_of_node() - Attach a DT node to a NAND device * @nand: NAND device @@ -412,6 +413,19 @@ static inline const struct device_node *nanddev_get_of_node(struct nand_device * { return mtd_get_of_node(nand->mtd); } +#else +/** + * nanddev_set_of_node() - Attach a DT node to a NAND device + * @nand: NAND device + * @node: ofnode + * + * Attach a DT node to a NAND device. + */ +static inline void nanddev_set_ofnode(struct nand_device *nand, ofnode node) +{ + mtd_set_ofnode(nand->mtd, node); +} +#endif /* __UBOOT__ */ /** * nanddev_offs_to_pos() - Convert an absolute NAND offset into a NAND position diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 233fdc341a..4a8e19ee4f 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -258,11 +258,13 @@ struct flash_info; /* * TODO: Remove, once all users of spi_flash interface are moved to MTD * - * struct spi_flash { +struct spi_flash { * Defined below (keep this text to enable searching for spi_flash decl) * } */ +#ifndef DT_PLAT_C #define spi_flash spi_nor +#endif /** * struct spi_nor - Structure for defining a the SPI NOR layer @@ -352,6 +354,7 @@ struct spi_nor { u32 erase_size; }; +#ifndef __UBOOT__ static inline void spi_nor_set_flash_node(struct spi_nor *nor, const struct device_node *np) { @@ -363,6 +366,7 @@ device_node *spi_nor_get_flash_node(struct spi_nor *nor) { return mtd_get_of_node(&nor->mtd); } +#endif /* __UBOOT__ */ /** * struct spi_nor_hwcaps - Structure for describing the hardware capabilies diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index 88bacde91e..15bcd59f34 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -412,6 +412,7 @@ spinand_to_nand(struct spinand_device *spinand) return &spinand->base; } +#ifndef __UBOOT__ /** * spinand_set_of_node - Attach a DT node to a SPI NAND device * @spinand: SPI NAND device @@ -424,6 +425,20 @@ static inline void spinand_set_of_node(struct spinand_device *spinand, { nanddev_set_of_node(&spinand->base, np); } +#else +/** + * spinand_set_of_node - Attach a DT node to a SPI NAND device + * @spinand: SPI NAND device + * @node: ofnode + * + * Attach a DT node to a SPI NAND device. + */ +static inline void spinand_set_ofnode(struct spinand_device *spinand, + ofnode node) +{ + nanddev_set_ofnode(&spinand->base, node); +} +#endif /* __UBOOT__ */ int spinand_match_and_init(struct spinand_device *dev, const struct spinand_info *table, diff --git a/include/net.h b/include/net.h index aff6674bb3..13da69b7c1 100644 --- a/include/net.h +++ b/include/net.h @@ -115,7 +115,7 @@ enum eth_state_t { * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... * @max_speed: Maximum speed of Ethernet connection supported by MAC - * @priv_pdata: device specific platdata + * @priv_pdata: device specific plat */ struct eth_pdata { phys_addr_t iobase; diff --git a/include/ns16550.h b/include/ns16550.h index 18c9077755..bef2071998 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -21,6 +21,9 @@ * will not allocate storage for arrays of size 0 */ +#ifndef __ns16550_h +#define __ns16550_h + #include <linux/types.h> #ifdef CONFIG_DM_SERIAL @@ -56,7 +59,7 @@ enum ns16550_flags { }; /** - * struct ns16550_platdata - information about a NS16550 port + * struct ns16550_plat - information about a NS16550 port * * @base: Base register address * @reg_width: IO accesses size of registers (in bytes, 1 or 4) @@ -67,7 +70,7 @@ enum ns16550_flags { * @flags: A few flags (enum ns16550_flags) * @bdf: PCI slot/function (pci_dev_t) */ -struct ns16550_platdata { +struct ns16550_plat { unsigned long base; int reg_width; int reg_shift; @@ -82,7 +85,7 @@ struct ns16550_platdata { struct udevice; -struct NS16550 { +struct ns16550 { UART_REG(rbr); /* 0 */ UART_REG(ier); /* 1 */ UART_REG(fcr); /* 2 */ @@ -111,7 +114,7 @@ struct NS16550 { UART_REG(ssr); /* 11*/ #endif #ifdef CONFIG_DM_SERIAL - struct ns16550_platdata *plat; + struct ns16550_plat *plat; #endif }; @@ -120,8 +123,6 @@ struct NS16550 { #define dll rbr #define dlm ier -typedef struct NS16550 *NS16550_t; - /* * These are the definitions for the FIFO Control Register */ @@ -221,11 +222,11 @@ typedef struct NS16550 *NS16550_t; /* useful defaults for LCR */ #define UART_LCR_8N1 0x03 -void NS16550_init(NS16550_t com_port, int baud_divisor); -void NS16550_putc(NS16550_t com_port, char c); -char NS16550_getc(NS16550_t com_port); -int NS16550_tstc(NS16550_t com_port); -void NS16550_reinit(NS16550_t com_port, int baud_divisor); +void ns16550_init(struct ns16550 *com_port, int baud_divisor); +void ns16550_putc(struct ns16550 *com_port, char c); +char ns16550_getc(struct ns16550 *com_port); +int ns16550_tstc(struct ns16550 *com_port); +void ns16550_reinit(struct ns16550 *com_port, int baud_divisor); /** * ns16550_calc_divisor() - calculate the divisor given clock and baud rate @@ -238,10 +239,10 @@ void NS16550_reinit(NS16550_t com_port, int baud_divisor); * @baudrate: Required baud rate * @return baud rate divisor that should be used */ -int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate); +int ns16550_calc_divisor(struct ns16550 *port, int clock, int baudrate); /** - * ns16550_serial_ofdata_to_platdata() - convert DT to platform data + * ns16550_serial_of_to_plat() - convert DT to platform data * * Decode a device tree node for an ns16550 device. This includes the * register base address and register shift properties. The caller must set @@ -250,7 +251,7 @@ int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate); * @dev: dev to decode platform data for * @return: 0 if OK, -EINVAL on error */ -int ns16550_serial_ofdata_to_platdata(struct udevice *dev); +int ns16550_serial_of_to_plat(struct udevice *dev); /** * ns16550_serial_probe() - probe a serial port @@ -266,3 +267,5 @@ int ns16550_serial_probe(struct udevice *dev); * These should be used by the client driver for the driver's 'ops' member */ extern const struct dm_serial_ops ns16550_serial_ops; + +#endif /* __ns16550_h */ diff --git a/include/os.h b/include/os.h index 1fe44f3510..0913b47b3a 100644 --- a/include/os.h +++ b/include/os.h @@ -407,4 +407,21 @@ void *os_find_text_base(void); */ void os_relaunch(char *argv[]); +/** + * os_setup_signal_handlers() - setup signal handlers + * + * Install signal handlers for SIGBUS and SIGSEGV. + * + * Return: 0 for success + */ +int os_setup_signal_handlers(void); + +/** + * os_signal_action() - handle a signal + * + * @sig: signal + * @pc: program counter + */ +void os_signal_action(int sig, unsigned long pc); + #endif diff --git a/include/p2sb.h b/include/p2sb.h index a25170e3d1..ddbc8d5e14 100644 --- a/include/p2sb.h +++ b/include/p2sb.h @@ -17,11 +17,11 @@ #define PCH_P2SB_HBDF 0x70 /** - * struct p2sb_child_platdata - Information about each child of a p2sb device + * struct p2sb_child_plat - Information about each child of a p2sb device * * @pid: Port ID for this child */ -struct p2sb_child_platdata { +struct p2sb_child_plat { uint pid; }; diff --git a/include/pci.h b/include/pci.h index d1ccf6c963..5f36537b72 100644 --- a/include/pci.h +++ b/include/pci.h @@ -899,11 +899,11 @@ struct udevice; #ifdef CONFIG_DM_PCI /** - * struct pci_child_platdata - information stored about each PCI device + * struct pci_child_plat - information stored about each PCI device * * Every device on a PCI bus has this per-child data. * - * It can be accessed using dev_get_parent_platdata(dev) if dev->parent is a + * It can be accessed using dev_get_parent_plat(dev) if dev->parent is a * PCI bus (i.e. UCLASS_PCI) * * @devfn: Encoded device and function index - see PCI_DEVFN() @@ -914,7 +914,7 @@ struct udevice; * @pfdev: Handle to Physical Function device * @virtid: Virtual Function Index */ -struct pci_child_platdata { +struct pci_child_plat { int devfn; unsigned short vendor; unsigned short device; @@ -934,7 +934,7 @@ struct dm_pci_ops { * PCI buses must support reading and writing configuration values * so that the bus can be scanned and its devices configured. * - * Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always. + * Normally PCI_BUS(@bdf) is the same as @dev_seq(bus), but not always. * If bridges exist it is possible to use the top-level bus to * access a sub-bus. In that case @bus will be the top-level bus * and PCI_BUS(bdf) will be a different (higher) value diff --git a/include/power/acpi_pmc.h b/include/power/acpi_pmc.h index 222288b71a..64176d79bc 100644 --- a/include/power/acpi_pmc.h +++ b/include/power/acpi_pmc.h @@ -180,7 +180,7 @@ int pmc_disable_tco(struct udevice *dev); */ int pmc_global_reset_set_enable(struct udevice *dev, bool enable); -int pmc_ofdata_to_uc_platdata(struct udevice *dev); +int pmc_ofdata_to_uc_plat(struct udevice *dev); int pmc_disable_tco_base(ulong tco_base); diff --git a/include/power/regulator.h b/include/power/regulator.h index 7f278e8c7d..19a3b7b502 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -16,15 +16,15 @@ * 'UCLASS_REGULATOR' and the regulator driver API. * * The regulator uclass - is based on uclass platform data which is allocated, - * automatically for each regulator device on bind and 'dev->uclass_platdata' - * points to it. The data type is: 'struct dm_regulator_uclass_platdata'. + * automatically for each regulator device on bind and 'dev->uclass_plat' + * points to it. The data type is: 'struct dm_regulator_uclass_plat'. * The uclass file: 'drivers/power/regulator/regulator-uclass.c' * * The regulator device - is based on driver's model 'struct udevice'. * The API can use regulator name in two meanings: * - devname - the regulator device's name: 'dev->name' - * - platname - the device's platdata's name. So in the code it looks like: - * 'uc_pdata = dev->uclass_platdata'; 'name = uc_pdata->name'. + * - platname - the device's plat's name. So in the code it looks like: + * 'uc_pdata = dev->uclass_plat'; 'name = uc_pdata->name'. * * The regulator device driver - provide an implementation of uclass operations * pointed by 'dev->driver->ops' as a struct of type 'struct dm_regulator_ops'. @@ -135,7 +135,7 @@ enum regulator_flag { }; /** - * struct dm_regulator_uclass_platdata - pointed by dev->uclass_platdata, and + * struct dm_regulator_uclass_plat - pointed by dev->uclass_plat, and * allocated on each regulator bind. This structure holds an information * about each regulator's constraints and supported operation modes. * There is no "step" voltage value - so driver should take care of this. @@ -162,7 +162,7 @@ enum regulator_flag { * The constraints: type, mode, mode_count, can be set by device driver, e.g. * by the driver '.probe' method. */ -struct dm_regulator_uclass_platdata { +struct dm_regulator_uclass_plat { enum regulator_type type; struct dm_regulator_mode *mode; int mode_count; @@ -422,7 +422,7 @@ int regulators_enable_boot_on(bool verbose); * regulator_autoset: setup the voltage/current on a regulator * * The setup depends on constraints found in device's uclass's platform data - * (struct dm_regulator_uclass_platdata): + * (struct dm_regulator_uclass_plat): * * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, * or if both are unset, then the function returns @@ -431,7 +431,7 @@ int regulators_enable_boot_on(bool verbose); * * The function returns on the first-encountered error. * - * @platname - expected string for dm_regulator_uclass_platdata .name field + * @platname - expected string for dm_regulator_uclass_plat .name field * @devp - returned pointer to the regulator device - if non-NULL passed * @return: 0 on success or negative value of errno. */ @@ -440,7 +440,7 @@ int regulator_autoset(struct udevice *dev); /** * regulator_autoset_by_name: setup the regulator given by its uclass's * platform data name field. The setup depends on constraints found in device's - * uclass's platform data (struct dm_regulator_uclass_platdata): + * uclass's platform data (struct dm_regulator_uclass_plat): * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, * or if both are unset, then the function returns * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal @@ -448,7 +448,7 @@ int regulator_autoset(struct udevice *dev); * * The function returns on first encountered error. * - * @platname - expected string for dm_regulator_uclass_platdata .name field + * @platname - expected string for dm_regulator_uclass_plat .name field * @devp - returned pointer to the regulator device - if non-NULL passed * @return: 0 on success or negative value of errno. * @@ -464,7 +464,7 @@ int regulator_autoset_by_name(const char *platname, struct udevice **devp); * regulator_autoset_by_name() for each name from the list. * * @list_platname - an array of expected strings for .name field of each - * regulator's uclass platdata + * regulator's uclass plat * @list_devp - an array of returned pointers to the successfully setup * regulator devices if non-NULL passed * @verbose - (true/false) print each regulator setup info, or be quiet @@ -499,9 +499,9 @@ int regulator_get_by_devname(const char *devname, struct udevice **devp); /** * regulator_get_by_platname: returns the pointer to the pmic regulator device. - * Search by name, found in regulator uclass platdata. + * Search by name, found in regulator uclass plat. * - * @platname - expected string for uc_pdata->name of regulator uclass platdata + * @platname - expected string for uc_pdata->name of regulator uclass plat * @devp - returns pointer to the regulator device or NULL on error * @return 0 on success or negative value of errno. * diff --git a/include/regmap.h b/include/regmap.h index c6258face3..8216de015d 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -373,7 +373,7 @@ int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val); int regmap_init_mem(ofnode node, struct regmap **mapp); /** - * regmap_init_mem_platdata() - Set up a new memory register map for + * regmap_init_mem_plat() - Set up a new memory register map for * of-platdata * * @dev: Device that uses this map @@ -388,8 +388,8 @@ int regmap_init_mem(ofnode node, struct regmap **mapp); * Use regmap_uninit() to free it. * */ -int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count, - struct regmap **mapp); +int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count, + struct regmap **mapp); int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index); diff --git a/include/remoteproc.h b/include/remoteproc.h index 74d01723f6..089131f65f 100644 --- a/include/remoteproc.h +++ b/include/remoteproc.h @@ -34,7 +34,7 @@ enum rproc_mem_type { * @mem_type: one of 'enum rproc_mem_type' * @driver_plat_data: driver specific platform data that may be needed. * - * This can be accessed with dev_get_uclass_platdata() for any UCLASS_REMOTEPROC + * This can be accessed with dev_get_uclass_plat() for any UCLASS_REMOTEPROC * device. * */ diff --git a/include/scsi.h b/include/scsi.h index 96cb726676..90cec99e32 100644 --- a/include/scsi.h +++ b/include/scsi.h @@ -162,14 +162,14 @@ struct scsi_cmd { #define SCSI_WRITE_SAME 0x41 /* Write Same (O) */ /** - * struct scsi_platdata - stores information about SCSI controller + * struct scsi_plat - stores information about SCSI controller * * @base: Controller base address * @max_lun: Maximum number of logical units * @max_id: Maximum number of target ids * @max_bytes_per_req: Maximum number of bytes per read/write request */ -struct scsi_platdata { +struct scsi_plat { unsigned long base; unsigned long max_lun; unsigned long max_id; diff --git a/include/sdhci.h b/include/sdhci.h index 1fd20ec086..3e5a649818 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -440,10 +440,10 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg) * ... * * Inside U_BOOT_DRIVER(): - * .platdata_auto_alloc_size = sizeof(struct msm_sdhc_plat), + * .plat_auto = sizeof(struct msm_sdhc_plat), * * To access platform data: - * struct msm_sdhc_plat *plat = dev_get_platdata(dev); + * struct msm_sdhc_plat *plat = dev_get_plat(dev); * * See msm_sdhci.c for an example. * diff --git a/include/search.h b/include/search.h index e56843c26f..d0bb44388e 100644 --- a/include/search.h +++ b/include/search.h @@ -80,7 +80,16 @@ int hsearch_r(struct env_entry item, enum env_action action, int hmatch_r(const char *match, int last_idx, struct env_entry **retval, struct hsearch_data *htab); -/* Search and delete entry matching "key" in internal hash table. */ +/** + * hdelete_r() - Search and delete entry in internal hash table + * + * @key: Name of entry to delete + * @htab: Hash table + * @flag: Flags to use (H_...) + * @return 0 on success, -ENOENT if not found, -EPERM if the hash table callback + * rejected changing the variable, -EINVAL if the hash table refused to + * delete the variable + */ int hdelete_r(const char *key, struct hsearch_data *htab, int flag); ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, diff --git a/include/spi.h b/include/spi.h index 2d34e4af11..dc3b21132a 100644 --- a/include/spi.h +++ b/include/spi.h @@ -39,17 +39,30 @@ #define SPI_DEFAULT_WORDLEN 8 -/* TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave */ +/** + * struct dm_spi_bus - SPI bus info + * + * This contains information about a SPI bus. To obtain this structure, use + * dev_get_uclass_priv(bus) where bus is the SPI bus udevice. + * + * @max_hz: Maximum speed that the bus can tolerate. + * @speed: Current bus speed. This is 0 until the bus is first claimed. + * @mode: Current bus mode. This is 0 until the bus is first claimed. + * + * TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave. + */ struct dm_spi_bus { uint max_hz; + uint speed; + uint mode; }; /** - * struct dm_spi_platdata - platform data for all SPI slaves + * struct dm_spi_plat - platform data for all SPI slaves * * This describes a SPI slave, a child device of the SPI bus. To obtain this - * struct from a spi_slave, use dev_get_parent_platdata(dev) or - * dev_get_parent_platdata(slave->dev). + * struct from a spi_slave, use dev_get_parent_plat(dev) or + * dev_get_parent_plat(slave->dev). * * This data is immutable. Each time the device is probed, @max_hz and @mode * will be copied to struct spi_slave. @@ -58,7 +71,7 @@ struct dm_spi_bus { * @max_hz: Maximum bus speed that this slave can tolerate * @mode: SPI mode to use for this device (see SPI mode flags) */ -struct dm_spi_slave_platdata { +struct dm_spi_slave_plat { unsigned int cs; uint max_hz; uint mode; @@ -102,7 +115,7 @@ enum spi_polarity { * * For driver model this is the per-child data used by the SPI bus. It can * be accessed using dev_get_parent_priv() on the slave device. The SPI uclass - * sets uip per_child_auto_alloc_size to sizeof(struct spi_slave), and the + * sets up per_child_auto to sizeof(struct spi_slave), and the * driver should not override it. Two platform data fields (max_hz and mode) * are copied into this structure to provide an initial value. This allows * them to be changed, since we should never change platform data in drivers. @@ -112,11 +125,9 @@ enum spi_polarity { * * @dev: SPI slave device * @max_hz: Maximum speed for this slave - * @speed: Current bus speed. This is 0 until the bus is first - * claimed. * @bus: ID of the bus that the slave is attached to. For * driver model this is the sequence number of the SPI - * bus (bus->seq) so does not need to be stored + * bus (dev_seq(bus)) so does not need to be stored * @cs: ID of the chip select connected to the slave. * @mode: SPI mode to use for this slave (see SPI mode flags) * @wordlen: Size of SPI word in number of bits @@ -131,7 +142,6 @@ struct spi_slave { #if CONFIG_IS_ENABLED(DM_SPI) struct udevice *dev; /* struct spi_slave is dev->parentdata */ uint max_hz; - uint speed; #else unsigned int bus; unsigned int cs; @@ -566,12 +576,12 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp, * is automatically bound on this chip select with requested speed and mode. * * Ths new slave device is probed ready for use with the speed and mode - * from platdata when available or the requested values. + * from plat when available or the requested values. * * @busnum: SPI bus number * @cs: Chip select to look for - * @speed: SPI speed to use for this slave when not available in platdata - * @mode: SPI mode to use for this slave when not available in platdata + * @speed: SPI speed to use for this slave when not available in plat + * @mode: SPI mode to use for this slave when not available in plat * @drv_name: Name of driver to attach to this chip select * @dev_name: Name of the new device thus created * @busp: Returns bus device @@ -601,7 +611,7 @@ int spi_chip_select(struct udevice *slave); int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp); /** - * spi_slave_ofdata_to_platdata() - decode standard SPI platform data + * spi_slave_of_to_plat() - decode standard SPI platform data * * This decodes the speed and mode for a slave from a device tree node * @@ -609,8 +619,7 @@ int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp); * @node: Node offset to read from * @plat: Place to put the decoded information */ -int spi_slave_ofdata_to_platdata(struct udevice *dev, - struct dm_spi_slave_platdata *plat); +int spi_slave_of_to_plat(struct udevice *dev, struct dm_spi_slave_plat *plat); /** * spi_cs_info() - Check information on a chip select diff --git a/include/spl.h b/include/spl.h index b72dfc7e3d..a7648787b7 100644 --- a/include/spl.h +++ b/include/spl.h @@ -285,7 +285,15 @@ u32 spl_mmc_boot_mode(const u32 boot_device); * If not overridden, it is weakly defined in common/spl/spl_mmc.c. */ int spl_mmc_boot_partition(const u32 boot_device); -void spl_set_bd(void); + +/** + * spl_alloc_bd() - Allocate space for bd_info + * + * This sets up the gd->bd pointer by allocating memory for it + * + * @return 0 if OK, -ENOMEM if out of memory + */ +int spl_alloc_bd(void); /** * spl_set_header_raw_uboot() - Set up a standard SPL image structure @@ -526,26 +534,80 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image, void spl_invoke_atf(struct spl_image_info *spl_image); /** - * bl2_plat_get_bl31_params() - prepare params for bl31. - * @bl32_entry address of BL32 executable (secure) - * @bl33_entry address of BL33 executable (non secure) - * @fdt_addr address of Flat Device Tree + * bl2_plat_get_bl31_params() - return params for bl31. + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree + * + * This is a weak function which might be overridden by the board code. By + * default it will just call bl2_plat_get_bl31_params_default(). * - * This function assigns a pointer to the memory that the platform has kept - * aside to pass platform specific and trusted firmware related information - * to BL31. This memory is allocated by allocating memory to - * bl2_to_bl31_params_mem structure which is a superset of all the - * structure whose information is passed to BL31 - * NOTE: This function should be called only once and should be done - * before generating params to BL31 + * If you just want to manipulate or add some parameters, you can override + * this function, call bl2_plat_get_bl31_params_default and operate on the + * returned bl31 params. * - * @return bl31 params structure pointer + * Return: bl31 params structure pointer */ struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry, uintptr_t bl33_entry, uintptr_t fdt_addr); /** + * bl2_plat_get_bl31_params_default() - prepare params for bl31. + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree + * + * This is the default implementation of bl2_plat_get_bl31_params(). It assigns + * a pointer to the memory that the platform has kept aside to pass platform + * specific and trusted firmware related information to BL31. This memory is + * allocated by allocating memory to bl2_to_bl31_params_mem structure which is + * a superset of all the structure whose information is passed to BL31 + * + * NOTE: The memory is statically allocated, thus this function should be + * called only once. All subsequent calls will overwrite any changes. + * + * Return: bl31 params structure pointer + */ +struct bl31_params *bl2_plat_get_bl31_params_default(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr); + +/** + * bl2_plat_get_bl31_params_v2() - return params for bl31 + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree + * + * This function does the same as bl2_plat_get_bl31_params() except that is is + * used for the new LOAD_IMAGE_V2 option, which uses a slightly different + * method to pass the parameters. + * + * Return: bl31 params structure pointer + */ +struct bl_params *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr); + +/** + * bl2_plat_get_bl31_params_v2_default() - prepare params for bl31. + * @bl32_entry: address of BL32 executable (secure) + * @bl33_entry: address of BL33 executable (non secure) + * @fdt_addr: address of Flat Device Tree + * + * This is the default implementation of bl2_plat_get_bl31_params_v2(). It + * prepares the linked list of the bl31 params, populates the image types and + * set the entry points for bl32 and bl33 (if available). + * + * NOTE: The memory is statically allocated, thus this function should be + * called only once. All subsequent calls will overwrite any changes. + * + * Return: bl31 params structure pointer + */ +struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry, + uintptr_t bl33_entry, + uintptr_t fdt_addr); +/** * spl_optee_entry - entry function for optee * * args defind in op-tee project diff --git a/include/sunxi_image.h b/include/sunxi_image.h new file mode 100644 index 0000000000..5b2055c0af --- /dev/null +++ b/include/sunxi_image.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2007-2011 + * Allwinner Technology Co., Ltd. <www.allwinnertech.com> + * Tom Cubie <tangliang@allwinnertech.com> + * + * Constants and data structures used in Allwinner "eGON" images, as + * parsed by the Boot-ROM. + * + * Shared between mkimage and the SPL. + */ +#ifndef SUNXI_IMAGE_H +#define SUNXI_IMAGE_H + +#define BOOT0_MAGIC "eGON.BT0" +#define BROM_STAMP_VALUE 0x5f0a6c39 +#define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */ +#define SPL_MAJOR_BITS 3 +#define SPL_MINOR_BITS 5 +#define SPL_VERSION(maj, min) \ + ((((maj) & ((1U << SPL_MAJOR_BITS) - 1)) << SPL_MINOR_BITS) | \ + ((min) & ((1U << SPL_MINOR_BITS) - 1))) + +#define SPL_HEADER_VERSION SPL_VERSION(0, 2) + +#define SPL_ENV_HEADER_VERSION SPL_VERSION(0, 1) +#define SPL_DT_HEADER_VERSION SPL_VERSION(0, 2) +#define SPL_DRAM_HEADER_VERSION SPL_VERSION(0, 3) + +/* boot head definition from sun4i boot code */ +struct boot_file_head { + uint32_t b_instruction; /* one intruction jumping to real code */ + uint8_t magic[8]; /* ="eGON.BT0" or "eGON.BT1", not C-style str */ + uint32_t check_sum; /* generated by PC */ + uint32_t length; /* generated by PC */ + /* + * We use a simplified header, only filling in what is needed + * by the boot ROM. To be compatible with Allwinner tools we + * would need to implement the proper fields here instead of + * padding. + * + * Actually we want the ability to recognize our "sunxi" variant + * of the SPL. To do so, let's place a special signature into the + * "pub_head_size" field. We can reasonably expect Allwinner's + * boot0 to always have the upper 16 bits of this set to 0 (after + * all the value shouldn't be larger than the limit imposed by + * SRAM size). + * If the signature is present (at 0x14), then we know it's safe + * to use the remaining 8 bytes (at 0x18) for our own purposes. + * (E.g. sunxi-tools "fel" utility can pass information there.) + */ + union { + uint32_t pub_head_size; + uint8_t spl_signature[4]; + }; + uint32_t fel_script_address; /* since v0.1, set by sunxi-fel */ + /* + * If the fel_uEnv_length member below is set to a non-zero value, + * it specifies the size (byte count) of data at fel_script_address. + * At the same time this indicates that the data is in uEnv.txt + * compatible format, ready to be imported via "env import -t". + */ + uint32_t fel_uEnv_length; /* since v0.1, set by sunxi-fel */ + /* + * Offset of an ASCIIZ string (relative to the SPL header), which + * contains the default device tree name (CONFIG_DEFAULT_DEVICE_TREE). + * This is optional and may be set to NULL. Is intended to be used + * by flash programming tools for providing nice informative messages + * to the users. + */ + uint32_t dt_name_offset; /* since v0.2, set by mksunxiboot */ + uint32_t dram_size; /* in MiB, since v0.3, set by SPL */ + uint32_t boot_media; /* written here by the boot ROM */ + /* A padding area (may be used for storing text strings) */ + uint32_t string_pool[13]; /* since v0.2, filled by mksunxiboot */ + /* The header must be a multiple of 32 bytes (for VBAR alignment) */ +}; + +/* Compile time check to assure proper alignment of structure */ +typedef char boot_file_head_not_multiple_of_32[1 - 2*(sizeof(struct boot_file_head) % 32)]; + +#endif diff --git a/include/syscon.h b/include/syscon.h index 3df96e3276..2e02199c05 100644 --- a/include/syscon.h +++ b/include/syscon.h @@ -33,7 +33,7 @@ struct syscon_ops { * * Update: 64-bit is now supported and we have an education crisis. */ -struct syscon_base_platdata { +struct syscon_base_plat { fdt_val_t reg[2]; }; #endif diff --git a/include/test/suites.h b/include/test/suites.h index ab7b3bd9ca..52e8fc8155 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -26,6 +26,7 @@ int cmd_ut_category(const char *name, const char *prefix, struct unit_test *tests, int n_ents, int argc, char *const argv[]); +int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc, @@ -38,6 +39,8 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_time(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/include/test/test.h b/include/test/test.h index 03e29290bf..3fdaa2b5e5 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -95,6 +95,15 @@ enum { }; /** + * testbus_get_clear_removed() - Test function to obtain removed device + * + * This is used in testbus to find out which device was removed. Calling this + * function returns a pointer to the device and then clears it back to NULL, so + * that a future test can check it. + */ +struct udevice *testbus_get_clear_removed(void); + +/** * dm_test_main() - Run driver model tests * * Run all the available driver model tests, or a selection diff --git a/include/tpm-v2.h b/include/tpm-v2.h index 74c14fe7c5..fab6b86ca2 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -18,6 +18,12 @@ #define TPM2_DIGEST_LEN 32 +#define TPM2_SHA1_DIGEST_SIZE 20 +#define TPM2_SHA256_DIGEST_SIZE 32 +#define TPM2_SHA384_DIGEST_SIZE 48 +#define TPM2_SHA512_DIGEST_SIZE 64 +#define TPM2_SM3_256_DIGEST_SIZE 32 + #define TPM2_MAX_PCRS 32 #define TPM2_PCR_SELECT_MAX ((TPM2_MAX_PCRS + 7) / 8) #define TPM2_MAX_CAP_BUFFER 1024 @@ -45,6 +51,15 @@ #define TPM2_PT_MAX_COMMAND_SIZE (u32)(TPM2_PT_FIXED + 30) #define TPM2_PT_MAX_RESPONSE_SIZE (u32)(TPM2_PT_FIXED + 31) +/* event types */ +#define EV_POST_CODE ((u32)0x00000001) +#define EV_NO_ACTION ((u32)0x00000003) +#define EV_SEPARATOR ((u32)0x00000004) +#define EV_S_CRTM_CONTENTS ((u32)0x00000007) +#define EV_S_CRTM_VERSION ((u32)0x00000008) +#define EV_CPU_MICROCODE ((u32)0x00000009) +#define EV_TABLE_OF_DEVICES ((u32)0x0000000B) + /* TPMS_TAGGED_PROPERTY Structure */ struct tpms_tagged_property { u32 property; @@ -87,6 +102,73 @@ struct tpms_capability_data { } __packed; /** + * SHA1 Event Log Entry Format + * + * @pcr_index: PCRIndex event extended to + * @event_type: Type of event (see EFI specs) + * @digest: Value extended into PCR index + * @event_size: Size of event + * @event: Event data + */ +struct tcg_pcr_event { + u32 pcr_index; + u32 event_type; + u8 digest[TPM2_SHA1_DIGEST_SIZE]; + u32 event_size; + u8 event[]; +} __packed; + +/** + * Definition of TPMU_HA Union + */ +union tmpu_ha { + u8 sha1[TPM2_SHA1_DIGEST_SIZE]; + u8 sha256[TPM2_SHA256_DIGEST_SIZE]; + u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE]; + u8 sha384[TPM2_SHA384_DIGEST_SIZE]; + u8 sha512[TPM2_SHA512_DIGEST_SIZE]; +} __packed; + +/** + * Definition of TPMT_HA Structure + * + * @hash_alg: Hash algorithm defined in enum tpm2_algorithms + * @digest: Digest value for a given algorithm + */ +struct tpmt_ha { + u16 hash_alg; + union tmpu_ha digest; +} __packed; + +/** + * Definition of TPML_DIGEST_VALUES Structure + * + * @count: Number of algorithms supported by hardware + * @digests: struct for algorithm id and hash value + */ +struct tpml_digest_values { + u32 count; + struct tpmt_ha digests[TPM2_NUM_PCR_BANKS]; +} __packed; + +/** + * Crypto Agile Log Entry Format + * + * @pcr_index: PCRIndex event extended to + * @event_type: Type of event + * @digests: List of digestsextended to PCR index + * @event_size: Size of the event data + * @event: Event data + */ +struct tcg_pcr_event2 { + u32 pcr_index; + u32 event_type; + struct tpml_digest_values digests; + u32 event_size; + u8 event[]; +} __packed; + +/** * TPM2 Structure Tags for command/response buffers. * * @TPM2_ST_NO_SESSIONS: the command does not need an authentication. @@ -309,11 +391,14 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw, * * @dev TPM device * @index Index of the PCR + * @algorithm Algorithm used, defined in 'enum tpm2_algorithms' * @digest Value representing the event to be recorded + * @digest_len len of the hash * * @return code of the operation */ -u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest); +u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm, + const u8 *digest, u32 digest_len); /** * Issue a TPM2_PCR_Read command. diff --git a/include/usb.h b/include/usb.h index 5a7af882fb..b3851fdb4f 100644 --- a/include/usb.h +++ b/include/usb.h @@ -597,18 +597,18 @@ struct usb_hub_device { #if CONFIG_IS_ENABLED(DM_USB) /** - * struct usb_platdata - Platform data about a USB controller + * struct usb_plat - Platform data about a USB controller * - * Given a USB controller (UCLASS_USB) dev this is dev_get_platdata(dev) + * Given a USB controller (UCLASS_USB) dev this is dev_get_plat(dev) */ -struct usb_platdata { +struct usb_plat { enum usb_init_type init_type; }; /** - * struct usb_dev_platdata - Platform data about a USB device + * struct usb_dev_plat - Platform data about a USB device * - * Given a USB device dev this structure is dev_get_parent_platdata(dev). + * Given a USB device dev this structure is dev_get_parent_plat(dev). * This is used by sandbox to provide emulation data also. * * @id: ID used to match this device @@ -617,7 +617,7 @@ struct usb_platdata { * @strings: List of descriptor strings (for sandbox emulation purposes) * @desc_list: List of descriptors (for sandbox emulation purposes) */ -struct usb_dev_platdata { +struct usb_dev_plat { struct usb_device_id id; int devnum; /* @@ -659,14 +659,14 @@ struct usb_bus_priv { }; /** - * struct usb_emul_platdata - platform data about the USB emulator + * struct usb_emul_plat - platform data about the USB emulator * * Given a USB emulator (UCLASS_USB_EMUL) 'dev', this is - * dev_get_uclass_platdata(dev). + * dev_get_uclass_plat(dev). * * @port1: USB emulator device port number on the parent hub */ -struct usb_emul_platdata { +struct usb_emul_plat { int port1; /* Port number (numbered from 1) */ }; diff --git a/include/vbe.h b/include/vbe.h index f420f493ee..1631260eb7 100644 --- a/include/vbe.h +++ b/include/vbe.h @@ -104,10 +104,10 @@ struct vbe_ddc_info { extern struct vbe_mode_info mode_info; struct video_priv; -struct video_uc_platdata; +struct video_uc_plat; int vbe_setup_video_priv(struct vesa_mode_info *vesa, struct video_priv *uc_priv, - struct video_uc_platdata *plat); + struct video_uc_plat *plat); int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)); #endif diff --git a/include/video.h b/include/video.h index 9d09d2409a..74d822fadb 100644 --- a/include/video.h +++ b/include/video.h @@ -18,10 +18,10 @@ struct udevice; /** - * struct video_uc_platdata - uclass platform data for a video device + * struct video_uc_plat - uclass platform data for a video device * * This holds information that the uclass needs to know about each device. It - * is accessed using dev_get_uclass_platdata(dev). See 'Theory of operation' at + * is accessed using dev_get_uclass_plat(dev). See 'Theory of operation' at * the top of video-uclass.c for details on how this information is set. * * @align: Frame-buffer alignment, indicating the memory boundary the frame @@ -31,7 +31,7 @@ struct udevice; * @copy_base: Base address of a hardware copy of the frame buffer. See * CONFIG_VIDEO_COPY. */ -struct video_uc_platdata { +struct video_uc_plat { uint align; uint size; ulong base; @@ -77,7 +77,7 @@ enum video_log2_bpp { * @fb: Frame buffer * @fb_size: Frame buffer size * @copy_fb: Copy of the frame buffer to keep up to date; see struct - * video_uc_platdata + * video_uc_plat * @line_length: Length of each frame buffer line, in bytes. This can be * set by the driver, but if not, the uclass will set it after * probing @@ -114,8 +114,16 @@ struct video_priv { u8 bg_col_idx; }; -/* Placeholder - there are no video operations at present */ +/** + * struct video_ops - structure for keeping video operations + * @video_sync: Synchronize FB with device. Some device like SPI based LCD + * displays needs synchronization when data in an FB is available. + * For these devices implement video_sync hook to call a sync + * function. vid is pointer to video device udevice. Function + * should return 0 on success video_sync and error code otherwise + */ struct video_ops { + int (*video_sync)(struct udevice *vid); }; #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops) @@ -125,7 +133,7 @@ struct video_ops { * * Note: This function is for internal use. * - * This uses the uclass platdata's @size and @align members to figure out + * This uses the uclass plat's @size and @align members to figure out * a size and position for each frame buffer as part of the pre-relocation * process of determining the post-relocation memory layout. * @@ -151,15 +159,17 @@ int video_clear(struct udevice *dev); /** * video_sync() - Sync a device's frame buffer with its hardware * + * @vid: Device to sync + * @force: True to force a sync even if there was one recently (this is + * very expensive on sandbox) + * + * @return: 0 on success, error code otherwise + * * Some frame buffers are cached or have a secondary frame buffer. This * function syncs these up so that the current contents of the U-Boot frame * buffer are displayed to the user. - * - * @dev: Device to sync - * @force: True to force a sync even if there was one recently (this is - * very expensive on sandbox) */ -void video_sync(struct udevice *vid, bool force); +int video_sync(struct udevice *vid, bool force); /** * video_sync_all() - Sync all devices' frame buffers with there hardware diff --git a/include/virtio.h b/include/virtio.h index 10a9c073ba..a42bdad6b8 100644 --- a/include/virtio.h +++ b/include/virtio.h @@ -492,7 +492,7 @@ static inline void __virtio_clear_bit(struct udevice *udev, unsigned int fbit) */ static inline bool virtio_has_feature(struct udevice *vdev, unsigned int fbit) { - if (!(vdev->flags & DM_FLAG_BOUND)) + if (!(dev_get_flags(vdev) & DM_FLAG_BOUND)) WARN_ON(true); return __virtio_test_bit(vdev->parent, fbit); diff --git a/lib/Kconfig b/lib/Kconfig index 7673d2e4e0..a704568443 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -168,7 +168,7 @@ config REGEX choice prompt "Pseudo-random library support type" depends on NET_RANDOM_ETHADDR || RANDOM_UUID || CMD_UUID || \ - RNG_SANDBOX || UT_LIB && AES + RNG_SANDBOX || UT_LIB && AES || FAT_WRITE default LIB_RAND help Select the library to provide pseudo-random number generator @@ -699,3 +699,11 @@ config LIB_ELF This supports fir 32 bit and 64 bit versions. endmenu + +config PHANDLE_CHECK_SEQ + bool "Enable phandle check while getting sequence number" + default n + help + When there are multiple device tree nodes with same name, + enable this config option to distinguish them using + phandles in fdtdec_get_alias_seq() function. diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c index c3439a5988..b5f2cebbde 100644 --- a/lib/acpi/acpi_device.c +++ b/lib/acpi/acpi_device.c @@ -602,7 +602,7 @@ static void acpi_device_write_i2c(struct acpi_ctx *ctx, static int acpi_device_set_i2c(const struct udevice *dev, struct acpi_i2c *i2c, const char *scope) { - struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct dm_i2c_chip *chip = dev_get_parent_plat(dev); struct udevice *bus = dev_get_parent(dev); memset(i2c, '\0', sizeof(*i2c)); @@ -724,10 +724,10 @@ static void acpi_device_write_spi(struct acpi_ctx *ctx, const struct acpi_spi *s static int acpi_device_set_spi(const struct udevice *dev, struct acpi_spi *spi, const char *scope) { - struct dm_spi_slave_platdata *plat; + struct dm_spi_slave_plat *plat; struct spi_slave *slave = dev_get_parent_priv(dev); - plat = dev_get_parent_platdata(slave->dev); + plat = dev_get_parent_plat(slave->dev); memset(spi, '\0', sizeof(*spi)); spi->device_select = plat->cs; spi->device_select_polarity = SPI_POLARITY_LOW; @@ -784,16 +784,6 @@ static const char *acpi_name_from_id(enum uclass_id id) } } -static int acpi_check_seq(const struct udevice *dev) -{ - if (dev->req_seq == -1) { - log_warning("Device '%s' has no seq\n", dev->name); - return log_msg_ret("no seq", -ENXIO); - } - - return dev->req_seq; -} - /* If you change this function, add test cases to dm_test_acpi_get_name() */ int acpi_device_infer_name(const struct udevice *dev, char *out_name) { @@ -826,29 +816,18 @@ int acpi_device_infer_name(const struct udevice *dev, char *out_name) } } if (!name) { - int num; - switch (id) { /* DSDT: acpi/lpss.asl */ case UCLASS_SERIAL: - num = acpi_check_seq(dev); - if (num < 0) - return num; - sprintf(out_name, "URT%d", num); + sprintf(out_name, "URT%d", dev_seq(dev)); name = out_name; break; case UCLASS_I2C: - num = acpi_check_seq(dev); - if (num < 0) - return num; - sprintf(out_name, "I2C%d", num); + sprintf(out_name, "I2C%d", dev_seq(dev)); name = out_name; break; case UCLASS_SPI: - num = acpi_check_seq(dev); - if (num < 0) - return num; - sprintf(out_name, "SPI%d", num); + sprintf(out_name, "SPI%d", dev_seq(dev)); name = out_name; break; default: diff --git a/lib/crypto/pkcs7_verify.c b/lib/crypto/pkcs7_verify.c index 320ba49f79..58683ef614 100644 --- a/lib/crypto/pkcs7_verify.c +++ b/lib/crypto/pkcs7_verify.c @@ -50,8 +50,15 @@ static int pkcs7_digest(struct pkcs7_message *pkcs7, struct image_region regions[2]; int ret = 0; - /* The digest was calculated already. */ - if (sig->digest) + /* + * [RFC2315 9.3] + * If the authenticated attributes are present, + * the message-digest is calculated on the + * attributes present in the + * authenticatedAttributes field and not just + * the contents field + */ + if (!sinfo->authattrs && sig->digest) return 0; if (!sinfo->sig->hash_algo) @@ -63,17 +70,25 @@ static int pkcs7_digest(struct pkcs7_message *pkcs7, else return -ENOPKG; - sig->digest = calloc(1, sig->digest_size); - if (!sig->digest) { - pr_warn("Sig %u: Out of memory\n", sinfo->index); - return -ENOMEM; - } + /* + * Calculate the hash only if the data is present. + * In case of authenticated variable and capsule, + * the hash has already been calculated on the + * efi_image_regions and populated + */ + if (pkcs7->data) { + sig->digest = calloc(1, sig->digest_size); + if (!sig->digest) { + pr_warn("Sig %u: Out of memory\n", sinfo->index); + return -ENOMEM; + } - regions[0].data = pkcs7->data; - regions[0].size = pkcs7->data_len; + regions[0].data = pkcs7->data; + regions[0].size = pkcs7->data_len; - /* Digest the message [RFC2315 9.3] */ - hash_calculate(sinfo->sig->hash_algo, regions, 1, sig->digest); + /* Digest the message [RFC2315 9.3] */ + hash_calculate(sinfo->sig->hash_algo, regions, 1, sig->digest); + } /* However, if there are authenticated attributes, there must be a * message digest attribute amongst them which corresponds to the diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index 7d650d512e..b3393e47fa 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -67,7 +67,7 @@ void putc(const char ch) putc('\r'); if (use_uart) { - NS16550_t com_port = (NS16550_t)0x3f8; + struct ns16550 *com_port = (struct ns16550 *)0x3f8; while ((inb((ulong)&com_port->lsr) & UART_LSR_THRE) == 0) ; diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 0e72a68bce..0937e3595a 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -42,7 +42,7 @@ * handle handle of the controller on which this driver is installed * io block io protocol proxied by this driver */ -struct efi_blk_platdata { +struct efi_blk_plat { efi_handle_t handle; struct efi_block_io *io; }; @@ -59,8 +59,8 @@ struct efi_blk_platdata { static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct efi_blk_platdata *platdata = dev_get_platdata(dev); - struct efi_block_io *io = platdata->io; + struct efi_blk_plat *plat = dev_get_plat(dev); + struct efi_block_io *io = plat->io; efi_status_t ret; EFI_PRINT("%s: read '%s', from block " LBAFU ", " LBAFU " blocks\n", @@ -88,8 +88,8 @@ static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct efi_blk_platdata *platdata = dev_get_platdata(dev); - struct efi_block_io *io = platdata->io; + struct efi_blk_plat *plat = dev_get_plat(dev); + struct efi_block_io *io = plat->io; efi_status_t ret; EFI_PRINT("%s: write '%s', from block " LBAFU ", " LBAFU " blocks\n", @@ -118,7 +118,7 @@ static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev) struct blk_desc *desc; const char *if_typename; - desc = dev_get_uclass_platdata(dev); + desc = dev_get_uclass_plat(dev); if_typename = blk_get_if_type_name(desc->if_type); return efi_disk_create_partitions(handle, desc, if_typename, @@ -140,7 +140,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) struct efi_object *obj = efi_search_obj(handle); struct efi_block_io *io = interface; int disks; - struct efi_blk_platdata *platdata; + struct efi_blk_plat *plat; EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io); @@ -169,9 +169,9 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) /* Set the DM_FLAG_NAME_ALLOCED flag to avoid a memory leak */ device_set_name_alloced(bdev); - platdata = dev_get_platdata(bdev); - platdata->handle = handle; - platdata->io = interface; + plat = dev_get_plat(bdev); + plat->handle = handle; + plat->io = interface; ret = device_probe(bdev); if (ret) @@ -196,7 +196,7 @@ U_BOOT_DRIVER(efi_blk) = { .name = "efi_blk", .id = UCLASS_BLK, .ops = &efi_blk_ops, - .platdata_auto_alloc_size = sizeof(struct efi_blk_platdata), + .plat_auto = sizeof(struct efi_blk_plat), }; /* EFI driver operators */ diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 0cf74b0361..382c2b477f 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -238,7 +238,7 @@ static efi_status_t EFIAPI efi_uc_stop( } ret = EFI_CALL(systab.boottime->free_pool(entry_buffer)); if (ret != EFI_SUCCESS) - printf("%s: ERROR: Cannot free pool\n", __func__); + log_err("Cannot free EFI memory pool\n"); /* Detach driver from controller */ ret = EFI_CALL(systab.boottime->close_protocol( @@ -260,10 +260,10 @@ static efi_status_t efi_add_driver(struct driver *drv) const struct efi_driver_ops *ops = drv->ops; struct efi_driver_binding_extended_protocol *bp; - debug("EFI: Adding driver '%s'\n", drv->name); + log_debug("Adding EFI driver '%s'\n", drv->name); if (!ops->protocol) { - printf("EFI: ERROR: protocol GUID missing for driver '%s'\n", - drv->name); + log_err("EFI protocol GUID missing for driver '%s'\n", + drv->name); return EFI_INVALID_PARAMETER; } bp = calloc(1, sizeof(struct efi_driver_binding_extended_protocol)); @@ -305,14 +305,14 @@ efi_status_t efi_driver_init(void) struct driver *drv; efi_status_t ret = EFI_SUCCESS; - debug("EFI: Initializing EFI driver framework\n"); + log_debug("Initializing EFI driver framework\n"); for (drv = ll_entry_start(struct driver, driver); drv < ll_entry_end(struct driver, driver); ++drv) { if (drv->id == UCLASS_EFI) { ret = efi_add_driver(drv); if (ret != EFI_SUCCESS) { - printf("EFI: ERROR: failed to add driver %s\n", - drv->name); + log_err("Failed to add EFI driver %s\n", + drv->name); break; } } @@ -328,7 +328,7 @@ efi_status_t efi_driver_init(void) */ static int efi_uc_init(struct uclass *class) { - printf("EFI: Initializing UCLASS_EFI\n"); + log_debug("Initializing UCLASS_EFI\n"); return 0; } @@ -340,7 +340,7 @@ static int efi_uc_init(struct uclass *class) */ static int efi_uc_destroy(struct uclass *class) { - printf("Destroying UCLASS_EFI\n"); + log_debug("Destroying UCLASS_EFI\n"); return 0; } diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index dd8b93bd3c..fdf245dea3 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -108,6 +108,91 @@ config EFI_SET_TIME Provide the SetTime() runtime service at boottime. This service can be used by an EFI application to adjust the real time clock. +config EFI_HAVE_CAPSULE_SUPPORT + bool + +config EFI_RUNTIME_UPDATE_CAPSULE + bool "UpdateCapsule() runtime service" + default n + select EFI_HAVE_CAPSULE_SUPPORT + help + Select this option if you want to use UpdateCapsule and + QueryCapsuleCapabilities API's. + +config EFI_CAPSULE_ON_DISK + bool "Enable capsule-on-disk support" + select EFI_HAVE_CAPSULE_SUPPORT + default n + help + Select this option if you want to use capsule-on-disk feature, + that is, capsules can be fetched and executed from files + under a specific directory on UEFI system partition instead of + via UpdateCapsule API. + +config EFI_CAPSULE_ON_DISK_EARLY + bool "Initiate capsule-on-disk at U-Boot boottime" + depends on EFI_CAPSULE_ON_DISK + default n + select EFI_SETUP_EARLY + help + Normally, without this option enabled, capsules will be + executed only at the first time of invoking one of efi command. + If this option is enabled, capsules will be enforced to be + executed as part of U-Boot initialisation so that they will + surely take place whatever is set to distro_bootcmd. + +config EFI_CAPSULE_FIRMWARE + bool + default n + +config EFI_CAPSULE_FIRMWARE_MANAGEMENT + bool "Capsule: Firmware Management Protocol" + depends on EFI_HAVE_CAPSULE_SUPPORT + default y + help + Select this option if you want to enable capsule-based + firmware update using Firmware Management Protocol. + +config EFI_CAPSULE_AUTHENTICATE + bool "Update Capsule authentication" + depends on EFI_CAPSULE_FIRMWARE + depends on EFI_CAPSULE_ON_DISK + depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT + select SHA256 + select RSA + select RSA_VERIFY + select RSA_VERIFY_WITH_PKEY + select X509_CERTIFICATE_PARSER + select PKCS7_MESSAGE_PARSER + select PKCS7_VERIFY + default n + help + Select this option if you want to enable capsule + authentication + +config EFI_CAPSULE_FIRMWARE_FIT + bool "FMP driver for FIT image" + depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT + depends on FIT + select UPDATE_FIT + select DFU + select EFI_CAPSULE_FIRMWARE + default n + help + Select this option if you want to enable firmware management protocol + driver for FIT image + +config EFI_CAPSULE_FIRMWARE_RAW + bool "FMP driver for raw image" + depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT + select DFU + select DFU_WRITE_ALT + select EFI_CAPSULE_FIRMWARE + default n + help + Select this option if you want to enable firmware management protocol + driver for raw image + config EFI_DEVICE_PATH_TO_TEXT bool "Device path to text protocol" default y @@ -179,7 +264,8 @@ config EFI_HAVE_RUNTIME_RESET # bool "Reset runtime service is available" bool default y - depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || SYSRESET_X86 + depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || \ + SANDBOX || SYSRESET_X86 config EFI_GRUB_ARM32_WORKAROUND bool "Workaround for GRUB on 32bit ARM" @@ -206,6 +292,15 @@ config EFI_TCG2_PROTOCOL Provide a EFI_TCG2_PROTOCOL implementation using the TPM hardware of the platform. +config EFI_TCG2_PROTOCOL_EVENTLOG_SIZE + int "EFI_TCG2_PROTOCOL EventLog size" + depends on EFI_TCG2_PROTOCOL + default 4096 + help + Define the size of the EventLog for EFI_TCG2_PROTOCOL. Note that + this is going to be allocated twice. One for the eventlog it self + and one for the configuration table that is required from the spec + config EFI_LOAD_FILE2_INITRD bool "EFI_FILE_LOAD2_PROTOCOL for Linux initial ramdisk" default n diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index cd4b252a41..462d4d9ac4 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -23,12 +23,14 @@ endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-y += efi_bootmgr.o obj-y += efi_boottime.o +obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o +obj-$(CONFIG_EFI_CAPSULE_FIRMWARE) += efi_firmware.o obj-y += efi_console.o obj-y += efi_device_path.o obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_device_path_to_text.o obj-y += efi_device_path_utilities.o obj-y += efi_file.o -obj-$(CONFIG_EFI_LOADER_HII) += efi_hii.o efi_hii_config.o +obj-$(CONFIG_EFI_LOADER_HII) += efi_hii.o obj-y += efi_image_loader.o obj-y += efi_memory.o obj-y += efi_root_node.o diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index a89bdb3140..b2cb0160c0 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -81,6 +81,9 @@ const efi_guid_t efi_guid_event_group_ready_to_boot = /* event group ResetSystem() invoked (before ExitBootServices) */ const efi_guid_t efi_guid_event_group_reset_system = EFI_EVENT_GROUP_RESET_SYSTEM; +/* GUIDs of the Load File and Load File2 protocols */ +const efi_guid_t efi_guid_load_file_protocol = EFI_LOAD_FILE_PROTOCOL_GUID; +const efi_guid_t efi_guid_load_file2_protocol = EFI_LOAD_FILE2_PROTOCOL_GUID; static efi_status_t EFIAPI efi_disconnect_controller( efi_handle_t controller_handle, @@ -244,8 +247,8 @@ static void efi_queue_event(struct efi_event *event) } if (event) list_add_tail(&event->queue_link, &efi_event_queue); + efi_process_event_queue(); } - efi_process_event_queue(); } /** @@ -1770,30 +1773,108 @@ failure: } /** - * efi_load_image_from_path() - load an image using a file path + * efi_locate_device_path() - Get the device path and handle of an device + * implementing a protocol + * @protocol: GUID of the protocol + * @device_path: device path + * @device: handle of the device + * + * This function implements the LocateDevicePath service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * Return: status code + */ +static efi_status_t EFIAPI efi_locate_device_path( + const efi_guid_t *protocol, + struct efi_device_path **device_path, + efi_handle_t *device) +{ + struct efi_device_path *dp; + size_t i; + struct efi_handler *handler; + efi_handle_t *handles; + size_t len, len_dp; + size_t len_best = 0; + efi_uintn_t no_handles; + u8 *remainder; + efi_status_t ret; + + EFI_ENTRY("%pUl, %p, %p", protocol, device_path, device); + + if (!protocol || !device_path || !*device_path) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + /* Find end of device path */ + len = efi_dp_instance_size(*device_path); + + /* Get all handles implementing the protocol */ + ret = EFI_CALL(efi_locate_handle_buffer(BY_PROTOCOL, protocol, NULL, + &no_handles, &handles)); + if (ret != EFI_SUCCESS) + goto out; + + for (i = 0; i < no_handles; ++i) { + /* Find the device path protocol */ + ret = efi_search_protocol(handles[i], &efi_guid_device_path, + &handler); + if (ret != EFI_SUCCESS) + continue; + dp = (struct efi_device_path *)handler->protocol_interface; + len_dp = efi_dp_instance_size(dp); + /* + * This handle can only be a better fit + * if its device path length is longer than the best fit and + * if its device path length is shorter of equal the searched + * device path. + */ + if (len_dp <= len_best || len_dp > len) + continue; + /* Check if dp is a subpath of device_path */ + if (memcmp(*device_path, dp, len_dp)) + continue; + if (!device) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + *device = handles[i]; + len_best = len_dp; + } + if (len_best) { + remainder = (u8 *)*device_path + len_best; + *device_path = (struct efi_device_path *)remainder; + ret = EFI_SUCCESS; + } else { + ret = EFI_NOT_FOUND; + } +out: + return EFI_EXIT(ret); +} + +/** + * efi_load_image_from_file() - load an image from file system * * Read a file into a buffer allocated as EFI_BOOT_SERVICES_DATA. It is the * callers obligation to update the memory type as needed. * - * @file_path: the path of the image to load - * @buffer: buffer containing the loaded image - * @size: size of the loaded image - * Return: status code + * @file_path: the path of the image to load + * @buffer: buffer containing the loaded image + * @size: size of the loaded image + * Return: status code */ static -efi_status_t efi_load_image_from_path(struct efi_device_path *file_path, +efi_status_t efi_load_image_from_file(struct efi_device_path *file_path, void **buffer, efi_uintn_t *size) { struct efi_file_info *info = NULL; struct efi_file_handle *f; - static efi_status_t ret; + efi_status_t ret; u64 addr; efi_uintn_t bs; - /* In case of failure nothing is returned */ - *buffer = NULL; - *size = 0; - /* Open file */ f = efi_file_from_path(file_path); if (!f) @@ -1842,6 +1923,86 @@ error: } /** + * efi_load_image_from_path() - load an image using a file path + * + * Read a file into a buffer allocated as EFI_BOOT_SERVICES_DATA. It is the + * callers obligation to update the memory type as needed. + * + * @boot_policy: true for request originating from the boot manager + * @file_path: the path of the image to load + * @buffer: buffer containing the loaded image + * @size: size of the loaded image + * Return: status code + */ +static +efi_status_t efi_load_image_from_path(bool boot_policy, + struct efi_device_path *file_path, + void **buffer, efi_uintn_t *size) +{ + efi_handle_t device; + efi_status_t ret; + struct efi_device_path *dp; + struct efi_load_file_protocol *load_file_protocol = NULL; + efi_uintn_t buffer_size; + uint64_t addr, pages; + const efi_guid_t *guid; + + /* In case of failure nothing is returned */ + *buffer = NULL; + *size = 0; + + dp = file_path; + ret = EFI_CALL(efi_locate_device_path( + &efi_simple_file_system_protocol_guid, &dp, &device)); + if (ret == EFI_SUCCESS) + return efi_load_image_from_file(file_path, buffer, size); + + ret = EFI_CALL(efi_locate_device_path( + &efi_guid_load_file_protocol, &dp, &device)); + if (ret == EFI_SUCCESS) { + guid = &efi_guid_load_file_protocol; + } else if (!boot_policy) { + guid = &efi_guid_load_file2_protocol; + ret = EFI_CALL(efi_locate_device_path(guid, &dp, &device)); + } + if (ret != EFI_SUCCESS) + return EFI_NOT_FOUND; + ret = EFI_CALL(efi_handle_protocol(device, guid, + (void **)&load_file_protocol)); + if (ret != EFI_SUCCESS) + return EFI_NOT_FOUND; + buffer_size = 0; + ret = load_file_protocol->load_file(load_file_protocol, dp, + boot_policy, &buffer_size, + NULL); + if (ret != EFI_BUFFER_TOO_SMALL) + goto out; + pages = efi_size_in_pages(buffer_size); + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, EFI_BOOT_SERVICES_DATA, + pages, &addr); + if (ret != EFI_SUCCESS) { + ret = EFI_OUT_OF_RESOURCES; + goto out; + } + ret = EFI_CALL(load_file_protocol->load_file( + load_file_protocol, dp, boot_policy, + &buffer_size, (void *)(uintptr_t)addr)); + if (ret != EFI_SUCCESS) + efi_free_pages(addr, pages); +out: + if (load_file_protocol) + EFI_CALL(efi_close_protocol(device, + &efi_guid_load_file2_protocol, + efi_root, NULL)); + if (ret == EFI_SUCCESS) { + *buffer = (void *)(uintptr_t)addr; + *size = buffer_size; + } + + return ret; +} + +/** * efi_load_image() - load an EFI image into memory * @boot_policy: true for request originating from the boot manager * @parent_image: the caller's image handle @@ -1883,8 +2044,8 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy, } if (!source_buffer) { - ret = efi_load_image_from_path(file_path, &dest_buffer, - &source_size); + ret = efi_load_image_from_path(boot_policy, file_path, + &dest_buffer, &source_size); if (ret != EFI_SUCCESS) goto error; } else { @@ -2404,88 +2565,6 @@ found: } /** - * efi_locate_device_path() - Get the device path and handle of an device - * implementing a protocol - * @protocol: GUID of the protocol - * @device_path: device path - * @device: handle of the device - * - * This function implements the LocateDevicePath service. - * - * See the Unified Extensible Firmware Interface (UEFI) specification for - * details. - * - * Return: status code - */ -static efi_status_t EFIAPI efi_locate_device_path( - const efi_guid_t *protocol, - struct efi_device_path **device_path, - efi_handle_t *device) -{ - struct efi_device_path *dp; - size_t i; - struct efi_handler *handler; - efi_handle_t *handles; - size_t len, len_dp; - size_t len_best = 0; - efi_uintn_t no_handles; - u8 *remainder; - efi_status_t ret; - - EFI_ENTRY("%pUl, %p, %p", protocol, device_path, device); - - if (!protocol || !device_path || !*device_path) { - ret = EFI_INVALID_PARAMETER; - goto out; - } - - /* Find end of device path */ - len = efi_dp_instance_size(*device_path); - - /* Get all handles implementing the protocol */ - ret = EFI_CALL(efi_locate_handle_buffer(BY_PROTOCOL, protocol, NULL, - &no_handles, &handles)); - if (ret != EFI_SUCCESS) - goto out; - - for (i = 0; i < no_handles; ++i) { - /* Find the device path protocol */ - ret = efi_search_protocol(handles[i], &efi_guid_device_path, - &handler); - if (ret != EFI_SUCCESS) - continue; - dp = (struct efi_device_path *)handler->protocol_interface; - len_dp = efi_dp_instance_size(dp); - /* - * This handle can only be a better fit - * if its device path length is longer than the best fit and - * if its device path length is shorter of equal the searched - * device path. - */ - if (len_dp <= len_best || len_dp > len) - continue; - /* Check if dp is a subpath of device_path */ - if (memcmp(*device_path, dp, len_dp)) - continue; - if (!device) { - ret = EFI_INVALID_PARAMETER; - goto out; - } - *device = handles[i]; - len_best = len_dp; - } - if (len_best) { - remainder = (u8 *)*device_path + len_best; - *device_path = (struct efi_device_path *)remainder; - ret = EFI_SUCCESS; - } else { - ret = EFI_NOT_FOUND; - } -out: - return EFI_EXIT(ret); -} - -/** * efi_install_multiple_protocol_interfaces() - Install multiple protocol * interfaces * @handle: handle on which the protocol interfaces shall be installed @@ -2700,7 +2779,7 @@ static void EFIAPI efi_set_mem(void *buffer, size_t size, uint8_t value) * * Return: status code */ -static efi_status_t efi_protocol_open( +efi_status_t efi_protocol_open( struct efi_handler *handler, void **protocol_interface, void *agent_handle, void *controller_handle, uint32_t attributes) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c new file mode 100644 index 0000000000..dad1b0fcf7 --- /dev/null +++ b/lib/efi_loader/efi_capsule.c @@ -0,0 +1,1032 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI Capsule + * + * Copyright (c) 2018 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include <common.h> +#include <efi_loader.h> +#include <efi_variable.h> +#include <fs.h> +#include <malloc.h> +#include <mapmem.h> +#include <sort.h> + +#include <crypto/pkcs7.h> +#include <crypto/pkcs7_parser.h> +#include <linux/err.h> + +const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID; +static const efi_guid_t efi_guid_firmware_management_capsule_id = + EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; +const efi_guid_t efi_guid_firmware_management_protocol = + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID; + +#ifdef CONFIG_EFI_CAPSULE_ON_DISK +/* for file system access */ +static struct efi_file_handle *bootdev_root; +#endif + +/** + * get_last_capsule - get the last capsule index + * + * Retrieve the index of the capsule invoked last time from "CapsuleLast" + * variable. + * + * Return: + * * > 0 - the last capsule index invoked + * * 0xffff - on error, or no capsule invoked yet + */ +static __maybe_unused unsigned int get_last_capsule(void) +{ + u16 value16[11]; /* "CapsuleXXXX": non-null-terminated */ + char value[11], *p; + efi_uintn_t size; + unsigned long index = 0xffff; + efi_status_t ret; + + size = sizeof(value16); + ret = efi_get_variable_int(L"CapsuleLast", &efi_guid_capsule_report, + NULL, &size, value16, NULL); + if (ret != EFI_SUCCESS || u16_strncmp(value16, L"Capsule", 7)) + goto err; + + p = value; + utf16_utf8_strcpy(&p, value16); + strict_strtoul(&value[7], 16, &index); +err: + return index; +} + +/** + * set_capsule_result - set a result variable + * @capsule: Capsule + * @return_status: Return status + * + * Create and set a result variable, "CapsuleXXXX", for the capsule, + * @capsule. + */ +static __maybe_unused +void set_capsule_result(int index, struct efi_capsule_header *capsule, + efi_status_t return_status) +{ + u16 variable_name16[12]; + struct efi_capsule_result_variable_header result; + struct efi_time time; + efi_status_t ret; + + efi_create_indexed_name(variable_name16, sizeof(variable_name16), + "Capsule", index); + result.variable_total_size = sizeof(result); + result.capsule_guid = capsule->capsule_guid; + ret = EFI_CALL((*efi_runtime_services.get_time)(&time, NULL)); + if (ret == EFI_SUCCESS) + memcpy(&result.capsule_processed, &time, sizeof(time)); + else + memset(&result.capsule_processed, 0, sizeof(time)); + result.capsule_status = return_status; + ret = efi_set_variable(variable_name16, &efi_guid_capsule_report, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(result), &result); + if (ret) + log_err("EFI: creating %ls failed\n", variable_name16); +} + +#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT +/** + * efi_fmp_find - search for Firmware Management Protocol drivers + * @image_type: Image type guid + * @instance: Instance number + * @handles: Handles of FMP drivers + * @no_handles: Number of handles + * + * Search for Firmware Management Protocol drivers, matching the image + * type, @image_type and the machine instance, @instance, from the list, + * @handles. + * + * Return: + * * Protocol instance - on success + * * NULL - on failure + */ +static struct efi_firmware_management_protocol * +efi_fmp_find(efi_guid_t *image_type, u64 instance, efi_handle_t *handles, + efi_uintn_t no_handles) +{ + efi_handle_t *handle; + struct efi_firmware_management_protocol *fmp; + struct efi_firmware_image_descriptor *image_info, *desc; + efi_uintn_t info_size, descriptor_size; + u32 descriptor_version; + u8 descriptor_count; + u32 package_version; + u16 *package_version_name; + bool found = false; + int i, j; + efi_status_t ret; + + for (i = 0, handle = handles; i < no_handles; i++, handle++) { + ret = EFI_CALL(efi_handle_protocol( + *handle, + &efi_guid_firmware_management_protocol, + (void **)&fmp)); + if (ret != EFI_SUCCESS) + continue; + + /* get device's image info */ + info_size = 0; + image_info = NULL; + descriptor_version = 0; + descriptor_count = 0; + descriptor_size = 0; + package_version = 0; + package_version_name = NULL; + ret = EFI_CALL(fmp->get_image_info(fmp, &info_size, + image_info, + &descriptor_version, + &descriptor_count, + &descriptor_size, + &package_version, + &package_version_name)); + if (ret != EFI_BUFFER_TOO_SMALL) + goto skip; + + image_info = malloc(info_size); + if (!image_info) + goto skip; + + ret = EFI_CALL(fmp->get_image_info(fmp, &info_size, + image_info, + &descriptor_version, + &descriptor_count, + &descriptor_size, + &package_version, + &package_version_name)); + if (ret != EFI_SUCCESS || + descriptor_version != EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION) + goto skip; + + /* matching */ + for (j = 0, desc = image_info; j < descriptor_count; + j++, desc = (void *)desc + descriptor_size) { + log_debug("+++ desc[%d] index: %d, name: %ls\n", + j, desc->image_index, desc->image_id_name); + if (!guidcmp(&desc->image_type_id, image_type) && + (!instance || + !desc->hardware_instance || + desc->hardware_instance == instance)) + found = true; + } + +skip: + efi_free_pool(package_version_name); + free(image_info); + EFI_CALL(efi_close_protocol( + (efi_handle_t)fmp, + &efi_guid_firmware_management_protocol, + NULL, NULL)); + if (found) + return fmp; + } + + return NULL; +} + +#if defined(CONFIG_EFI_CAPSULE_AUTHENTICATE) + +const efi_guid_t efi_guid_capsule_root_cert_guid = + EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; + +__weak int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len) +{ + /* The platform is supposed to provide + * a method for getting the public key + * stored in the form of efi signature + * list + */ + return 0; +} + +efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size, + void **image, efi_uintn_t *image_size) +{ + u8 *buf; + int ret; + void *fdt_pkey, *pkey; + efi_uintn_t pkey_len; + uint64_t monotonic_count; + struct efi_signature_store *truststore; + struct pkcs7_message *capsule_sig; + struct efi_image_regions *regs; + struct efi_firmware_image_authentication *auth_hdr; + efi_status_t status; + + status = EFI_SECURITY_VIOLATION; + capsule_sig = NULL; + truststore = NULL; + regs = NULL; + + /* Sanity checks */ + if (capsule == NULL || capsule_size == 0) + goto out; + + auth_hdr = (struct efi_firmware_image_authentication *)capsule; + if (capsule_size < sizeof(*auth_hdr)) + goto out; + + if (auth_hdr->auth_info.hdr.dwLength <= + offsetof(struct win_certificate_uefi_guid, cert_data)) + goto out; + + if (guidcmp(&auth_hdr->auth_info.cert_type, &efi_guid_cert_type_pkcs7)) + goto out; + + *image = (uint8_t *)capsule + sizeof(auth_hdr->monotonic_count) + + auth_hdr->auth_info.hdr.dwLength; + *image_size = capsule_size - auth_hdr->auth_info.hdr.dwLength - + sizeof(auth_hdr->monotonic_count); + memcpy(&monotonic_count, &auth_hdr->monotonic_count, + sizeof(monotonic_count)); + + /* data to be digested */ + regs = calloc(sizeof(*regs) + sizeof(struct image_region) * 2, 1); + if (!regs) + goto out; + + regs->max = 2; + efi_image_region_add(regs, (uint8_t *)*image, + (uint8_t *)*image + *image_size, 1); + + efi_image_region_add(regs, (uint8_t *)&monotonic_count, + (uint8_t *)&monotonic_count + sizeof(monotonic_count), + 1); + + capsule_sig = efi_parse_pkcs7_header(auth_hdr->auth_info.cert_data, + auth_hdr->auth_info.hdr.dwLength + - sizeof(auth_hdr->auth_info), + &buf); + if (IS_ERR(capsule_sig)) { + debug("Parsing variable's pkcs7 header failed\n"); + capsule_sig = NULL; + goto out; + } + + ret = efi_get_public_key_data(&fdt_pkey, &pkey_len); + if (ret < 0) + goto out; + + pkey = malloc(pkey_len); + if (!pkey) + goto out; + + memcpy(pkey, fdt_pkey, pkey_len); + truststore = efi_build_signature_store(pkey, pkey_len); + if (!truststore) + goto out; + + /* verify signature */ + if (efi_signature_verify(regs, capsule_sig, truststore, NULL)) { + debug("Verified\n"); + } else { + debug("Verifying variable's signature failed\n"); + goto out; + } + + status = EFI_SUCCESS; + +out: + efi_sigstore_free(truststore); + pkcs7_free_message(capsule_sig); + free(regs); + + return status; +} +#else +efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size, + void **image, efi_uintn_t *image_size) +{ + return EFI_UNSUPPORTED; +} +#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */ + + +/** + * efi_capsule_update_firmware - update firmware from capsule + * @capsule_data: Capsule + * + * Update firmware, using a capsule, @capsule_data. Loading any FMP + * drivers embedded in a capsule is not supported. + * + * Return: status code + */ +static efi_status_t efi_capsule_update_firmware( + struct efi_capsule_header *capsule_data) +{ + struct efi_firmware_management_capsule_header *capsule; + struct efi_firmware_management_capsule_image_header *image; + size_t capsule_size; + void *image_binary, *vendor_code; + efi_handle_t *handles; + efi_uintn_t no_handles; + int item; + struct efi_firmware_management_protocol *fmp; + u16 *abort_reason; + efi_status_t ret = EFI_SUCCESS; + + /* sanity check */ + if (capsule_data->header_size < sizeof(*capsule) || + capsule_data->header_size >= capsule_data->capsule_image_size) + return EFI_INVALID_PARAMETER; + + capsule = (void *)capsule_data + capsule_data->header_size; + capsule_size = capsule_data->capsule_image_size + - capsule_data->header_size; + + if (capsule->version != 0x00000001) + return EFI_UNSUPPORTED; + + handles = NULL; + ret = EFI_CALL(efi_locate_handle_buffer( + BY_PROTOCOL, + &efi_guid_firmware_management_protocol, + NULL, &no_handles, (efi_handle_t **)&handles)); + if (ret != EFI_SUCCESS) + return EFI_UNSUPPORTED; + + /* Payload */ + for (item = capsule->embedded_driver_count; + item < capsule->embedded_driver_count + + capsule->payload_item_count; item++) { + /* sanity check */ + if ((capsule->item_offset_list[item] + sizeof(*image) + >= capsule_size)) { + log_err("EFI: A capsule has not enough data\n"); + ret = EFI_INVALID_PARAMETER; + goto out; + } + + image = (void *)capsule + capsule->item_offset_list[item]; + + if (image->version != 0x00000003) { + ret = EFI_UNSUPPORTED; + goto out; + } + + /* find a device for update firmware */ + /* TODO: should we pass index as well, or nothing but type? */ + fmp = efi_fmp_find(&image->update_image_type_id, + image->update_hardware_instance, + handles, no_handles); + if (!fmp) { + log_err("EFI Capsule: driver not found for firmware type: %pUl, hardware instance: %lld\n", + &image->update_image_type_id, + image->update_hardware_instance); + ret = EFI_UNSUPPORTED; + goto out; + } + + /* do update */ + image_binary = (void *)image + sizeof(*image); + vendor_code = image_binary + image->update_image_size; + + abort_reason = NULL; + ret = EFI_CALL(fmp->set_image(fmp, image->update_image_index, + image_binary, + image->update_image_size, + vendor_code, NULL, + &abort_reason)); + if (ret != EFI_SUCCESS) { + log_err("EFI Capsule: firmware update failed: %ls\n", + abort_reason); + efi_free_pool(abort_reason); + goto out; + } + } + +out: + efi_free_pool(handles); + + return ret; +} +#else +static efi_status_t efi_capsule_update_firmware( + struct efi_capsule_header *capsule_data) +{ + return EFI_UNSUPPORTED; +} +#endif /* CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT */ + +/** + * efi_update_capsule() - process information from operating system + * @capsule_header_array: Array of virtual address pointers + * @capsule_count: Number of pointers in capsule_header_array + * @scatter_gather_list: Array of physical address pointers + * + * This function implements the UpdateCapsule() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * Return: status code + */ +efi_status_t EFIAPI efi_update_capsule( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 scatter_gather_list) +{ + struct efi_capsule_header *capsule; + unsigned int i; + efi_status_t ret; + + EFI_ENTRY("%p, %lu, %llu\n", capsule_header_array, capsule_count, + scatter_gather_list); + + if (!capsule_count) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + ret = EFI_SUCCESS; + for (i = 0, capsule = *capsule_header_array; i < capsule_count; + i++, capsule = *(++capsule_header_array)) { + /* sanity check */ + if (capsule->header_size < sizeof(*capsule) || + capsule->capsule_image_size < sizeof(*capsule)) { + log_err("EFI: A capsule has not enough data\n"); + continue; + } + + log_debug("Capsule[%d] (guid:%pUl)\n", + i, &capsule->capsule_guid); + if (!guidcmp(&capsule->capsule_guid, + &efi_guid_firmware_management_capsule_id)) { + ret = efi_capsule_update_firmware(capsule); + } else { + log_err("EFI: not support capsule type: %pUl\n", + &capsule->capsule_guid); + ret = EFI_UNSUPPORTED; + } + + if (ret != EFI_SUCCESS) + goto out; + } +out: + return EFI_EXIT(ret); +} + +/** + * efi_query_capsule_caps() - check if capsule is supported + * @capsule_header_array: Array of virtual pointers + * @capsule_count: Number of pointers in capsule_header_array + * @maximum_capsule_size: Maximum capsule size + * @reset_type: Type of reset needed for capsule update + * + * This function implements the QueryCapsuleCapabilities() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * Return: status code + */ +efi_status_t EFIAPI efi_query_capsule_caps( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 *maximum_capsule_size, + u32 *reset_type) +{ + struct efi_capsule_header *capsule __attribute__((unused)); + unsigned int i; + efi_status_t ret; + + EFI_ENTRY("%p, %lu, %p, %p\n", capsule_header_array, capsule_count, + maximum_capsule_size, reset_type); + + if (!maximum_capsule_size) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + *maximum_capsule_size = U64_MAX; + *reset_type = EFI_RESET_COLD; + + ret = EFI_SUCCESS; + for (i = 0, capsule = *capsule_header_array; i < capsule_count; + i++, capsule = *(++capsule_header_array)) { + /* TODO */ + } +out: + return EFI_EXIT(ret); +} + +#ifdef CONFIG_EFI_CAPSULE_ON_DISK +/** + * get_dp_device - retrieve a device path from boot variable + * @boot_var: Boot variable name + * @device_dp Device path + * + * Retrieve a device patch from boot variable, @boot_var. + * + * Return: status code + */ +static efi_status_t get_dp_device(u16 *boot_var, + struct efi_device_path **device_dp) +{ + void *buf = NULL; + efi_uintn_t size; + struct efi_load_option lo; + struct efi_device_path *file_dp; + efi_status_t ret; + + size = 0; + ret = efi_get_variable_int(boot_var, &efi_global_variable_guid, + NULL, &size, NULL, NULL); + if (ret == EFI_BUFFER_TOO_SMALL) { + buf = malloc(size); + if (!buf) + return EFI_OUT_OF_RESOURCES; + ret = efi_get_variable_int(boot_var, &efi_global_variable_guid, + NULL, &size, buf, NULL); + } + if (ret != EFI_SUCCESS) + return ret; + + efi_deserialize_load_option(&lo, buf, &size); + + if (lo.attributes & LOAD_OPTION_ACTIVE) { + efi_dp_split_file_path(lo.file_path, device_dp, &file_dp); + efi_free_pool(file_dp); + + ret = EFI_SUCCESS; + } else { + ret = EFI_NOT_FOUND; + } + + free(buf); + + return ret; +} + +/** + * device_is_present_and_system_part - check if a device exists + * @dp Device path + * + * Check if a device pointed to by the device path, @dp, exists and is + * located in UEFI system partition. + * + * Return: true - yes, false - no + */ +static bool device_is_present_and_system_part(struct efi_device_path *dp) +{ + efi_handle_t handle; + + handle = efi_dp_find_obj(dp, NULL); + if (!handle) + return false; + + return efi_disk_is_system_part(handle); +} + +/** + * find_boot_device - identify the boot device + * + * Identify the boot device from boot-related variables as UEFI + * specification describes and put its handle into bootdev_root. + * + * Return: status code + */ +static efi_status_t find_boot_device(void) +{ + char boot_var[9]; + u16 boot_var16[9], *p, bootnext, *boot_order = NULL; + efi_uintn_t size; + int i, num; + struct efi_simple_file_system_protocol *volume; + struct efi_device_path *boot_dev = NULL; + efi_status_t ret; + + /* find active boot device in BootNext */ + bootnext = 0; + size = sizeof(bootnext); + ret = efi_get_variable_int(L"BootNext", + (efi_guid_t *)&efi_global_variable_guid, + NULL, &size, &bootnext, NULL); + if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { + /* BootNext does exist here */ + if (ret == EFI_BUFFER_TOO_SMALL || size != sizeof(u16)) { + log_err("BootNext must be 16-bit integer\n"); + goto skip; + } + sprintf((char *)boot_var, "Boot%04X", bootnext); + p = boot_var16; + utf8_utf16_strcpy(&p, boot_var); + + ret = get_dp_device(boot_var16, &boot_dev); + if (ret == EFI_SUCCESS) { + if (device_is_present_and_system_part(boot_dev)) { + goto out; + } else { + efi_free_pool(boot_dev); + boot_dev = NULL; + } + } + } + +skip: + /* find active boot device in BootOrder */ + size = 0; + ret = efi_get_variable_int(L"BootOrder", &efi_global_variable_guid, + NULL, &size, NULL, NULL); + if (ret == EFI_BUFFER_TOO_SMALL) { + boot_order = malloc(size); + if (!boot_order) { + ret = EFI_OUT_OF_RESOURCES; + goto out; + } + + ret = efi_get_variable_int(L"BootOrder", + &efi_global_variable_guid, + NULL, &size, boot_order, NULL); + } + if (ret != EFI_SUCCESS) + goto out; + + /* check in higher order */ + num = size / sizeof(u16); + for (i = 0; i < num; i++) { + sprintf((char *)boot_var, "Boot%04X", boot_order[i]); + p = boot_var16; + utf8_utf16_strcpy(&p, boot_var); + ret = get_dp_device(boot_var16, &boot_dev); + if (ret != EFI_SUCCESS) + continue; + + if (device_is_present_and_system_part(boot_dev)) + break; + + efi_free_pool(boot_dev); + boot_dev = NULL; + } +out: + if (boot_dev) { + u16 *path_str; + + path_str = efi_dp_str(boot_dev); + log_debug("EFI Capsule: bootdev is %ls\n", path_str); + efi_free_pool(path_str); + + volume = efi_fs_from_path(boot_dev); + if (!volume) + ret = EFI_DEVICE_ERROR; + else + ret = EFI_CALL(volume->open_volume(volume, + &bootdev_root)); + efi_free_pool(boot_dev); + } else { + ret = EFI_NOT_FOUND; + } + free(boot_order); + + return ret; +} + +/** + * efi_capsule_scan_dir - traverse a capsule directory in boot device + * @files: Array of file names + * @num: Number of elements in @files + * + * Traverse a capsule directory in boot device. + * Called by initialization code, and returns an array of capsule file + * names in @files. + * + * Return: status code + */ +static efi_status_t efi_capsule_scan_dir(u16 ***files, unsigned int *num) +{ + struct efi_file_handle *dirh; + struct efi_file_info *dirent; + efi_uintn_t dirent_size, tmp_size; + unsigned int count; + u16 **tmp_files; + efi_status_t ret; + + ret = find_boot_device(); + if (ret == EFI_NOT_FOUND) { + log_debug("EFI Capsule: bootdev is not set\n"); + *num = 0; + return EFI_SUCCESS; + } else if (ret != EFI_SUCCESS) { + return EFI_DEVICE_ERROR; + } + + /* count capsule files */ + ret = EFI_CALL((*bootdev_root->open)(bootdev_root, &dirh, + EFI_CAPSULE_DIR, + EFI_FILE_MODE_READ, 0)); + if (ret != EFI_SUCCESS) { + *num = 0; + return EFI_SUCCESS; + } + + dirent_size = 256; + dirent = malloc(dirent_size); + if (!dirent) + return EFI_OUT_OF_RESOURCES; + + count = 0; + while (1) { + tmp_size = dirent_size; + ret = EFI_CALL((*dirh->read)(dirh, &tmp_size, dirent)); + if (ret == EFI_BUFFER_TOO_SMALL) { + dirent = realloc(dirent, tmp_size); + if (!dirent) { + ret = EFI_OUT_OF_RESOURCES; + goto err; + } + dirent_size = tmp_size; + ret = EFI_CALL((*dirh->read)(dirh, &tmp_size, dirent)); + } + if (ret != EFI_SUCCESS) + goto err; + if (!tmp_size) + break; + + if (!(dirent->attribute & EFI_FILE_DIRECTORY) && + u16_strcmp(dirent->file_name, L".") && + u16_strcmp(dirent->file_name, L"..")) + count++; + } + + ret = EFI_CALL((*dirh->setpos)(dirh, 0)); + if (ret != EFI_SUCCESS) + goto err; + + /* make a list */ + tmp_files = malloc(count * sizeof(*files)); + if (!tmp_files) { + ret = EFI_OUT_OF_RESOURCES; + goto err; + } + + count = 0; + while (1) { + tmp_size = dirent_size; + ret = EFI_CALL((*dirh->read)(dirh, &tmp_size, dirent)); + if (ret != EFI_SUCCESS) + goto err; + if (!tmp_size) + break; + + if (!(dirent->attribute & EFI_FILE_DIRECTORY) && + u16_strcmp(dirent->file_name, L".") && + u16_strcmp(dirent->file_name, L"..")) + tmp_files[count++] = u16_strdup(dirent->file_name); + } + /* ignore an error */ + EFI_CALL((*dirh->close)(dirh)); + + /* in ascii order */ + /* FIXME: u16 version of strcasecmp */ + qsort(tmp_files, count, sizeof(*tmp_files), + (int (*)(const void *, const void *))strcasecmp); + *files = tmp_files; + *num = count; + ret = EFI_SUCCESS; +err: + free(dirent); + + return ret; +} + +/** + * efi_capsule_read_file - read in a capsule file + * @filename: File name + * @capsule: Pointer to buffer for capsule + * + * Read a capsule file and put its content in @capsule. + * + * Return: status code + */ +static efi_status_t efi_capsule_read_file(const u16 *filename, + struct efi_capsule_header **capsule) +{ + struct efi_file_handle *dirh, *fh; + struct efi_file_info *file_info = NULL; + struct efi_capsule_header *buf = NULL; + efi_uintn_t size; + efi_status_t ret; + + ret = EFI_CALL((*bootdev_root->open)(bootdev_root, &dirh, + EFI_CAPSULE_DIR, + EFI_FILE_MODE_READ, 0)); + if (ret != EFI_SUCCESS) + return ret; + ret = EFI_CALL((*dirh->open)(dirh, &fh, (u16 *)filename, + EFI_FILE_MODE_READ, 0)); + /* ignore an error */ + EFI_CALL((*dirh->close)(dirh)); + if (ret != EFI_SUCCESS) + return ret; + + /* file size */ + size = 0; + ret = EFI_CALL((*fh->getinfo)(fh, &efi_file_info_guid, + &size, file_info)); + if (ret == EFI_BUFFER_TOO_SMALL) { + file_info = malloc(size); + if (!file_info) { + ret = EFI_OUT_OF_RESOURCES; + goto err; + } + ret = EFI_CALL((*fh->getinfo)(fh, &efi_file_info_guid, + &size, file_info)); + } + if (ret != EFI_SUCCESS) + goto err; + size = file_info->file_size; + free(file_info); + buf = malloc(size); + if (!buf) { + ret = EFI_OUT_OF_RESOURCES; + goto err; + } + + /* fetch data */ + ret = EFI_CALL((*fh->read)(fh, &size, buf)); + if (ret == EFI_SUCCESS) { + if (size >= buf->capsule_image_size) { + *capsule = buf; + } else { + free(buf); + ret = EFI_INVALID_PARAMETER; + } + } else { + free(buf); + } +err: + EFI_CALL((*fh->close)(fh)); + + return ret; +} + +/** + * efi_capsule_delete_file - delete a capsule file + * @filename: File name + * + * Delete a capsule file from capsule directory. + * + * Return: status code + */ +static efi_status_t efi_capsule_delete_file(const u16 *filename) +{ + struct efi_file_handle *dirh, *fh; + efi_status_t ret; + + ret = EFI_CALL((*bootdev_root->open)(bootdev_root, &dirh, + EFI_CAPSULE_DIR, + EFI_FILE_MODE_READ, 0)); + if (ret != EFI_SUCCESS) + return ret; + ret = EFI_CALL((*dirh->open)(dirh, &fh, (u16 *)filename, + EFI_FILE_MODE_READ, 0)); + /* ignore an error */ + EFI_CALL((*dirh->close)(dirh)); + + ret = EFI_CALL((*fh->delete)(fh)); + + return ret; +} + +/** + * efi_capsule_scan_done - reset a scan help function + * + * Reset a scan help function + */ +static void efi_capsule_scan_done(void) +{ + EFI_CALL((*bootdev_root->close)(bootdev_root)); + bootdev_root = NULL; +} + +/** + * arch_efi_load_capsule_drivers - initialize capsule drivers + * + * Architecture or board specific initialization routine + * + * Return: status code + */ +efi_status_t __weak arch_efi_load_capsule_drivers(void) +{ + __maybe_unused efi_handle_t handle; + efi_status_t ret = EFI_SUCCESS; + + if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)) { + handle = NULL; + ret = EFI_CALL(efi_install_multiple_protocol_interfaces( + &handle, &efi_guid_firmware_management_protocol, + &efi_fmp_fit, NULL)); + } + + if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)) { + handle = NULL; + ret = EFI_CALL(efi_install_multiple_protocol_interfaces( + &efi_root, + &efi_guid_firmware_management_protocol, + &efi_fmp_raw, NULL)); + } + + return ret; +} + +/** + * efi_launch_capsule - launch capsules + * + * Launch all the capsules in system at boot time. + * Called by efi init code + * + * Return: status codde + */ +efi_status_t efi_launch_capsules(void) +{ + u64 os_indications; + efi_uintn_t size; + struct efi_capsule_header *capsule = NULL; + u16 **files; + unsigned int nfiles, index, i; + u16 variable_name16[12]; + efi_status_t ret; + + size = sizeof(os_indications); + ret = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid, + NULL, &size, &os_indications, NULL); + if (ret != EFI_SUCCESS || + !(os_indications + & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED)) + return EFI_SUCCESS; + + index = get_last_capsule(); + + /* Load capsule drivers */ + ret = arch_efi_load_capsule_drivers(); + if (ret != EFI_SUCCESS) + return ret; + + /* + * Find capsules on disk. + * All the capsules are collected at the beginning because + * capsule files will be removed instantly. + */ + nfiles = 0; + files = NULL; + ret = efi_capsule_scan_dir(&files, &nfiles); + if (ret != EFI_SUCCESS) + return ret; + if (!nfiles) + return EFI_SUCCESS; + + /* Launch capsules */ + for (i = 0, ++index; i < nfiles; i++, index++) { + log_debug("capsule from %ls ...\n", files[i]); + if (index > 0xffff) + index = 0; + ret = efi_capsule_read_file(files[i], &capsule); + if (ret == EFI_SUCCESS) { + ret = EFI_CALL(efi_update_capsule(&capsule, 1, 0)); + if (ret != EFI_SUCCESS) + log_err("EFI Capsule update failed at %ls\n", + files[i]); + + free(capsule); + } else { + log_err("EFI: reading capsule failed: %ls\n", files[i]); + } + /* create CapsuleXXXX */ + set_capsule_result(index, capsule, ret); + + /* delete a capsule either in case of success or failure */ + ret = efi_capsule_delete_file(files[i]); + if (ret != EFI_SUCCESS) + log_err("EFI: deleting a capsule file failed: %ls\n", + files[i]); + } + efi_capsule_scan_done(); + + for (i = 0; i < nfiles; i++) + free(files[i]); + free(files); + + /* CapsuleLast */ + efi_create_indexed_name(variable_name16, sizeof(variable_name16), + "Capsule", index - 1); + efi_set_variable_int(L"CapsuleLast", &efi_guid_capsule_report, + EFI_VARIABLE_READ_ONLY | + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + 22, variable_name16, false); + + return ret; +} +#endif /* CONFIG_EFI_CAPSULE_ON_DISK */ diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 8a5c13c424..c9315dd458 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -531,7 +531,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) case UCLASS_ETH: { struct efi_device_path_mac_addr *dp = dp_fill(buf, dev->parent); - struct eth_pdata *pdata = dev->platdata; + struct eth_pdata *pdata = dev_get_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR; @@ -551,7 +551,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) case UCLASS_ROOT: { /* stop traversing parents at this point: */ struct efi_device_path_vendor *dp; - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); dp_fill(buf, dev->parent); dp = buf; @@ -568,7 +568,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) #ifdef CONFIG_VIRTIO_BLK case UCLASS_VIRTIO: { struct efi_device_path_vendor *dp; - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); dp_fill(buf, dev->parent); dp = buf; @@ -586,7 +586,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) case UCLASS_IDE: { struct efi_device_path_atapi *dp = dp_fill(buf, dev->parent); - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_ATAPI; @@ -603,7 +603,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) case UCLASS_SCSI: { struct efi_device_path_scsi *dp = dp_fill(buf, dev->parent); - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_SCSI; @@ -617,14 +617,14 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) case UCLASS_MMC: { struct efi_device_path_sd_mmc_path *sddp = dp_fill(buf, dev->parent); - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); sddp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; sddp->dp.sub_type = is_sd(desc) ? DEVICE_PATH_SUB_TYPE_MSG_SD : DEVICE_PATH_SUB_TYPE_MSG_MMC; sddp->dp.length = sizeof(*sddp); - sddp->slot_number = dev->seq; + sddp->slot_number = dev_seq(dev); return &sddp[1]; } #endif @@ -632,7 +632,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) case UCLASS_AHCI: { struct efi_device_path_sata *dp = dp_fill(buf, dev->parent); - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_SATA; @@ -677,7 +677,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) DEVICE_PATH_SUB_TYPE_MSG_SD : DEVICE_PATH_SUB_TYPE_MSG_MMC; sddp->dp.length = sizeof(*sddp); - sddp->slot_number = dev->seq; + sddp->slot_number = dev_seq(dev); return &sddp[1]; } diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 7bd1ccec45..26b953461b 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -376,6 +376,23 @@ static efi_status_t efi_disk_add_dev( /* Fill in object data */ if (part) { struct efi_device_path *node = efi_dp_part_node(desc, part); + struct efi_handler *handler; + void *protocol_interface; + + /* Parent must expose EFI_BLOCK_IO_PROTOCOL */ + ret = efi_search_protocol(parent, &efi_block_io_guid, &handler); + if (ret != EFI_SUCCESS) + goto error; + + /* + * Link the partition (child controller) to the block device + * (controller). + */ + ret = efi_protocol_open(handler, &protocol_interface, NULL, + &diskobj->header, + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); + if (ret != EFI_SUCCESS) + goto error; diskobj->dp = efi_dp_append_node(dp_parent, node); efi_free_pool(node); @@ -453,6 +470,9 @@ static efi_status_t efi_disk_add_dev( } } return EFI_SUCCESS; +error: + efi_delete_handle(&diskobj->header); + return ret; } /** @@ -527,7 +547,7 @@ efi_status_t efi_disk_register(void) for (uclass_first_device_check(UCLASS_BLK, &dev); dev; uclass_next_device_check(&dev)) { - struct blk_desc *desc = dev_get_uclass_platdata(dev); + struct blk_desc *desc = dev_get_uclass_plat(dev); const char *if_typename = blk_get_if_type_name(desc->if_type); /* Add block device for the full device */ diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c new file mode 100644 index 0000000000..5e401bbca2 --- /dev/null +++ b/lib/efi_loader/efi_firmware.c @@ -0,0 +1,478 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI Firmware management protocol + * + * Copyright (c) 2020 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include <common.h> +#include <charset.h> +#include <dfu.h> +#include <efi_loader.h> +#include <image.h> +#include <signatures.h> + +#include <linux/list.h> + +#define FMP_PAYLOAD_HDR_SIGNATURE SIGNATURE_32('M', 'S', 'S', '1') + +/** + * struct fmp_payload_header - EDK2 header for the FMP payload + * + * This structure describes the header which is preprended to the + * FMP payload by the edk2 capsule generation scripts. + * + * @signature: Header signature used to identify the header + * @header_size: Size of the structure + * @fw_version: Firmware versions used + * @lowest_supported_version: Lowest supported version + */ +struct fmp_payload_header { + u32 signature; + u32 header_size; + u32 fw_version; + u32 lowest_supported_version; +}; + +/* Place holder; not supported */ +static +efi_status_t EFIAPI efi_firmware_get_image_unsupported( + struct efi_firmware_management_protocol *this, + u8 image_index, + void *image, + efi_uintn_t *image_size) +{ + EFI_ENTRY("%p %d %p %p\n", this, image_index, image, image_size); + + return EFI_EXIT(EFI_UNSUPPORTED); +} + +/* Place holder; not supported */ +static +efi_status_t EFIAPI efi_firmware_check_image_unsupported( + struct efi_firmware_management_protocol *this, + u8 image_index, + const void *image, + efi_uintn_t *image_size, + u32 *image_updatable) +{ + EFI_ENTRY("%p %d %p %p %p\n", this, image_index, image, image_size, + image_updatable); + + return EFI_EXIT(EFI_UNSUPPORTED); +} + +/* Place holder; not supported */ +static +efi_status_t EFIAPI efi_firmware_get_package_info_unsupported( + struct efi_firmware_management_protocol *this, + u32 *package_version, + u16 **package_version_name, + u32 *package_version_name_maxlen, + u64 *attributes_supported, + u64 *attributes_setting) +{ + EFI_ENTRY("%p %p %p %p %p %p\n", this, package_version, + package_version_name, package_version_name_maxlen, + attributes_supported, attributes_setting); + + return EFI_EXIT(EFI_UNSUPPORTED); +} + +/* Place holder; not supported */ +static +efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( + struct efi_firmware_management_protocol *this, + const void *image, + efi_uintn_t *image_size, + const void *vendor_code, + u32 package_version, + const u16 *package_version_name) +{ + EFI_ENTRY("%p %p %p %p %x %p\n", this, image, image_size, vendor_code, + package_version, package_version_name); + + return EFI_EXIT(EFI_UNSUPPORTED); +} + +/** + * efi_get_dfu_info - return information about the current firmware image + * @this: Protocol instance + * @image_info_size: Size of @image_info + * @image_info: Image information + * @descriptor_version: Pointer to version number + * @descriptor_count: Pointer to number of descriptors + * @descriptor_size: Pointer to descriptor size + * package_version: Package version + * package_version_name: Package version's name + * image_type: Image type GUID + * + * Return information bout the current firmware image in @image_info. + * @image_info will consist of a number of descriptors. + * Each descriptor will be created based on "dfu_alt_info" variable. + * + * Return status code + */ +static efi_status_t efi_get_dfu_info( + efi_uintn_t *image_info_size, + struct efi_firmware_image_descriptor *image_info, + u32 *descriptor_version, + u8 *descriptor_count, + efi_uintn_t *descriptor_size, + u32 *package_version, + u16 **package_version_name, + const efi_guid_t *image_type) +{ + struct dfu_entity *dfu; + size_t names_len, total_size; + int dfu_num, i; + u16 *name, *next; + + dfu_init_env_entities(NULL, NULL); + + names_len = 0; + dfu_num = 0; + list_for_each_entry(dfu, &dfu_list, list) { + names_len += (utf8_utf16_strlen(dfu->name) + 1) * 2; + dfu_num++; + } + if (!dfu_num) { + log_warning("Probably dfu_alt_info not defined\n"); + *image_info_size = 0; + dfu_free_entities(); + + return EFI_SUCCESS; + } + + total_size = sizeof(*image_info) * dfu_num + names_len; + /* + * we will assume that sizeof(*image_info) * dfu_name + * is, at least, a multiple of 2. So the start address for + * image_id_name would be aligned with 2 bytes. + */ + if (*image_info_size < total_size) { + *image_info_size = total_size; + dfu_free_entities(); + + return EFI_BUFFER_TOO_SMALL; + } + *image_info_size = total_size; + + *descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; + *descriptor_count = dfu_num; + *descriptor_size = sizeof(*image_info); + *package_version = 0xffffffff; /* not supported */ + *package_version_name = NULL; /* not supported */ + + /* DFU alt number should correspond to image_index */ + i = 0; + /* Name area starts just after descriptors */ + name = (u16 *)((u8 *)image_info + sizeof(*image_info) * dfu_num); + next = name; + list_for_each_entry(dfu, &dfu_list, list) { + image_info[i].image_index = dfu->alt + 1; + image_info[i].image_type_id = *image_type; + image_info[i].image_id = dfu->alt; + + /* copy the DFU entity name */ + utf8_utf16_strcpy(&next, dfu->name); + image_info[i].image_id_name = name; + name = ++next; + + image_info[i].version = 0; /* not supported */ + image_info[i].version_name = NULL; /* not supported */ + image_info[i].size = 0; + image_info[i].attributes_supported = + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED; + image_info[i].attributes_setting = + IMAGE_ATTRIBUTE_IMAGE_UPDATABLE; + + /* Check if the capsule authentication is enabled */ + if (env_get("capsule_authentication_enabled")) + image_info[0].attributes_setting |= + IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED; + + image_info[i].lowest_supported_image_version = 0; + image_info[i].last_attempt_version = 0; + image_info[i].last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS; + image_info[i].hardware_instance = 1; + image_info[i].dependencies = NULL; + + i++; + } + + dfu_free_entities(); + + return EFI_SUCCESS; +} + +#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_FIT +/* + * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update + * method with existing FIT image format, and handles + * - multiple regions of firmware via DFU + * but doesn't support + * - versioning of firmware image + * - package information + */ +const efi_guid_t efi_firmware_image_type_uboot_fit = + EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID; + +/** + * efi_firmware_fit_get_image_info - return information about the current + * firmware image + * @this: Protocol instance + * @image_info_size: Size of @image_info + * @image_info: Image information + * @descriptor_version: Pointer to version number + * @descriptor_count: Pointer to number of descriptors + * @descriptor_size: Pointer to descriptor size + * package_version: Package version + * package_version_name: Package version's name + * + * Return information bout the current firmware image in @image_info. + * @image_info will consist of a number of descriptors. + * Each descriptor will be created based on "dfu_alt_info" variable. + * + * Return status code + */ +static +efi_status_t EFIAPI efi_firmware_fit_get_image_info( + struct efi_firmware_management_protocol *this, + efi_uintn_t *image_info_size, + struct efi_firmware_image_descriptor *image_info, + u32 *descriptor_version, + u8 *descriptor_count, + efi_uintn_t *descriptor_size, + u32 *package_version, + u16 **package_version_name) +{ + efi_status_t ret; + + EFI_ENTRY("%p %p %p %p %p %p %p %p\n", this, + image_info_size, image_info, + descriptor_version, descriptor_count, descriptor_size, + package_version, package_version_name); + + if (!image_info_size) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + if (*image_info_size && + (!image_info || !descriptor_version || !descriptor_count || + !descriptor_size || !package_version || !package_version_name)) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + ret = efi_get_dfu_info(image_info_size, image_info, + descriptor_version, descriptor_count, + descriptor_size, + package_version, package_version_name, + &efi_firmware_image_type_uboot_fit); + + return EFI_EXIT(ret); +} + +/** + * efi_firmware_fit_set_image - update the firmware image + * @this: Protocol instance + * @image_index: Image index number + * @image: New image + * @image_size: Size of new image + * @vendor_code: Vendor-specific update policy + * @progress: Function to report the progress of update + * @abort_reason: Pointer to string of abort reason + * + * Update the firmware to new image, using dfu. The new image should + * have FIT image format commonly used in U-Boot. + * @vendor_code, @progress and @abort_reason are not supported. + * + * Return: status code + */ +static +efi_status_t EFIAPI efi_firmware_fit_set_image( + struct efi_firmware_management_protocol *this, + u8 image_index, + const void *image, + efi_uintn_t image_size, + const void *vendor_code, + efi_status_t (*progress)(efi_uintn_t completion), + u16 **abort_reason) +{ + EFI_ENTRY("%p %d %p %ld %p %p %p\n", this, image_index, image, + image_size, vendor_code, progress, abort_reason); + + if (!image || image_index != 1) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + if (fit_update(image)) + return EFI_EXIT(EFI_DEVICE_ERROR); + + return EFI_EXIT(EFI_SUCCESS); +} + +const struct efi_firmware_management_protocol efi_fmp_fit = { + .get_image_info = efi_firmware_fit_get_image_info, + .get_image = efi_firmware_get_image_unsupported, + .set_image = efi_firmware_fit_set_image, + .check_image = efi_firmware_check_image_unsupported, + .get_package_info = efi_firmware_get_package_info_unsupported, + .set_package_info = efi_firmware_set_package_info_unsupported, +}; +#endif /* CONFIG_EFI_CAPSULE_FIRMWARE_FIT */ + +#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_RAW +/* + * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update + * method with raw data. + */ +const efi_guid_t efi_firmware_image_type_uboot_raw = + EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID; + +/** + * efi_firmware_raw_get_image_info - return information about the current + firmware image + * @this: Protocol instance + * @image_info_size: Size of @image_info + * @image_info: Image information + * @descriptor_version: Pointer to version number + * @descriptor_count: Pointer to number of descriptors + * @descriptor_size: Pointer to descriptor size + * package_version: Package version + * package_version_name: Package version's name + * + * Return information bout the current firmware image in @image_info. + * @image_info will consist of a number of descriptors. + * Each descriptor will be created based on "dfu_alt_info" variable. + * + * Return status code + */ +static +efi_status_t EFIAPI efi_firmware_raw_get_image_info( + struct efi_firmware_management_protocol *this, + efi_uintn_t *image_info_size, + struct efi_firmware_image_descriptor *image_info, + u32 *descriptor_version, + u8 *descriptor_count, + efi_uintn_t *descriptor_size, + u32 *package_version, + u16 **package_version_name) +{ + efi_status_t ret = EFI_SUCCESS; + + EFI_ENTRY("%p %p %p %p %p %p %p %p\n", this, + image_info_size, image_info, + descriptor_version, descriptor_count, descriptor_size, + package_version, package_version_name); + + if (!image_info_size) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + if (*image_info_size && + (!image_info || !descriptor_version || !descriptor_count || + !descriptor_size || !package_version || !package_version_name)) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + ret = efi_get_dfu_info(image_info_size, image_info, + descriptor_version, descriptor_count, + descriptor_size, + package_version, package_version_name, + &efi_firmware_image_type_uboot_raw); + + return EFI_EXIT(ret); +} + +/** + * efi_firmware_raw_set_image - update the firmware image + * @this: Protocol instance + * @image_index: Image index number + * @image: New image + * @image_size: Size of new image + * @vendor_code: Vendor-specific update policy + * @progress: Function to report the progress of update + * @abort_reason: Pointer to string of abort reason + * + * Update the firmware to new image, using dfu. The new image should + * be a single raw image. + * @vendor_code, @progress and @abort_reason are not supported. + * + * Return: status code + */ +static +efi_status_t EFIAPI efi_firmware_raw_set_image( + struct efi_firmware_management_protocol *this, + u8 image_index, + const void *image, + efi_uintn_t image_size, + const void *vendor_code, + efi_status_t (*progress)(efi_uintn_t completion), + u16 **abort_reason) +{ + u32 fmp_hdr_signature; + struct fmp_payload_header *header; + void *capsule_payload; + efi_status_t status; + efi_uintn_t capsule_payload_size; + + EFI_ENTRY("%p %d %p %ld %p %p %p\n", this, image_index, image, + image_size, vendor_code, progress, abort_reason); + + if (!image) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + /* Authenticate the capsule if authentication enabled */ + if (IS_ENABLED(CONFIG_EFI_CAPSULE_AUTHENTICATE) && + env_get("capsule_authentication_enabled")) { + capsule_payload = NULL; + capsule_payload_size = 0; + status = efi_capsule_authenticate(image, image_size, + &capsule_payload, + &capsule_payload_size); + + if (status == EFI_SECURITY_VIOLATION) { + printf("Capsule authentication check failed. Aborting update\n"); + return EFI_EXIT(status); + } else if (status != EFI_SUCCESS) { + return EFI_EXIT(status); + } + + debug("Capsule authentication successfull\n"); + image = capsule_payload; + image_size = capsule_payload_size; + } else { + debug("Capsule authentication disabled. "); + debug("Updating capsule without authenticating.\n"); + } + + fmp_hdr_signature = FMP_PAYLOAD_HDR_SIGNATURE; + header = (void *)image; + + if (!memcmp(&header->signature, &fmp_hdr_signature, + sizeof(fmp_hdr_signature))) { + /* + * When building the capsule with the scripts in + * edk2, a FMP header is inserted above the capsule + * payload. Compensate for this header to get the + * actual payload that is to be updated. + */ + image += header->header_size; + image_size -= header->header_size; + + } + + if (dfu_write_by_alt(image_index - 1, (void *)image, image_size, + NULL, NULL)) + return EFI_EXIT(EFI_DEVICE_ERROR); + + return EFI_EXIT(EFI_SUCCESS); +} + +const struct efi_firmware_management_protocol efi_fmp_raw = { + .get_image_info = efi_firmware_raw_get_image_info, + .get_image = efi_firmware_get_image_unsupported, + .set_image = efi_firmware_raw_set_image, + .check_image = efi_firmware_check_image_unsupported, + .get_package_info = efi_firmware_get_package_info_unsupported, + .set_package_info = efi_firmware_set_package_info_unsupported, +}; +#endif /* CONFIG_EFI_CAPSULE_FIRMWARE_RAW */ diff --git a/lib/efi_loader/efi_hii_config.c b/lib/efi_loader/efi_hii_config.c index 26ea4b9bc0..237e8acf84 100644 --- a/lib/efi_loader/efi_hii_config.c +++ b/lib/efi_loader/efi_hii_config.c @@ -1,9 +1,13 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * EFI Human Interface Infrastructure ... Configuration + * EFI Human Interface Infrastructure ... Configuration * - * Copyright (c) 2017 Leif Lindholm - * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited + * Copyright (c) 2017 Leif Lindholm + * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited + * + * As this is still a non-working stub and the protocol is neither required + * by the EFI shell nor by the UEFI SCT this module has been removed from + * the Makefile. */ #include <common.h> diff --git a/lib/efi_loader/efi_load_initrd.c b/lib/efi_loader/efi_load_initrd.c index d517d686c3..b9ee883905 100644 --- a/lib/efi_loader/efi_load_initrd.c +++ b/lib/efi_loader/efi_load_initrd.c @@ -4,16 +4,11 @@ */ #include <common.h> -#include <env.h> -#include <malloc.h> -#include <mapmem.h> -#include <dm.h> -#include <fs.h> #include <efi_loader.h> #include <efi_load_initrd.h> - -static const efi_guid_t efi_guid_load_file2_protocol = - EFI_LOAD_FILE2_PROTOCOL_GUID; +#include <fs.h> +#include <malloc.h> +#include <mapmem.h> static efi_status_t EFIAPI efi_load_file2_initrd(struct efi_load_file_protocol *this, diff --git a/lib/efi_loader/efi_root_node.c b/lib/efi_loader/efi_root_node.c index f68b0fdc61..b17db312f7 100644 --- a/lib/efi_loader/efi_root_node.c +++ b/lib/efi_loader/efi_root_node.c @@ -77,9 +77,6 @@ efi_status_t efi_root_node_register(void) /* HII database protocol */ &efi_guid_hii_database_protocol, (void *)&efi_hii_database, - /* HII configuration routing protocol */ - &efi_guid_hii_config_routing_protocol, - (void *)&efi_hii_config_routing, #endif NULL)); efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE; diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 1fa1595e40..93c9478b22 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -449,6 +449,50 @@ efi_status_t __weak __efi_runtime EFIAPI efi_set_time(struct efi_time *time) } /** + * efi_update_capsule_unsupported() - process information from operating system + * + * This function implements the UpdateCapsule() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @capsule_header_array: pointer to array of virtual pointers + * @capsule_count: number of pointers in capsule_header_array + * @scatter_gather_list: pointer to array of physical pointers + * Returns: status code + */ +efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 scatter_gather_list) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_query_capsule_caps_unsupported() - check if capsule is supported + * + * This function implements the QueryCapsuleCapabilities() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @capsule_header_array: pointer to array of virtual pointers + * @capsule_count: number of pointers in capsule_header_array + * @maximum_capsule_size: maximum capsule size + * @reset_type: type of reset needed for capsule update + * Returns: status code + */ +efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps_unsupported( + struct efi_capsule_header **capsule_header_array, + efi_uintn_t capsule_count, + u64 *maximum_capsule_size, + u32 *reset_type) +{ + return EFI_UNSUPPORTED; +} + +/** * efi_is_runtime_service_pointer() - check if pointer points to runtime table * * @p: pointer to check @@ -471,6 +515,13 @@ void efi_runtime_detach(void) efi_runtime_services.reset_system = efi_reset_system; efi_runtime_services.get_time = efi_get_time; efi_runtime_services.set_time = efi_set_time; + if (IS_ENABLED(CONFIG_EFI_RUNTIME_UPDATE_CAPSULE)) { + /* won't support at runtime */ + efi_runtime_services.update_capsule = + efi_update_capsule_unsupported; + efi_runtime_services.query_capsule_caps = + efi_query_capsule_caps_unsupported; + } /* Update CRC32 */ efi_update_table_header_crc32(&efi_runtime_services.hdr); @@ -879,50 +930,6 @@ static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void) return EFI_UNSUPPORTED; } -/** - * efi_update_capsule() - process information from operating system - * - * This function implements the UpdateCapsule() runtime service. - * - * See the Unified Extensible Firmware Interface (UEFI) specification for - * details. - * - * @capsule_header_array: pointer to array of virtual pointers - * @capsule_count: number of pointers in capsule_header_array - * @scatter_gather_list: pointer to arry of physical pointers - * Returns: status code - */ -efi_status_t __efi_runtime EFIAPI efi_update_capsule( - struct efi_capsule_header **capsule_header_array, - efi_uintn_t capsule_count, - u64 scatter_gather_list) -{ - return EFI_UNSUPPORTED; -} - -/** - * efi_query_capsule_caps() - check if capsule is supported - * - * This function implements the QueryCapsuleCapabilities() runtime service. - * - * See the Unified Extensible Firmware Interface (UEFI) specification for - * details. - * - * @capsule_header_array: pointer to array of virtual pointers - * @capsule_count: number of pointers in capsule_header_array - * @maximum_capsule_size: maximum capsule size - * @reset_type: type of reset needed for capsule update - * Returns: status code - */ -efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps( - struct efi_capsule_header **capsule_header_array, - efi_uintn_t capsule_count, - u64 *maximum_capsule_size, - u32 *reset_type) -{ - return EFI_UNSUPPORTED; -} - struct efi_runtime_services __efi_runtime_data efi_runtime_services = { .hdr = { .signature = EFI_RUNTIME_SERVICES_SIGNATURE, @@ -940,7 +947,12 @@ struct efi_runtime_services __efi_runtime_data efi_runtime_services = { .set_variable = efi_set_variable, .get_next_high_mono_count = (void *)&efi_unimplemented, .reset_system = &efi_reset_system_boottime, +#ifdef CONFIG_EFI_RUNTIME_UPDATE_CAPSULE .update_capsule = efi_update_capsule, .query_capsule_caps = efi_query_capsule_caps, +#else + .update_capsule = efi_update_capsule_unsupported, + .query_capsule_caps = efi_query_capsule_caps_unsupported, +#endif .query_variable_info = efi_query_variable_info, }; diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index e206b60bb8..5800cbf6d4 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -100,9 +100,9 @@ static efi_status_t efi_init_secure_boot(void) ret = efi_set_variable_int(L"SignatureSupport", &efi_global_variable_guid, + EFI_VARIABLE_READ_ONLY | EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS | - EFI_VARIABLE_READ_ONLY, + EFI_VARIABLE_RUNTIME_ACCESS, sizeof(signature_types), &signature_types, false); if (ret != EFI_SUCCESS) @@ -118,13 +118,67 @@ static efi_status_t efi_init_secure_boot(void) #endif /* CONFIG_EFI_SECURE_BOOT */ /** + * efi_init_capsule - initialize capsule update state + * + * Return: status code + */ +static efi_status_t efi_init_capsule(void) +{ + efi_status_t ret = EFI_SUCCESS; + + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_UPDATE)) { + ret = efi_set_variable_int(L"CapsuleMax", + &efi_guid_capsule_report, + EFI_VARIABLE_READ_ONLY | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + 22, L"CapsuleFFFF", false); + if (ret != EFI_SUCCESS) + printf("EFI: cannot initialize CapsuleMax variable\n"); + } + + return ret; +} + +/** + * efi_init_os_indications() - indicate supported features for OS requests + * + * Set the OsIndicationsSupported variable. + * + * Return: status code + */ +static efi_status_t efi_init_os_indications(void) +{ + u64 os_indications_supported = 0; + + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) + os_indications_supported |= + EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED; + + if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK)) + os_indications_supported |= + EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED; + + if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT)) + os_indications_supported |= + EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED; + + return efi_set_variable_int(L"OsIndicationsSupported", + &efi_global_variable_guid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS | + EFI_VARIABLE_READ_ONLY, + sizeof(os_indications_supported), + &os_indications_supported, false); +} + +/** * efi_init_obj_list() - Initialize and populate EFI object list * * Return: status code */ efi_status_t efi_init_obj_list(void) { - u64 os_indications_supported = 0; /* None */ efi_status_t ret = EFI_SUCCESS; /* Initialize once only */ @@ -157,12 +211,6 @@ efi_status_t efi_init_obj_list(void) goto out; } - if (IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL)) { - ret = efi_tcg2_register(); - if (ret != EFI_SUCCESS) - goto out; - } - /* Initialize variable services */ ret = efi_init_variables(); if (ret != EFI_SUCCESS) @@ -174,13 +222,7 @@ efi_status_t efi_init_obj_list(void) goto out; /* Indicate supported features */ - ret = efi_set_variable_int(L"OsIndicationsSupported", - &efi_global_variable_guid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS | - EFI_VARIABLE_READ_ONLY, - sizeof(os_indications_supported), - &os_indications_supported, false); + ret = efi_init_os_indications(); if (ret != EFI_SUCCESS) goto out; @@ -189,6 +231,12 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + if (IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL)) { + ret = efi_tcg2_register(); + if (ret != EFI_SUCCESS) + goto out; + } + /* Secure boot */ ret = efi_init_secure_boot(); if (ret != EFI_SUCCESS) @@ -209,11 +257,6 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; #endif -#ifdef CONFIG_EFI_LOAD_FILE2_INITRD - ret = efi_initrd_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif #ifdef CONFIG_NET ret = efi_net_register(); if (ret != EFI_SUCCESS) @@ -233,11 +276,19 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + ret = efi_init_capsule(); + if (ret != EFI_SUCCESS) + goto out; + /* Initialize EFI runtime services */ ret = efi_reset_system_init(); if (ret != EFI_SUCCESS) goto out; + /* Execute capsules after reboot */ + if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK) && + !IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) + ret = efi_launch_capsules(); out: efi_obj_list_initialized = ret; return ret; diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c index 79dee27421..c7ec275414 100644 --- a/lib/efi_loader/efi_signature.c +++ b/lib/efi_loader/efi_signature.c @@ -26,7 +26,92 @@ const efi_guid_t efi_guid_cert_x509 = EFI_CERT_X509_GUID; const efi_guid_t efi_guid_cert_x509_sha256 = EFI_CERT_X509_SHA256_GUID; const efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID; -#ifdef CONFIG_EFI_SECURE_BOOT +#if defined(CONFIG_EFI_SECURE_BOOT) || defined(CONFIG_EFI_CAPSULE_AUTHENTICATE) +static u8 pkcs7_hdr[] = { + /* SEQUENCE */ + 0x30, 0x82, 0x05, 0xc7, + /* OID: pkcs7-signedData */ + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, + /* Context Structured? */ + 0xa0, 0x82, 0x05, 0xb8, +}; + +/** + * efi_parse_pkcs7_header - parse a signature in payload + * @buf: Pointer to payload's value + * @buflen: Length of @buf + * @tmpbuf: Pointer to temporary buffer + * + * Parse a signature embedded in payload's value and instantiate + * a pkcs7_message structure. Since pkcs7_parse_message() accepts only + * pkcs7's signedData, some header needed be prepended for correctly + * parsing authentication data + * A temporary buffer will be allocated if needed, and it should be + * kept valid during the authentication because some data in the buffer + * will be referenced by efi_signature_verify(). + * + * Return: Pointer to pkcs7_message structure on success, NULL on error + */ +struct pkcs7_message *efi_parse_pkcs7_header(const void *buf, + size_t buflen, + u8 **tmpbuf) +{ + u8 *ebuf; + size_t ebuflen, len; + struct pkcs7_message *msg; + + /* + * This is the best assumption to check if the binary is + * already in a form of pkcs7's signedData. + */ + if (buflen > sizeof(pkcs7_hdr) && + !memcmp(&((u8 *)buf)[4], &pkcs7_hdr[4], 11)) { + msg = pkcs7_parse_message(buf, buflen); + if (IS_ERR(msg)) + return NULL; + return msg; + } + + /* + * Otherwise, we should add a dummy prefix sequence for pkcs7 + * message parser to be able to process. + * NOTE: EDK2 also uses similar hack in WrapPkcs7Data() + * in CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c + * TODO: + * The header should be composed in a more refined manner. + */ + EFI_PRINT("Makeshift prefix added to authentication data\n"); + ebuflen = sizeof(pkcs7_hdr) + buflen; + if (ebuflen <= 0x7f) { + EFI_PRINT("Data is too short\n"); + return NULL; + } + + ebuf = malloc(ebuflen); + if (!ebuf) { + EFI_PRINT("Out of memory\n"); + return NULL; + } + + memcpy(ebuf, pkcs7_hdr, sizeof(pkcs7_hdr)); + memcpy(ebuf + sizeof(pkcs7_hdr), buf, buflen); + len = ebuflen - 4; + ebuf[2] = (len >> 8) & 0xff; + ebuf[3] = len & 0xff; + len = ebuflen - 0x13; + ebuf[0x11] = (len >> 8) & 0xff; + ebuf[0x12] = len & 0xff; + + msg = pkcs7_parse_message(ebuf, ebuflen); + + if (IS_ERR(msg)) { + free(ebuf); + return NULL; + } + + *tmpbuf = ebuf; + return msg; +} /** * efi_hash_regions - calculate a hash value @@ -652,6 +737,63 @@ err: } /** + * efi_sigstore_parse_sigdb - parse the signature list and populate + * the signature store + * + * @sig_list: Pointer to the signature list + * @size: Size of the signature list + * + * Parse the efi signature list and instantiate a signature store + * structure. + * + * Return: Pointer to signature store on success, NULL on error + */ +struct efi_signature_store *efi_build_signature_store(void *sig_list, + efi_uintn_t size) +{ + struct efi_signature_list *esl; + struct efi_signature_store *sigstore = NULL, *siglist; + + esl = sig_list; + while (size > 0) { + /* List must exist if there is remaining data. */ + if (size < sizeof(*esl)) { + EFI_PRINT("Signature list in wrong format\n"); + goto err; + } + + if (size < esl->signature_list_size) { + EFI_PRINT("Signature list in wrong format\n"); + goto err; + } + + /* Parse a single siglist. */ + siglist = efi_sigstore_parse_siglist(esl); + if (!siglist) { + EFI_PRINT("Parsing of signature list of failed\n"); + goto err; + } + + /* Append siglist */ + siglist->next = sigstore; + sigstore = siglist; + + /* Next */ + size -= esl->signature_list_size; + esl = (void *)esl + esl->signature_list_size; + } + free(sig_list); + + return sigstore; + +err: + efi_sigstore_free(sigstore); + free(sig_list); + + return NULL; +} + +/** * efi_sigstore_parse_sigdb - parse a signature database variable * @name: Variable's name * @@ -662,8 +804,7 @@ err: */ struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name) { - struct efi_signature_store *sigstore = NULL, *siglist; - struct efi_signature_list *esl; + struct efi_signature_store *sigstore = NULL; const efi_guid_t *vendor; void *db; efi_uintn_t db_size; @@ -699,47 +840,10 @@ struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name) ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, db)); if (ret != EFI_SUCCESS) { EFI_PRINT("Getting variable, %ls, failed\n", name); - goto err; - } - - /* Parse siglist list */ - esl = db; - while (db_size > 0) { - /* List must exist if there is remaining data. */ - if (db_size < sizeof(*esl)) { - EFI_PRINT("variable, %ls, in wrong format\n", name); - goto err; - } - - if (db_size < esl->signature_list_size) { - EFI_PRINT("variable, %ls, in wrong format\n", name); - goto err; - } - - /* Parse a single siglist. */ - siglist = efi_sigstore_parse_siglist(esl); - if (!siglist) { - EFI_PRINT("Parsing signature list of %ls failed\n", - name); - goto err; - } - - /* Append siglist */ - siglist->next = sigstore; - sigstore = siglist; - - /* Next */ - db_size -= esl->signature_list_size; - esl = (void *)esl + esl->signature_list_size; + free(db); + return NULL; } - free(db); - return sigstore; - -err: - efi_sigstore_free(sigstore); - free(db); - - return NULL; + return efi_build_signature_store(db, db_size); } -#endif /* CONFIG_EFI_SECURE_BOOT */ +#endif /* CONFIG_EFI_SECURE_BOOT || CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/lib/efi_loader/efi_string.c b/lib/efi_loader/efi_string.c index 3de721f06c..9627242288 100644 --- a/lib/efi_loader/efi_string.c +++ b/lib/efi_loader/efi_string.c @@ -23,13 +23,19 @@ * Return: A pointer to the next position after the created string * in @buffer, or NULL otherwise */ -u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int index) +u16 *efi_create_indexed_name(u16 *buffer, size_t buffer_size, const char *name, + unsigned int index) { u16 *p = buffer; char index_buf[5]; + size_t size; + size = (utf8_utf16_strlen(name) * sizeof(u16) + + sizeof(index_buf) * sizeof(u16)); + if (buffer_size < size) + return NULL; utf8_utf16_strcpy(&p, name); - sprintf(index_buf, "%04X", index); + snprintf(index_buf, sizeof(index_buf), "%04X", index); utf8_utf16_strcpy(&p, index_buf); return p; diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 62f2f9427b..797d6eb134 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -14,11 +14,24 @@ #include <efi_tcg2.h> #include <log.h> #include <tpm-v2.h> +#include <u-boot/sha1.h> +#include <u-boot/sha256.h> +#include <u-boot/sha512.h> #include <linux/unaligned/access_ok.h> #include <linux/unaligned/generic.h> +#include <hexdump.h> + +struct event_log_buffer { + void *buffer; + void *final_buffer; + size_t pos; /* eventlog position */ + size_t final_pos; /* final events config table position */ + size_t last_event_size; + bool get_event_called; + bool truncated; +}; -DECLARE_GLOBAL_DATA_PTR; - +static struct event_log_buffer event_log; /* * When requesting TPM2_CAP_TPM_PROPERTIES the value is on a standard offset. * Since the current tpm2_get_capability() response buffers starts at @@ -30,33 +43,40 @@ DECLARE_GLOBAL_DATA_PTR; #define properties_offset (offsetof(struct tpml_tagged_tpm_property, tpm_property) + \ offsetof(struct tpms_tagged_property, value)) -struct { +static const efi_guid_t efi_guid_tcg2_protocol = EFI_TCG2_PROTOCOL_GUID; +static const efi_guid_t efi_guid_final_events = EFI_TCG2_FINAL_EVENTS_TABLE_GUID; + +struct digest_info { u16 hash_alg; u32 hash_mask; -} hash_algo_list[] = { + u16 hash_len; +}; + +const static struct digest_info hash_algo_list[] = { { TPM2_ALG_SHA1, EFI_TCG2_BOOT_HASH_ALG_SHA1, + TPM2_SHA1_DIGEST_SIZE, }, { TPM2_ALG_SHA256, EFI_TCG2_BOOT_HASH_ALG_SHA256, + TPM2_SHA256_DIGEST_SIZE, }, { TPM2_ALG_SHA384, EFI_TCG2_BOOT_HASH_ALG_SHA384, + TPM2_SHA384_DIGEST_SIZE, }, { TPM2_ALG_SHA512, EFI_TCG2_BOOT_HASH_ALG_SHA512, - }, - { - TPM2_ALG_SM3_256, - EFI_TCG2_BOOT_HASH_ALG_SM3_256, + TPM2_SHA512_DIGEST_SIZE, }, }; #define MAX_HASH_COUNT ARRAY_SIZE(hash_algo_list) + /** * alg_to_mask - Get a TCG hash mask for algorithms * @@ -76,7 +96,146 @@ static u32 alg_to_mask(u16 hash_alg) return 0; } -const efi_guid_t efi_guid_tcg2_protocol = EFI_TCG2_PROTOCOL_GUID; +/** + * alg_to_len - Get a TCG hash len for algorithms + * + * @hash_alg: TCG defined algorithm + * + * @Return: len of chosen algorithm, 0 if the algorithm is not supported + */ +static u16 alg_to_len(u16 hash_alg) +{ + int i; + + for (i = 0; i < MAX_HASH_COUNT; i++) { + if (hash_algo_list[i].hash_alg == hash_alg) + return hash_algo_list[i].hash_len; + } + + return 0; +} + +static u32 tcg_event_final_size(struct tpml_digest_values *digest_list) +{ + u32 len; + int i; + + len = offsetof(struct tcg_pcr_event2, digests); + len += offsetof(struct tpml_digest_values, digests); + for (i = 0; i < digest_list->count; i++) { + u16 hash_alg = digest_list->digests[i].hash_alg; + + len += offsetof(struct tpmt_ha, digest); + len += alg_to_len(hash_alg); + } + len += sizeof(u32); /* tcg_pcr_event2 event_size*/ + + return len; +} + +/* tcg2_pcr_extend - Extend PCRs for a TPM2 device for a given tpml_digest_values + * + * @dev: device + * @digest_list: list of digest algorithms to extend + * + * @Return: status code + */ +static efi_status_t tcg2_pcr_extend(struct udevice *dev, u32 pcr_index, + struct tpml_digest_values *digest_list) +{ + u32 rc; + int i; + + for (i = 0; i < digest_list->count; i++) { + u32 alg = digest_list->digests[i].hash_alg; + + rc = tpm2_pcr_extend(dev, pcr_index, alg, + (u8 *)&digest_list->digests[i].digest, + alg_to_len(alg)); + if (rc) { + EFI_PRINT("Failed to extend PCR\n"); + return EFI_DEVICE_ERROR; + } + } + + return EFI_SUCCESS; +} + +/* tcg2_agile_log_append - Append an agile event to out eventlog + * + * @pcr_index: PCR index + * @event_type: type of event added + * @digest_list: list of digest algorithms to add + * @size: size of event + * @event: event to add + * + * @Return: status code + */ +static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, + struct tpml_digest_values *digest_list, + u32 size, u8 event[]) +{ + void *log = event_log.buffer + event_log.pos; + size_t pos; + int i; + u32 event_size; + + if (event_log.get_event_called) + log = event_log.final_buffer + event_log.final_pos; + + /* + * size refers to the length of event[] only, we need to check against + * the final tcg_pcr_event2 size + */ + event_size = size + tcg_event_final_size(digest_list); + if (event_log.pos + event_size > TPM2_EVENT_LOG_SIZE || + event_log.final_pos + event_size > TPM2_EVENT_LOG_SIZE) { + event_log.truncated = true; + return EFI_VOLUME_FULL; + } + + put_unaligned_le32(pcr_index, log); + pos = offsetof(struct tcg_pcr_event2, event_type); + put_unaligned_le32(event_type, log + pos); + pos = offsetof(struct tcg_pcr_event2, digests); /* count */ + put_unaligned_le32(digest_list->count, log + pos); + + pos += offsetof(struct tpml_digest_values, digests); + for (i = 0; i < digest_list->count; i++) { + u16 hash_alg = digest_list->digests[i].hash_alg; + u8 *digest = (u8 *)&digest_list->digests[i].digest; + + put_unaligned_le16(hash_alg, log + pos); + pos += offsetof(struct tpmt_ha, digest); + memcpy(log + pos, digest, alg_to_len(hash_alg)); + pos += alg_to_len(hash_alg); + } + + put_unaligned_le32(size, log + pos); + pos += sizeof(u32); /* tcg_pcr_event2 event_size*/ + memcpy(log + pos, event, size); + pos += size; + + /* make sure the calculated buffer is what we checked against */ + if (pos != event_size) + return EFI_INVALID_PARAMETER; + + /* if GetEventLog hasn't been called update the normal log */ + if (!event_log.get_event_called) { + event_log.pos += pos; + event_log.last_event_size = pos; + } else { + /* if GetEventLog has been called update config table log */ + struct efi_tcg2_final_events_table *final_event; + + final_event = + (struct efi_tcg2_final_events_table *)(event_log.final_buffer); + final_event->number_of_events++; + event_log.final_pos += pos; + } + + return EFI_SUCCESS; +} /** * platform_get_tpm_device() - retrieve TPM device @@ -208,7 +367,7 @@ static int tpm2_get_num_pcr(struct udevice *dev, u32 *num_pcr) * * Return: true if PCR is active */ -bool is_active_pcr(struct tpms_pcr_selection *selection) +static bool is_active_pcr(struct tpms_pcr_selection *selection) { int i; /* @@ -309,6 +468,103 @@ out: } /** + * __get_active_pcr_banks() - returns the currently active PCR banks + * + * @active_pcr_banks: pointer for receiving the bitmap of currently + * active PCR banks + * + * Return: status code + */ +static efi_status_t __get_active_pcr_banks(u32 *active_pcr_banks) +{ + struct udevice *dev; + u32 active, supported, pcr_banks; + efi_status_t ret; + int err; + + ret = platform_get_tpm2_device(&dev); + if (ret != EFI_SUCCESS) + goto out; + + err = tpm2_get_pcr_info(dev, &supported, &active, &pcr_banks); + if (err) { + ret = EFI_DEVICE_ERROR; + goto out; + } + + *active_pcr_banks = active; + +out: + return ret; +} + +/* tcg2_create_digest - create a list of digests of the supported PCR banks + * for a given memory range + * + * @input: input memory + * @length: length of buffer to calculate the digest + * @digest_list: list of digests to fill in + * + * Return: status code + */ +static efi_status_t tcg2_create_digest(const u8 *input, u32 length, + struct tpml_digest_values *digest_list) +{ + sha1_context ctx; + sha256_context ctx_256; + sha512_context ctx_512; + u8 final[TPM2_ALG_SHA512]; + efi_status_t ret; + u32 active; + int i; + + ret = __get_active_pcr_banks(&active); + if (ret != EFI_SUCCESS) + return ret; + + digest_list->count = 0; + for (i = 0; i < MAX_HASH_COUNT; i++) { + u16 hash_alg = hash_algo_list[i].hash_alg; + + if (!(active & alg_to_mask(hash_alg))) + continue; + switch (hash_alg) { + case TPM2_ALG_SHA1: + sha1_starts(&ctx); + sha1_update(&ctx, input, length); + sha1_finish(&ctx, final); + digest_list->count++; + break; + case TPM2_ALG_SHA256: + sha256_starts(&ctx_256); + sha256_update(&ctx_256, input, length); + sha256_finish(&ctx_256, final); + digest_list->count++; + break; + case TPM2_ALG_SHA384: + sha384_starts(&ctx_512); + sha384_update(&ctx_512, input, length); + sha384_finish(&ctx_512, final); + digest_list->count++; + break; + case TPM2_ALG_SHA512: + sha512_starts(&ctx_512); + sha512_update(&ctx_512, input, length); + sha512_finish(&ctx_512, final); + digest_list->count++; + break; + default: + EFI_PRINT("Unsupported algorithm %x\n", hash_alg); + return EFI_INVALID_PARAMETER; + } + digest_list->digests[i].hash_alg = hash_alg; + memcpy(&digest_list->digests[i].digest, final, (u32)alg_to_len(hash_alg)); + } + + return EFI_SUCCESS; +} + +/** * efi_tcg2_get_capability() - protocol capability information and state information * * @this: TCG2 protocol instance @@ -427,7 +683,28 @@ efi_tcg2_get_eventlog(struct efi_tcg2_protocol *this, u64 *event_log_location, u64 *event_log_last_entry, bool *event_log_truncated) { - return EFI_UNSUPPORTED; + efi_status_t ret = EFI_SUCCESS; + struct udevice *dev; + + EFI_ENTRY("%p, %u, %p, %p, %p", this, log_format, event_log_location, + event_log_last_entry, event_log_truncated); + + ret = platform_get_tpm2_device(&dev); + if (ret != EFI_SUCCESS) { + event_log_location = NULL; + event_log_last_entry = NULL; + *event_log_truncated = false; + ret = EFI_SUCCESS; + goto out; + } + *event_log_location = (uintptr_t)event_log.buffer; + *event_log_last_entry = (uintptr_t)(event_log.buffer + event_log.pos - + event_log.last_event_size); + *event_log_truncated = event_log.truncated; + event_log.get_event_called = true; + +out: + return EFI_EXIT(ret); } /** @@ -450,7 +727,76 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags, u64 data_to_hash, u64 data_to_hash_len, struct efi_tcg2_event *efi_tcg_event) { - return EFI_UNSUPPORTED; + struct udevice *dev; + efi_status_t ret; + u32 event_type, pcr_index, event_size; + struct tpml_digest_values digest_list; + + EFI_ENTRY("%p, %llu, %llu, %llu, %p", this, flags, data_to_hash, + data_to_hash_len, efi_tcg_event); + + if (!this || !data_to_hash || !efi_tcg_event) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + ret = platform_get_tpm2_device(&dev); + if (ret != EFI_SUCCESS) + goto out; + + if (efi_tcg_event->size < efi_tcg_event->header.header_size + + sizeof(u32)) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + if (efi_tcg_event->header.pcr_index < 0 || + efi_tcg_event->header.pcr_index > TPM2_MAX_PCRS) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + /* + * if PE_COFF_IMAGE is set we need to make sure the image is not + * corrupted, verify it and hash the PE/COFF image in accordance with + * the procedure specified in "Calculating the PE Image Hash" + * section of the "Windows Authenticode Portable Executable Signature + * Format" + * Not supported for now + */ + if (flags & PE_COFF_IMAGE) { + ret = EFI_UNSUPPORTED; + goto out; + } + + pcr_index = efi_tcg_event->header.pcr_index; + event_type = efi_tcg_event->header.event_type; + + ret = tcg2_create_digest((u8 *)data_to_hash, data_to_hash_len, + &digest_list); + if (ret != EFI_SUCCESS) + goto out; + + ret = tcg2_pcr_extend(dev, pcr_index, &digest_list); + if (ret != EFI_SUCCESS) + goto out; + + if (flags & EFI_TCG2_EXTEND_ONLY) { + if (event_log.truncated) + ret = EFI_VOLUME_FULL; + goto out; + } + + /* + * The efi_tcg_event size includes the size component and the + * headersize + */ + event_size = efi_tcg_event->size - sizeof(efi_tcg_event->size) - + efi_tcg_event->header.header_size; + ret = tcg2_agile_log_append(pcr_index, event_type, &digest_list, + event_size, efi_tcg_event->event); +out: + return EFI_EXIT(ret); } /** @@ -464,7 +810,7 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags, * * Return: status code */ -efi_status_t EFIAPI +static efi_status_t EFIAPI efi_tcg2_submit_command(struct efi_tcg2_protocol *this, u32 input_param_block_size, u8 *input_param_block, u32 output_param_block_size, u8 *output_param_block) @@ -481,11 +827,16 @@ efi_tcg2_submit_command(struct efi_tcg2_protocol *this, * * Return: status code */ -efi_status_t EFIAPI +static efi_status_t EFIAPI efi_tcg2_get_active_pcr_banks(struct efi_tcg2_protocol *this, u32 *active_pcr_banks) { - return EFI_UNSUPPORTED; + efi_status_t ret; + + EFI_ENTRY("%p, %p", this, active_pcr_banks); + ret = __get_active_pcr_banks(active_pcr_banks); + + return EFI_EXIT(ret); } /** @@ -496,7 +847,7 @@ efi_tcg2_get_active_pcr_banks(struct efi_tcg2_protocol *this, * * Return: status code */ -efi_status_t EFIAPI +static efi_status_t EFIAPI efi_tcg2_set_active_pcr_banks(struct efi_tcg2_protocol *this, u32 active_pcr_banks) { @@ -515,7 +866,7 @@ efi_tcg2_set_active_pcr_banks(struct efi_tcg2_protocol *this, * * Return: status code */ -efi_status_t EFIAPI +static efi_status_t EFIAPI efi_tcg2_get_result_of_set_active_pcr_banks(struct efi_tcg2_protocol *this, u32 *operation_present, u32 *response) { @@ -533,6 +884,169 @@ static const struct efi_tcg2_protocol efi_tcg2_protocol = { }; /** + * create_specid_event() - Create the first event in the eventlog + * + * @dev: tpm device + * @event_header: Pointer to the final event header + * @event_size: final spec event size + * + * Return: status code + */ +static efi_status_t create_specid_event(struct udevice *dev, void *buffer, + size_t *event_size) +{ + struct tcg_efi_spec_id_event *spec_event; + size_t spec_event_size; + efi_status_t ret = EFI_DEVICE_ERROR; + u32 active, supported; + int err, i; + + /* + * Create Spec event. This needs to be the first event in the log + * according to the TCG EFI protocol spec + */ + + /* Setup specID event data */ + spec_event = (struct tcg_efi_spec_id_event *)buffer; + memcpy(spec_event->signature, TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03, + sizeof(spec_event->signature)); + put_unaligned_le32(0, &spec_event->platform_class); /* type client */ + spec_event->spec_version_minor = + TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2; + spec_event->spec_version_major = + TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2; + spec_event->spec_errata = + TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2; + spec_event->uintn_size = sizeof(efi_uintn_t) / sizeof(u32); + + err = tpm2_get_pcr_info(dev, &supported, &active, + &spec_event->number_of_algorithms); + if (err) + goto out; + if (spec_event->number_of_algorithms > MAX_HASH_COUNT || + spec_event->number_of_algorithms < 1) + goto out; + + for (i = 0; i < spec_event->number_of_algorithms; i++) { + u16 hash_alg = hash_algo_list[i].hash_alg; + u16 hash_len = hash_algo_list[i].hash_len; + + if (active && alg_to_mask(hash_alg)) { + put_unaligned_le16(hash_alg, + &spec_event->digest_sizes[i].algorithm_id); + put_unaligned_le16(hash_len, + &spec_event->digest_sizes[i].digest_size); + } + } + /* + * the size of the spec event and placement of vendor_info_size + * depends on supported algoriths + */ + spec_event_size = + offsetof(struct tcg_efi_spec_id_event, digest_sizes) + + spec_event->number_of_algorithms * sizeof(spec_event->digest_sizes[0]); + /* no vendor info for us */ + memset(buffer + spec_event_size, 0, + sizeof(spec_event->vendor_info_size)); + spec_event_size += sizeof(spec_event->vendor_info_size); + *event_size = spec_event_size; + + return EFI_SUCCESS; + +out: + return ret; +} + +/** + * create_final_event() - Create the final event and install the config + * defined by the TCG EFI spec + */ +static efi_status_t create_final_event(void) +{ + struct efi_tcg2_final_events_table *final_event; + efi_status_t ret; + + /* + * All events generated after the invocation of + * EFI_TCG2_GET_EVENT_LOGS need to be stored in an instance of an + * EFI_CONFIGURATION_TABLE + */ + ret = efi_allocate_pool(EFI_ACPI_MEMORY_NVS, TPM2_EVENT_LOG_SIZE, + &event_log.final_buffer); + if (ret != EFI_SUCCESS) + goto out; + + memset(event_log.final_buffer, 0xff, TPM2_EVENT_LOG_SIZE); + final_event = event_log.final_buffer; + final_event->number_of_events = 0; + final_event->version = EFI_TCG2_FINAL_EVENTS_TABLE_VERSION; + event_log.final_pos = sizeof(*final_event); + ret = efi_install_configuration_table(&efi_guid_final_events, + final_event); + if (ret != EFI_SUCCESS) + goto out; + + return EFI_SUCCESS; +out: + return ret; +} + +/** + * efi_init_event_log() - initialize an eventlog + */ +static efi_status_t efi_init_event_log(void) +{ + /* + * vendor_info_size is currently set to 0, we need to change the length + * and allocate the flexible array member if this changes + */ + struct tcg_pcr_event *event_header = NULL; + struct udevice *dev; + size_t spec_event_size; + efi_status_t ret; + + ret = platform_get_tpm2_device(&dev); + if (ret != EFI_SUCCESS) + goto out; + + ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, TPM2_EVENT_LOG_SIZE, + (void **)&event_log.buffer); + if (ret != EFI_SUCCESS) + goto out; + + /* + * initialize log area as 0xff so the OS can easily figure out the + * last log entry + */ + memset(event_log.buffer, 0xff, TPM2_EVENT_LOG_SIZE); + event_log.pos = 0; + event_log.last_event_size = 0; + event_log.get_event_called = false; + event_log.truncated = false; + + /* + * The log header is defined to be in SHA1 event log entry format. + * Setup event header + */ + event_header = (struct tcg_pcr_event *)event_log.buffer; + put_unaligned_le32(0, &event_header->pcr_index); + put_unaligned_le32(EV_NO_ACTION, &event_header->event_type); + memset(&event_header->digest, 0, sizeof(event_header->digest)); + ret = create_specid_event(dev, event_log.buffer + sizeof(*event_header), + &spec_event_size); + if (ret != EFI_SUCCESS) + goto out; + put_unaligned_le32(spec_event_size, &event_header->event_size); + event_log.pos = spec_event_size + sizeof(*event_header); + event_log.last_event_size = event_log.pos; + + ret = create_final_event(); + +out: + return ret; +} + +/** * efi_tcg2_register() - register EFI_TCG2_PROTOCOL * * If a TPM2 device is available, the TPM TCG2 Protocol is registered @@ -549,6 +1063,11 @@ efi_status_t efi_tcg2_register(void) log_warning("Unable to find TPMv2 device\n"); return EFI_SUCCESS; } + + ret = efi_init_event_log(); + if (ret != EFI_SUCCESS) + return ret; + ret = efi_add_protocol(efi_root, &efi_guid_tcg2_protocol, (void *)&efi_tcg2_protocol); if (ret != EFI_SUCCESS) diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 0c689cfb47..ba0874e9e7 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -24,91 +24,6 @@ #include <asm/sections.h> #ifdef CONFIG_EFI_SECURE_BOOT -static u8 pkcs7_hdr[] = { - /* SEQUENCE */ - 0x30, 0x82, 0x05, 0xc7, - /* OID: pkcs7-signedData */ - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, - /* Context Structured? */ - 0xa0, 0x82, 0x05, 0xb8, -}; - -/** - * efi_variable_parse_signature - parse a signature in variable - * @buf: Pointer to variable's value - * @buflen: Length of @buf - * @tmpbuf: Pointer to temporary buffer - * - * Parse a signature embedded in variable's value and instantiate - * a pkcs7_message structure. Since pkcs7_parse_message() accepts only - * pkcs7's signedData, some header needed be prepended for correctly - * parsing authentication data, particularly for variable's. - * A temporary buffer will be allocated if needed, and it should be - * kept valid during the authentication because some data in the buffer - * will be referenced by efi_signature_verify(). - * - * Return: Pointer to pkcs7_message structure on success, NULL on error - */ -static struct pkcs7_message *efi_variable_parse_signature(const void *buf, - size_t buflen, - u8 **tmpbuf) -{ - u8 *ebuf; - size_t ebuflen, len; - struct pkcs7_message *msg; - - /* - * This is the best assumption to check if the binary is - * already in a form of pkcs7's signedData. - */ - if (buflen > sizeof(pkcs7_hdr) && - !memcmp(&((u8 *)buf)[4], &pkcs7_hdr[4], 11)) { - msg = pkcs7_parse_message(buf, buflen); - if (IS_ERR(msg)) - return NULL; - return msg; - } - - /* - * Otherwise, we should add a dummy prefix sequence for pkcs7 - * message parser to be able to process. - * NOTE: EDK2 also uses similar hack in WrapPkcs7Data() - * in CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyCommon.c - * TODO: - * The header should be composed in a more refined manner. - */ - EFI_PRINT("Makeshift prefix added to authentication data\n"); - ebuflen = sizeof(pkcs7_hdr) + buflen; - if (ebuflen <= 0x7f) { - EFI_PRINT("Data is too short\n"); - return NULL; - } - - ebuf = malloc(ebuflen); - if (!ebuf) { - EFI_PRINT("Out of memory\n"); - return NULL; - } - - memcpy(ebuf, pkcs7_hdr, sizeof(pkcs7_hdr)); - memcpy(ebuf + sizeof(pkcs7_hdr), buf, buflen); - len = ebuflen - 4; - ebuf[2] = (len >> 8) & 0xff; - ebuf[3] = len & 0xff; - len = ebuflen - 0x13; - ebuf[0x11] = (len >> 8) & 0xff; - ebuf[0x12] = len & 0xff; - - msg = pkcs7_parse_message(ebuf, ebuflen); - - if (IS_ERR(msg)) { - free(ebuf); - return NULL; - } - - *tmpbuf = ebuf; - return msg; -} /** * efi_variable_authenticate - authenticate a variable @@ -215,10 +130,10 @@ static efi_status_t efi_variable_authenticate(u16 *variable, goto err; /* ebuf should be kept valid during the authentication */ - var_sig = efi_variable_parse_signature(auth->auth_info.cert_data, - auth->auth_info.hdr.dwLength - - sizeof(auth->auth_info), - &ebuf); + var_sig = efi_parse_pkcs7_header(auth->auth_info.cert_data, + auth->auth_info.hdr.dwLength + - sizeof(auth->auth_info), + &ebuf); if (!var_sig) { EFI_PRINT("Parsing variable's signature failed\n"); goto err; diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 58fb43fcdf..426552bfa0 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -25,9 +25,12 @@ efi_selftest_crc32.o \ efi_selftest_devicepath_util.o \ efi_selftest_events.o \ efi_selftest_event_groups.o \ +efi_selftest_exception.o \ efi_selftest_exitbootservices.o \ efi_selftest_gop.o \ +efi_selftest_load_file.o \ efi_selftest_loaded_image.o \ +efi_selftest_loadimage.o \ efi_selftest_manageprotocols.o \ efi_selftest_mem.o \ efi_selftest_memory.o \ @@ -35,6 +38,8 @@ efi_selftest_open_protocol.o \ efi_selftest_register_notify.o \ efi_selftest_reset.o \ efi_selftest_set_virtual_address_map.o \ +efi_selftest_startimage_exit.o \ +efi_selftest_startimage_return.o \ efi_selftest_textinput.o \ efi_selftest_textinputex.o \ efi_selftest_textoutput.o \ @@ -65,12 +70,6 @@ ifeq ($(CONFIG_BLK)$(CONFIG_DOS_PARTITION),yy) obj-y += efi_selftest_block_device.o endif -obj-y += \ -efi_selftest_exception.o \ -efi_selftest_loadimage.o \ -efi_selftest_startimage_exit.o \ -efi_selftest_startimage_return.o - targets += \ efi_miniapp_file_image_exception.h \ efi_miniapp_file_image_exit.h \ @@ -94,10 +93,12 @@ $(obj)/efi_miniapp_file_image_return.h: $(obj)/efi_selftest_miniapp_return.efi $(obj)/../../tools/file2include $(obj)/efi_selftest_miniapp_return.efi > \ $(obj)/efi_miniapp_file_image_return.h -$(obj)/efi_selftest_loadimage.o: $(obj)/efi_miniapp_file_image_exit.h - $(obj)/efi_selftest_exception.o: $(obj)/efi_miniapp_file_image_exception.h +$(obj)/efi_selftest_load_file.o: $(obj)/efi_miniapp_file_image_exit.h + +$(obj)/efi_selftest_loadimage.o: $(obj)/efi_miniapp_file_image_exit.h + $(obj)/efi_selftest_startimage_exit.o: $(obj)/efi_miniapp_file_image_exit.h $(obj)/efi_selftest_startimage_return.o: $(obj)/efi_miniapp_file_image_return.h diff --git a/lib/efi_selftest/efi_selftest_load_file.c b/lib/efi_selftest/efi_selftest_load_file.c new file mode 100644 index 0000000000..4473e7c36e --- /dev/null +++ b/lib/efi_selftest/efi_selftest_load_file.c @@ -0,0 +1,475 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * efi_selftest_load_file + * + * Copyright (c) 2020 Heinrich Schuchardt <xypron.glpk@gmx.de> + * + * This test checks the handling of the LOAD_FILE and the LOAD_FILE2 protocol + * by the LoadImage() service. + */ + +#include <efi_selftest.h> +/* Include containing the miniapp.efi application */ +#include "efi_miniapp_file_image_exit.h" + +/* Block size of compressed disk image */ +#define COMPRESSED_DISK_IMAGE_BLOCK_SIZE 8 + +/* Binary logarithm of the block size */ +#define LB_BLOCK_SIZE 9 + +#define GUID_VENDOR \ + EFI_GUID(0xdbca4c98, 0x6cb0, 0x694d, \ + 0x08, 0x72, 0x81, 0x9c, 0x65, 0xfc, 0xbb, 0xd1) + +#define GUID_VENDOR2 \ + EFI_GUID(0xdbca4c98, 0x6cb0, 0x694d, \ + 0x08, 0x72, 0x81, 0x9c, 0x65, 0xfc, 0xbb, 0xd2) + +#define FILE_NAME_SIZE 16 + +static const efi_guid_t efi_st_guid_load_file_protocol = + EFI_LOAD_FILE_PROTOCOL_GUID; +static const efi_guid_t efi_st_guid_load_file2_protocol = + EFI_LOAD_FILE2_PROTOCOL_GUID; +static const efi_guid_t efi_st_guid_device_path = + EFI_DEVICE_PATH_PROTOCOL_GUID; + +static efi_handle_t image_handle; +static struct efi_boot_services *boottime; +static efi_handle_t handle_lf; +static efi_handle_t handle_lf2; + +/* One 8 byte block of the compressed disk image */ +struct line { + size_t addr; + char *line; +}; + +/* Compressed file image */ +struct compressed_file_image { + size_t length; + struct line lines[]; +}; + +static struct compressed_file_image img = EFI_ST_DISK_IMG; + +static int load_file_call_count; +static int load_file2_call_count; + +/* Decompressed file image */ +static u8 *image; + +static struct { + struct efi_device_path_vendor v; + struct efi_device_path d; +} dp_lf_prot = { + { + { + DEVICE_PATH_TYPE_HARDWARE_DEVICE, + DEVICE_PATH_SUB_TYPE_VENDOR, + sizeof(struct efi_device_path_vendor), + }, + GUID_VENDOR, + }, + { + DEVICE_PATH_TYPE_END, + DEVICE_PATH_SUB_TYPE_END, + sizeof(struct efi_device_path), + }, +}; + +static struct { + struct efi_device_path_vendor v; + struct efi_device_path_file_path f; + u16 file_name[FILE_NAME_SIZE]; + struct efi_device_path e; +} dp_lf_file = { + { + { + DEVICE_PATH_TYPE_HARDWARE_DEVICE, + DEVICE_PATH_SUB_TYPE_VENDOR, + sizeof(struct efi_device_path_vendor), + }, + GUID_VENDOR, + }, + { + { + DEVICE_PATH_TYPE_MEDIA_DEVICE, + DEVICE_PATH_SUB_TYPE_FILE_PATH, + sizeof(struct efi_device_path_file_path) + + FILE_NAME_SIZE * sizeof(u16), + } + }, + L"\\lf.efi", + { + DEVICE_PATH_TYPE_END, + DEVICE_PATH_SUB_TYPE_END, + sizeof(struct efi_device_path), + }, +}; + +struct efi_device_path *dp_lf_file_remainder = &dp_lf_file.f.dp; + +static struct { + struct efi_device_path_vendor v; + struct efi_device_path d; +} dp_lf2_prot = { + { + { + DEVICE_PATH_TYPE_HARDWARE_DEVICE, + DEVICE_PATH_SUB_TYPE_VENDOR, + sizeof(struct efi_device_path_vendor), + }, + GUID_VENDOR2, + }, + { + DEVICE_PATH_TYPE_END, + DEVICE_PATH_SUB_TYPE_END, + sizeof(struct efi_device_path), + }, +}; + +static struct { + struct efi_device_path_vendor v; + struct efi_device_path_file_path f; + u16 file_name[FILE_NAME_SIZE]; + struct efi_device_path e; +} dp_lf2_file = { + { + { + DEVICE_PATH_TYPE_HARDWARE_DEVICE, + DEVICE_PATH_SUB_TYPE_VENDOR, + sizeof(struct efi_device_path_vendor), + }, + GUID_VENDOR2, + }, + { + { + DEVICE_PATH_TYPE_MEDIA_DEVICE, + DEVICE_PATH_SUB_TYPE_FILE_PATH, + sizeof(struct efi_device_path_file_path) + + FILE_NAME_SIZE * sizeof(u16), + } + }, + L"\\lf2.efi", + { + DEVICE_PATH_TYPE_END, + DEVICE_PATH_SUB_TYPE_END, + sizeof(struct efi_device_path), + }, +}; + +struct efi_device_path *dp_lf2_file_remainder = &dp_lf2_file.f.dp; + +/* + * Decompress the disk image. + * + * @image decompressed disk image + * @return status code + */ +static efi_status_t decompress(u8 **image) +{ + u8 *buf; + size_t i; + size_t addr; + size_t len; + efi_status_t ret; + + ret = boottime->allocate_pool(EFI_LOADER_DATA, img.length, + (void **)&buf); + if (ret != EFI_SUCCESS) { + efi_st_error("Out of memory\n"); + return ret; + } + boottime->set_mem(buf, img.length, 0); + + for (i = 0; ; ++i) { + if (!img.lines[i].line) + break; + addr = img.lines[i].addr; + len = COMPRESSED_DISK_IMAGE_BLOCK_SIZE; + if (addr + len > img.length) + len = img.length - addr; + boottime->copy_mem(buf + addr, img.lines[i].line, len); + } + *image = buf; + return ret; +} + +/* + * load_file() - LoadFile() service of a EFI_LOAD_FILE_PROTOCOL + * + * @this: instance of EFI_LOAD_FILE_PROTOCOL + * @file_path: remaining device path + * @boot_policy: true if called by boot manager + * @buffer_size: (required) buffer size + * @buffer: buffer to which the file is to be loaded + */ +efi_status_t EFIAPI load_file(struct efi_load_file_protocol *this, + struct efi_device_path *file_path, + bool boot_policy, + efi_uintn_t *buffer_size, + void *buffer) +{ + ++load_file_call_count; + if (memcmp(file_path, dp_lf_file_remainder, + sizeof(struct efi_device_path_file_path) + + FILE_NAME_SIZE * sizeof(u16) + + sizeof(struct efi_device_path))) { + efi_st_error("Wrong remaining device path\n"); + return EFI_NOT_FOUND; + } + if (this->load_file != load_file) { + efi_st_error("wrong this\n"); + return EFI_INVALID_PARAMETER; + } + if (*buffer_size < img.length) { + *buffer_size = img.length; + return EFI_BUFFER_TOO_SMALL; + } + memcpy(buffer, image, img.length); + *buffer_size = img.length; + return EFI_SUCCESS; +} + + +/* + * load_file2() - LoadFile() service of a EFI_LOAD_FILE2_PROTOCOL + * + * @this: instance of EFI_LOAD_FILE2_PROTOCOL + * @file_path: remaining device path + * @boot_policy: true if called by boot manager + * @buffer_size: (required) buffer size + * @buffer: buffer to which the file is to be loaded + */ +efi_status_t EFIAPI load_file2(struct efi_load_file_protocol *this, + struct efi_device_path *file_path, + bool boot_policy, + efi_uintn_t *buffer_size, + void *buffer) +{ + ++load_file2_call_count; + if (memcmp(file_path, dp_lf2_file_remainder, + sizeof(struct efi_device_path_file_path) + + FILE_NAME_SIZE * sizeof(u16) + + sizeof(struct efi_device_path))) { + efi_st_error("Wrong remaining device path\n"); + return EFI_NOT_FOUND; + } + if (this->load_file != load_file2) { + efi_st_error("wrong this\n"); + return EFI_INVALID_PARAMETER; + } + if (boot_policy) { + efi_st_error("LOAD_FILE2 called with boot_policy = true"); + return EFI_INVALID_PARAMETER; + } + if (*buffer_size < img.length) { + *buffer_size = img.length; + return EFI_BUFFER_TOO_SMALL; + } + memcpy(buffer, image, img.length); + *buffer_size = img.length; + return EFI_SUCCESS; +} + +static struct efi_load_file_protocol lf_prot = {load_file}; +static struct efi_load_file_protocol lf2_prot = {load_file2}; + +/* + * Setup unit test. + * + * Install an EFI_LOAD_FILE_PROTOCOL and an EFI_LOAD_FILE2_PROTOCOL. + * + * @handle: handle of the loaded image + * @systable: system table + * @return: EFI_ST_SUCCESS for success + */ +static int efi_st_load_file_setup(const efi_handle_t handle, + const struct efi_system_table *systable) +{ + efi_status_t ret; + + image_handle = handle; + boottime = systable->boottime; + + /* Load the application image into memory */ + decompress(&image); + + ret = boottime->install_multiple_protocol_interfaces( + &handle_lf, + &efi_st_guid_device_path, + &dp_lf_prot, + &efi_st_guid_load_file_protocol, + &lf_prot, + NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("InstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; + } + ret = boottime->install_multiple_protocol_interfaces( + &handle_lf2, + &efi_st_guid_device_path, + &dp_lf2_prot, + &efi_st_guid_load_file2_protocol, + &lf2_prot, + NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("InstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; +} + +/* + * Tear down unit test. + * + * @return: EFI_ST_SUCCESS for success + */ +static int efi_st_load_file_teardown(void) +{ + efi_status_t ret = EFI_ST_SUCCESS; + + if (handle_lf) { + ret = boottime->uninstall_multiple_protocol_interfaces( + handle_lf, + &efi_st_guid_device_path, + &dp_lf_prot, + &efi_st_guid_load_file_protocol, + &lf_prot, + NULL); + if (ret != EFI_SUCCESS) { + efi_st_error( + "UninstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; + } + } + if (handle_lf2) { + ret = boottime->uninstall_multiple_protocol_interfaces( + handle_lf2, + &efi_st_guid_device_path, + &dp_lf2_prot, + &efi_st_guid_load_file2_protocol, + &lf2_prot, + NULL); + if (ret != EFI_SUCCESS) { + efi_st_error( + "UninstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; + } + } + + if (image) { + ret = boottime->free_pool(image); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to free image\n"); + return EFI_ST_FAILURE; + } + } + return ret; +} + +/* + * Execute unit test. + * + * Try loading an image via the EFI_LOAD_FILE_PROTOCOL and the + * EFI_LOAD_FILE2_PROTOCOL. Finally execute the image. + * + * @return: EFI_ST_SUCCESS for success + */ +static int efi_st_load_file_execute(void) +{ + efi_status_t ret; + efi_handle_t handle; + efi_uintn_t exit_data_size = 0; + u16 *exit_data = NULL; + u16 expected_text[] = EFI_ST_SUCCESS_STR; + + load_file_call_count = 0; + load_file2_call_count = 0; + handle = NULL; + ret = boottime->load_image(true, image_handle, &dp_lf_file.v.dp, NULL, + 0, &handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to load image\n"); + return EFI_ST_FAILURE; + } + if (load_file2_call_count || !load_file_call_count) { + efi_st_error("Wrong image loaded\n"); + return EFI_ST_FAILURE; + } + ret = boottime->unload_image(handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to unload image\n"); + return EFI_ST_FAILURE; + } + + load_file_call_count = 0; + load_file2_call_count = 0; + handle = NULL; + ret = boottime->load_image(false, image_handle, &dp_lf_file.v.dp, NULL, + 0, &handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to load image\n"); + return EFI_ST_FAILURE; + } + if (load_file2_call_count || !load_file_call_count) { + efi_st_error("Wrong image loaded\n"); + return EFI_ST_FAILURE; + } + ret = boottime->unload_image(handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to unload image\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->load_image(true, image_handle, &dp_lf2_file.v.dp, NULL, + 0, &handle); + if (ret != EFI_NOT_FOUND) { + efi_st_error( + "Boot manager should not use LOAD_FILE2_PROTOCOL\n"); + return EFI_ST_FAILURE; + } + + load_file_call_count = 0; + load_file2_call_count = 0; + handle = NULL; + ret = boottime->load_image(false, image_handle, &dp_lf2_file.v.dp, NULL, + 0, &handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to load image\n"); + return EFI_ST_FAILURE; + } + if (!load_file2_call_count || load_file_call_count) { + efi_st_error("Wrong image loaded\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->start_image(handle, &exit_data_size, &exit_data); + if (ret != EFI_UNSUPPORTED) { + efi_st_error("Wrong return value from application\n"); + return EFI_ST_FAILURE; + } + if (!exit_data || exit_data_size != sizeof(expected_text) || + memcmp(exit_data, expected_text, sizeof(expected_text))) { + efi_st_error("Incorrect exit data\n"); + return EFI_ST_FAILURE; + } + ret = boottime->free_pool(exit_data); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to free exit data\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; +} + +EFI_UNIT_TEST(load_file_protocol) = { + .name = "load file protocol", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = efi_st_load_file_setup, + .execute = efi_st_load_file_execute, + .teardown = efi_st_load_file_teardown, +}; diff --git a/lib/efi_selftest/efi_selftest_load_initrd.c b/lib/efi_selftest/efi_selftest_load_initrd.c index fe060a6644..f591dcd211 100644 --- a/lib/efi_selftest/efi_selftest_load_initrd.c +++ b/lib/efi_selftest/efi_selftest_load_initrd.c @@ -86,7 +86,6 @@ static int setup(const efi_handle_t handle, static int execute(void) { - efi_guid_t lf2_proto_guid = EFI_LOAD_FILE2_PROTOCOL_GUID; struct efi_load_file_protocol *lf2; struct efi_device_path *dp2, *dp2_invalid; efi_status_t status; @@ -99,13 +98,15 @@ static int execute(void) memset(buffer, 0, sizeof(buffer)); dp2 = (struct efi_device_path *)&dp; - status = boottime->locate_device_path(&lf2_proto_guid, &dp2, &handle); + status = boottime->locate_device_path(&efi_guid_load_file2_protocol, + &dp2, &handle); if (status != EFI_SUCCESS) { efi_st_error("Unable to locate device path\n"); return EFI_ST_FAILURE; } - status = boottime->handle_protocol(handle, &lf2_proto_guid, + status = boottime->handle_protocol(handle, + &efi_guid_load_file2_protocol, (void **)&lf2); if (status != EFI_SUCCESS) { efi_st_error("Unable to locate protocol\n"); diff --git a/lib/efi_selftest/efi_selftest_miniapp_exception.c b/lib/efi_selftest/efi_selftest_miniapp_exception.c index 63c63d75f1..59b7e5100a 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exception.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exception.c @@ -33,6 +33,8 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, asm volatile (".word 0xe7f7defb\n"); #elif defined(CONFIG_RISCV) asm volatile (".word 0xffffffff\n"); +#elif defined(CONFIG_SANDBOX) + asm volatile (".word 0xffffffff\n"); #elif defined(CONFIG_X86) asm volatile (".word 0xffff\n"); #endif diff --git a/lib/fdtdec.c b/lib/fdtdec.c index ee1bd41b08..0ab7105fef 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -500,6 +500,17 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset, slash = strrchr(prop, '/'); if (strcmp(slash + 1, find_name)) continue; + + /* + * Adding an extra check to distinguish DT nodes with + * same name + */ + if (IS_ENABLED(CONFIG_PHANDLE_CHECK_SEQ)) { + if (fdt_get_phandle(blob, offset) != + fdt_get_phandle(blob, fdt_path_offset(blob, prop))) + continue; + } + val = trailing_strtol(name); if (val != -1) { *seqp = val; diff --git a/lib/hashtable.c b/lib/hashtable.c index 7c08f5c805..ff5ff72639 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -472,7 +472,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag) idx = hsearch_r(e, ENV_FIND, &ep, htab, 0); if (idx == 0) { __set_errno(ESRCH); - return 0; /* not found */ + return -ENOENT; /* not found */ } /* Check for permission */ @@ -481,7 +481,7 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag) debug("change_ok() rejected deleting variable " "%s, skipping it!\n", key); __set_errno(EPERM); - return 0; + return -EPERM; } /* If there is a callback, call it */ @@ -490,12 +490,12 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag) debug("callback() rejected deleting variable " "%s, skipping it!\n", key); __set_errno(EINVAL); - return 0; + return -EINVAL; } _hdelete(key, htab, ep, idx); - return 1; + return 0; } #if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV)) @@ -917,7 +917,7 @@ int himport_r(struct hsearch_data *htab, if (!drop_var_from_set(name, nvars, localvars)) continue; - if (hdelete_r(name, htab, flag) == 0) + if (hdelete_r(name, htab, flag)) debug("DELETE ERROR ##############################\n"); continue; @@ -979,7 +979,7 @@ int himport_r(struct hsearch_data *htab, * b) if the variable was not present in current env, we notify * it might be a typo */ - if (hdelete_r(localvars[i], htab, flag) == 0) + if (hdelete_r(localvars[i], htab, flag)) printf("WARNING: '%s' neither in running nor in imported env!\n", localvars[i]); else printf("WARNING: '%s' not in imported env, deleting it!\n", localvars[i]); diff --git a/lib/smbios.c b/lib/smbios.c index 485a812c77..1e10fa8420 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -229,7 +229,7 @@ static void smbios_write_type4_dm(struct smbios_type4 *t, ofnode node) uclass_find_first_device(UCLASS_CPU, &cpu); if (cpu) { - struct cpu_platdata *plat = dev_get_parent_platdata(cpu); + struct cpu_plat *plat = dev_get_parent_plat(cpu); if (plat->family) processor_family = plat->family; diff --git a/lib/time.c b/lib/time.c index 88bc50405f..cc6944ec34 100644 --- a/lib/time.c +++ b/lib/time.c @@ -9,6 +9,7 @@ #include <dm.h> #include <errno.h> #include <init.h> +#include <spl.h> #include <time.h> #include <timer.h> #include <watchdog.h> @@ -96,8 +97,13 @@ uint64_t notrace get_ticks(void) } ret = timer_get_count(gd->timer, &count); - if (ret) - panic("Could not read count from timer (err %d)\n", ret); + if (ret) { + if (spl_phase() > PHASE_TPL) + panic("Could not read count from timer (err %d)\n", + ret); + else + panic("no timer (err %d)\n", ret); + } return count; } diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index 91759068cf..1f3deb06e4 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -80,11 +80,12 @@ u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw, return tpm_sendrecv_command(dev, command_v2, NULL, NULL); } -u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest) +u32 tpm2_pcr_extend(struct udevice *dev, u32 index, u32 algorithm, + const u8 *digest, u32 digest_len) { u8 command_v2[COMMAND_BUFFER_SIZE] = { tpm_u16(TPM2_ST_SESSIONS), /* TAG */ - tpm_u32(33 + TPM2_DIGEST_LEN), /* Length */ + tpm_u32(33 + digest_len), /* Length */ tpm_u32(TPM2_CC_PCR_EXTEND), /* Command code */ /* HANDLE */ @@ -99,7 +100,7 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest) tpm_u16(0), /* Size of <hmac/password> */ /* <hmac/password> (if any) */ tpm_u32(1), /* Count (number of hashes) */ - tpm_u16(TPM2_ALG_SHA256), /* Algorithm of the hash */ + tpm_u16(algorithm), /* Algorithm of the hash */ /* STRING(digest) Digest */ }; unsigned int offset = 33; @@ -110,8 +111,8 @@ u32 tpm2_pcr_extend(struct udevice *dev, u32 index, const uint8_t *digest) * - the digest */ ret = pack_byte_string(command_v2, sizeof(command_v2), "s", - offset, digest, TPM2_DIGEST_LEN); - offset += TPM2_DIGEST_LEN; + offset, digest, digest_len); + offset += digest_len; if (ret) return TPM_LIB_ERROR; diff --git a/net/Kconfig b/net/Kconfig index 1b3e420d0d..c4b4dae064 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -74,4 +74,18 @@ config TFTP_WINDOWSIZE before an ack response is required. The default TFTP implementation implies a window size of 1. +config SERVERIP_FROM_PROXYDHCP + bool "Get serverip value from Proxy DHCP response" + help + Allows bootfile config to be fetched from Proxy DHCP server + while IP is obtained from main DHCP server. + +config SERVERIP_FROM_PROXYDHCP_DELAY_MS + int "# of additional milliseconds to wait for ProxyDHCP response" + default 100 + help + Amount of additional time to wait for ProxyDHCP response after + receiving response from main DHCP server. Has no effect if + SERVERIP_FROM_PROXYDHCP is false. + endif # if NET diff --git a/net/bootp.c b/net/bootp.c index de3dab4114..163af41e92 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -146,10 +146,7 @@ static int check_reply_packet(uchar *pkt, unsigned dest, unsigned src, return retval; } -/* - * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet - */ -static void store_net_params(struct bootp_hdr *bp) +static void store_bootp_params(struct bootp_hdr *bp) { #if !defined(CONFIG_BOOTP_SERVERIP) struct in_addr tmp_ip; @@ -183,6 +180,16 @@ static void store_net_params(struct bootp_hdr *bp) if (*net_boot_file_name) env_set("bootfile", net_boot_file_name); #endif +} + +/* + * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet + */ +static void store_net_params(struct bootp_hdr *bp) +{ +#if !defined(CONFIG_SERVERIP_FROM_PROXYDHCP) + store_bootp_params(bp); +#endif net_copy_ip(&net_ip, &bp->bp_yiaddr); } @@ -1055,8 +1062,12 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip, debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: " "%d\n", src, dest, len, dhcp_state); - if (net_read_ip(&bp->bp_yiaddr).s_addr == 0) + if (net_read_ip(&bp->bp_yiaddr).s_addr == 0) { +#if defined(CONFIG_SERVERIP_FROM_PROXYDHCP) + store_bootp_params(bp); +#endif return; + } switch (dhcp_state) { case SELECTING: @@ -1075,6 +1086,12 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip, dhcp_packet_process_options(bp); efi_net_set_dhcp_ack(pkt, len); +#if defined(CONFIG_SERVERIP_FROM_PROXYDHCP) + if (!net_server_ip.s_addr) + udelay(CONFIG_SERVERIP_FROM_PROXYDHCP_DELAY_MS * + 1000); +#endif /* CONFIG_SERVERIP_FROM_PROXYDHCP */ + debug("TRANSITIONING TO REQUESTING STATE\n"); dhcp_state = REQUESTING; diff --git a/net/eth-uclass.c b/net/eth-uclass.c index e14695c0f1..0156324032 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -50,7 +50,7 @@ static struct eth_uclass_priv *eth_get_uclass_priv(void) return NULL; assert(uc); - return uc->priv; + return uclass_get_priv(uc); } void eth_set_current_to_next(void) @@ -126,9 +126,6 @@ struct udevice *eth_get_dev_by_name(const char *devname) uclass_foreach_dev(it, uc) { /* - * We need the seq to be valid, so try to probe it. - * If the probe fails, the seq will not match since it will be - * -1 instead of what we are looking for. * We don't care about errors from probe here. Either they won't * match an alias or it will match a literal name and we'll pick * up the error when we try to probe again in eth_set_dev(). @@ -137,7 +134,7 @@ struct udevice *eth_get_dev_by_name(const char *devname) continue; /* Check for the name or the sequence number to match */ if (strcmp(it->name, devname) == 0 || - (endp > startp && it->seq == seq)) + (endp > startp && dev_seq(it) == seq)) return it; } @@ -149,7 +146,7 @@ unsigned char *eth_get_ethaddr(void) struct eth_pdata *pdata; if (eth_get_dev()) { - pdata = eth_get_dev()->platdata; + pdata = dev_get_plat(eth_get_dev()); return pdata->enetaddr; } @@ -166,7 +163,7 @@ int eth_init_state_only(void) if (!current || !device_active(current)) return -EINVAL; - priv = current->uclass_priv; + priv = dev_get_uclass_priv(current); priv->state = ETH_STATE_ACTIVE; return 0; @@ -182,14 +179,14 @@ void eth_halt_state_only(void) if (!current || !device_active(current)) return; - priv = current->uclass_priv; + priv = dev_get_uclass_priv(current); priv->state = ETH_STATE_PASSIVE; } int eth_get_dev_index(void) { if (eth_get_dev()) - return eth_get_dev()->seq; + return dev_seq(eth_get_dev()); return -1; } @@ -202,8 +199,8 @@ static int eth_write_hwaddr(struct udevice *dev) return -EINVAL; /* seq is valid since the device is active */ - if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev->seq)) { - pdata = dev->platdata; + if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev_seq(dev))) { + pdata = dev_get_plat(dev); if (!is_valid_ethaddr(pdata->enetaddr)) { printf("\nError: %s address %pM illegal value\n", dev->name, pdata->enetaddr); @@ -235,9 +232,9 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op, /* look for an index after "eth" */ index = simple_strtoul(name + 3, NULL, 10); - retval = uclass_find_device_by_seq(UCLASS_ETH, index, false, &dev); + retval = uclass_find_device_by_seq(UCLASS_ETH, index, &dev); if (!retval) { - struct eth_pdata *pdata = dev->platdata; + struct eth_pdata *pdata = dev_get_plat(dev); switch (op) { case env_op_create: case env_op_overwrite: @@ -290,7 +287,7 @@ int eth_init(void) ret = eth_get_ops(current)->start(current); if (ret >= 0) { struct eth_device_priv *priv = - current->uclass_priv; + dev_get_uclass_priv(current); priv->state = ETH_STATE_ACTIVE; return 0; @@ -326,7 +323,7 @@ void eth_halt(void) return; eth_get_ops(current)->stop(current); - priv = current->uclass_priv; + priv = dev_get_uclass_priv(current); if (priv) priv->state = ETH_STATE_PASSIVE; } @@ -434,11 +431,11 @@ int eth_initialize(void) bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT); do { - if (dev->seq != -1) { + if (device_active(dev)) { if (num_devices) printf(", "); - printf("eth%d: %s", dev->seq, dev->name); + printf("eth%d: %s", dev_seq(dev), dev->name); if (ethprime && dev == prime_dev) printf(" [PRIME]"); @@ -446,7 +443,7 @@ int eth_initialize(void) eth_write_hwaddr(dev); - if (dev->seq != -1) + if (device_active(dev)) num_devices++; uclass_next_device_check(&dev); } while (dev); @@ -505,8 +502,8 @@ static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN]) static int eth_post_probe(struct udevice *dev) { - struct eth_device_priv *priv = dev->uclass_priv; - struct eth_pdata *pdata = dev->platdata; + struct eth_device_priv *priv = dev_get_uclass_priv(dev); + struct eth_pdata *pdata = dev_get_plat(dev); unsigned char env_enetaddr[ARP_HLEN]; char *source = "DT"; @@ -547,7 +544,7 @@ static int eth_post_probe(struct udevice *dev) eth_get_ops(dev)->read_rom_hwaddr(dev); } - eth_env_get_enetaddr_by_index("eth", dev->seq, env_enetaddr); + eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr); if (!is_zero_ethaddr(env_enetaddr)) { if (!is_zero_ethaddr(pdata->enetaddr) && memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) { @@ -562,13 +559,14 @@ static int eth_post_probe(struct udevice *dev) /* Override the ROM MAC address */ memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN); } else if (is_valid_ethaddr(pdata->enetaddr)) { - eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr); + eth_env_set_enetaddr_by_index("eth", dev_seq(dev), + pdata->enetaddr); } else if (is_zero_ethaddr(pdata->enetaddr) || !is_valid_ethaddr(pdata->enetaddr)) { #ifdef CONFIG_NET_RANDOM_ETHADDR net_random_ethaddr(pdata->enetaddr); printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", - dev->name, dev->seq, pdata->enetaddr); + dev->name, dev_seq(dev), pdata->enetaddr); #else printf("\nError: %s address not set.\n", dev->name); @@ -583,7 +581,7 @@ static int eth_post_probe(struct udevice *dev) static int eth_pre_remove(struct udevice *dev) { - struct eth_pdata *pdata = dev->platdata; + struct eth_pdata *pdata = dev_get_plat(dev); eth_get_ops(dev)->stop(dev); @@ -600,7 +598,7 @@ UCLASS_DRIVER(eth) = { .pre_unbind = eth_pre_unbind, .post_probe = eth_post_probe, .pre_remove = eth_pre_remove, - .priv_auto_alloc_size = sizeof(struct eth_uclass_priv), - .per_device_auto_alloc_size = sizeof(struct eth_device_priv), + .priv_auto = sizeof(struct eth_uclass_priv), + .per_device_auto = sizeof(struct eth_device_priv), .flags = DM_UC_FLAG_SEQ_ALIAS, }; diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c index 6674eb6bee..780526c19e 100644 --- a/net/mdio-mux-uclass.c +++ b/net/mdio-mux-uclass.c @@ -65,7 +65,7 @@ static int mmux_change_sel(struct udevice *ch, bool sel) struct udevice *mux = ch->parent; struct mdio_mux_perdev_priv *priv = dev_get_uclass_priv(mux); struct mdio_mux_ops *ops = mdio_mux_get_ops(mux); - struct mdio_mux_ch_data *ch_data = dev_get_parent_platdata(ch); + struct mdio_mux_ch_data *ch_data = dev_get_parent_plat(ch); int err = 0; if (sel) { @@ -147,7 +147,7 @@ static int mmux_reset(struct udevice *ch) /* Picks up the mux selection value for each child */ static int dm_mdio_mux_child_post_bind(struct udevice *ch) { - struct mdio_mux_ch_data *ch_data = dev_get_parent_platdata(ch); + struct mdio_mux_ch_data *ch_data = dev_get_parent_plat(ch); ch_data->sel = dev_read_u32_default(ch, "reg", MDIO_MUX_SELECT_NONE); @@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux) ofnode ch_node; int err, first_err = 0; - if (!ofnode_valid(mux->node)) { + if (!dev_has_ofnode(mux)) { debug("%s: no mux node found, no child MDIO busses set up\n", __func__); return 0; @@ -228,6 +228,6 @@ UCLASS_DRIVER(mdio_mux) = { .child_post_bind = dm_mdio_mux_child_post_bind, .post_bind = dm_mdio_mux_post_bind, .post_probe = dm_mdio_mux_post_probe, - .per_device_auto_alloc_size = sizeof(struct mdio_mux_perdev_priv), - .per_child_platdata_auto_alloc_size = sizeof(struct mdio_mux_ch_data), + .per_device_auto = sizeof(struct mdio_mux_perdev_priv), + .per_child_plat_auto = sizeof(struct mdio_mux_ch_data), }; diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index b5e8e46512..697e5f838d 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev) const char *dt_name; /* set a custom name for the MDIO device, if present in DT */ - if (ofnode_valid(dev->node)) { - dt_name = ofnode_read_string(dev->node, "device-name"); + if (dev_has_ofnode(dev)) { + dt_name = dev_read_string(dev, "device-name"); if (dt_name) { debug("renaming dev %s to %s\n", dev->name, dt_name); device_set_name(dev, dt_name); @@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) struct phy_device *phy; int i; - if (!ofnode_valid(ethdev->node)) { + if (!dev_has_ofnode(ethdev)) { debug("%s: supplied eth dev has no DT node!\n", ethdev->name); return NULL; } interface = PHY_INTERFACE_MODE_NONE; for (i = 0; i < PHY_MODE_STR_CNT; i++) { - if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]); + if_str = dev_read_string(ethdev, phy_mode_str[i]); if (if_str) { interface = phy_get_interface_by_name(if_str); break; @@ -216,5 +216,5 @@ UCLASS_DRIVER(mdio) = { .post_bind = dm_mdio_post_bind, .post_probe = dm_mdio_post_probe, .pre_remove = dm_mdio_pre_remove, - .per_device_auto_alloc_size = sizeof(struct mdio_perdev_priv), + .per_device_auto = sizeof(struct mdio_perdev_priv), }; diff --git a/net/sntp.c b/net/sntp.c index d5d5671933..dac0f8ceea 100644 --- a/net/sntp.c +++ b/net/sntp.c @@ -57,18 +57,15 @@ static void sntp_timeout_handler(void) static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip, unsigned src, unsigned len) { -#ifdef CONFIG_TIMESTAMP struct sntp_pkt_t *rpktp = (struct sntp_pkt_t *)pkt; struct rtc_time tm; ulong seconds; -#endif debug("%s\n", __func__); if (dest != sntp_our_port) return; -#ifdef CONFIG_TIMESTAMP /* * As the RTC's used in U-Boot support second resolution only * we simply ignore the sub-second field. @@ -76,8 +73,7 @@ static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip, memcpy(&seconds, &rpktp->transmit_timestamp, sizeof(ulong)); rtc_to_tm(ntohl(seconds) - 2208988800UL + net_ntp_time_offset, &tm); -#if defined(CONFIG_CMD_DATE) -# ifdef CONFIG_DM_RTC +#ifdef CONFIG_DM_RTC struct udevice *dev; int ret; @@ -86,14 +82,12 @@ static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip, printf("SNTP: cannot find RTC: err=%d\n", ret); else dm_rtc_set(dev, &tm); -# else +#elif defined(CONFIG_CMD_DATE) rtc_set(&tm); -# endif #endif printf("Date: %4d-%02d-%02d Time: %2d:%02d:%02d\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); -#endif net_set_state(NETLOOP_SUCCESS); } diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 9f1f7445d7..ea4e045769 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -31,10 +31,14 @@ endif ifeq ($(CONFIG_TPL_BUILD),y) SPL_BIN := u-boot-tpl +SPL_NAME := tpl else SPL_BIN := u-boot-spl +SPL_NAME := spl endif +export SPL_NAME + ifdef CONFIG_SPL_BUILD SPL_ := SPL_ ifeq ($(CONFIG_TPL_BUILD),y) @@ -116,7 +120,8 @@ endif u-boot-spl-init := $(head-y) u-boot-spl-main := $(libs-y) ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA -u-boot-spl-platdata := $(obj)/dts/dt-platdata.o +u-boot-spl-platdata := $(obj)/dts/dt-plat.o +u-boot-spl-platdata_c := $(patsubst %.o,%.c,$(u-boot-spl-platdata)) endif # Linker Script @@ -298,22 +303,23 @@ $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN) @bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " toupper(size)}' | bc); \ dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null; -$(obj)/$(SPL_BIN).dtb: dts/dt-spl.dtb FORCE +$(obj)/$(SPL_BIN).dtb: $(obj)/dts/dt-$(SPL_NAME).dtb FORCE $(call if_changed,copy) pythonpath = PYTHONPATH=scripts/dtc/pylibfdt -quiet_cmd_dtocc = DTOC C $@ -cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata +DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \ + -d $(obj)/$(SPL_BIN).dtb -quiet_cmd_dtoch = DTOC H $@ -cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct +quiet_cmd_dtoc = DTOC $@ +cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all quiet_cmd_plat = PLAT $@ cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@) -targets += $(obj)/dts/dt-platdata.o -$(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \ +targets += $(u-boot-spl-platdata) + +$(obj)/dts/dt-%.o: $(obj)/dts/dt-%.c \ include/generated/dt-structs-gen.h prepare FORCE $(call if_changed,plat) @@ -321,11 +327,9 @@ PHONY += dts_dir dts_dir: $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts) -include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir FORCE - $(call if_changed,dtoch) - -$(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir FORCE - $(call if_changed,dtocc) +include/generated/dt-structs-gen.h $(u-boot-spl-platdata_c) &: \ + $(obj)/$(SPL_BIN).dtb dts_dir FORCE + $(call if_changed,dtoc) ifdef CONFIG_SAMSUNG ifdef CONFIG_VAR_SIZE_SPL @@ -382,11 +386,11 @@ endif $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE $(call if_changed,mkimage) -quiet_cmd_mksunxiboot = MKSUNXI $@ -cmd_mksunxiboot = $(objtree)/tools/mksunxiboot \ - --default-dt $(CONFIG_DEFAULT_DEVICE_TREE) $< $@ +MKIMAGEFLAGS_sunxi-spl.bin = -T sunxi_egon \ + -n $(CONFIG_DEFAULT_DEVICE_TREE) + $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE - $(call if_changed,mksunxiboot) + $(call if_changed,mkimage) quiet_cmd_sunxi_spl_image_builder = SUNXI_SPL_IMAGE_BUILDER $@ cmd_sunxi_spl_image_builder = $(objtree)/tools/sunxi-spl-image-builder \ @@ -457,9 +461,8 @@ endif PHONY += FORCE FORCE: -PHONY += dtbs -dtbs: - $(Q)$(MAKE) $(build)=dts dtbs +$(obj)/dts/dt-$(SPL_NAME).dtb: dts/dt.dtb + $(Q)$(MAKE) $(build)=$(obj)/dts spl_dtbs # Declare the contents of the .PHONY variable as phony. We keep that # information in a variable so we can use it in if_changed and friends. diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4ed7e124c9..01ab570a16 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2320,6 +2320,23 @@ sub get_raw_comment { return $comment; } +# Args: +# line: Patch line to check +# auto: Auto variable name, e.g. "per_child_auto" +# suffix: Suffix to expect on member, e.g. "_priv" +# warning: Warning name, e.g. "PRIV_AUTO" +sub u_boot_struct_name { + my ($line, $auto, $suffix, $warning) = @_; + + # Use _priv as a suffix for the device-private data struct + if ($line =~ /^\+\s*\.${auto}\s*=\s*sizeof\(struct\((\w+)\).*/) { + my $struct_name = $1; + if ($struct_name !~ /^\w+${suffix}/) { + WARN($warning, "struct \'$struct_name\' should have a ${suffix} suffix"); + } + } +} + # Checks specific to U-Boot sub u_boot_line { my ($realfile, $line, $rawline, $herecurr) = @_; @@ -2371,6 +2388,27 @@ sub u_boot_line { ERROR("CONFIG_IS_ENABLED_CONFIG", "CONFIG_IS_ENABLED() takes values without the CONFIG_ prefix\n" . $herecurr); } + + # Use _priv as a suffix for the device-private data struct + if ($line =~ /^\+\s*\.priv_auto\s*=\s*sizeof\(struct\((\w+)\).*/) { + my $struct_name = $1; + if ($struct_name !~ /^\w+_priv/) { + WARN("PRIV_AUTO", "struct \'$struct_name\' should have a _priv suffix"); + } + } + + # Check struct names for the 'auto' members of struct driver + u_boot_struct_name($line, "priv_auto", "_priv", "PRIV_AUTO"); + u_boot_struct_name($line, "plat_auto", "_plat", "PLAT_AUTO"); + u_boot_struct_name($line, "per_child_auto", "_priv", "CHILD_PRIV_AUTO"); + u_boot_struct_name($line, "per_child_plat_auto", "_plat", + "CHILD_PLAT_AUTO"); + + # Now the ones for struct uclass, skipping those in common with above + u_boot_struct_name($line, "per_device_auto", "_priv", + "DEVICE_PRIV_AUTO"); + u_boot_struct_name($line, "per_device_plat_auto", "_plat", + "DEVICE_PLAT_AUTO"); } sub process { diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 55acc38d06..e2cf205451 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -3506,7 +3506,6 @@ CONFIG_SYS_POST_WATCHDOG CONFIG_SYS_POST_WORD_ADDR CONFIG_SYS_PPC_DDR_WIMGE CONFIG_SYS_PQSPAR -CONFIG_SYS_PROMPT_HUSH_PS2 CONFIG_SYS_PSDPAR CONFIG_SYS_PSSR_VAL CONFIG_SYS_PTCPAR diff --git a/test/Makefile b/test/Makefile index 8296734eb3..d4323f9963 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,6 +5,7 @@ ifneq ($(CONFIG_SANDBOX),) obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o endif +obj-$(CONFIG_$(SPL_)CMDLINE) += bootm.o obj-$(CONFIG_$(SPL_)CMDLINE) += cmd/ obj-$(CONFIG_$(SPL_)CMDLINE) += cmd_ut.o obj-$(CONFIG_$(SPL_)CMDLINE) += command_ut.o diff --git a/test/bootm.c b/test/bootm.c new file mode 100644 index 0000000000..92dc2b6e17 --- /dev/null +++ b/test/bootm.c @@ -0,0 +1,247 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for bootm routines + * + * Copyright 2020 Google LLC + */ + +#include <common.h> +#include <bootm.h> +#include <test/suites.h> +#include <test/test.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR; + +#define BOOTM_TEST(_name, _flags) UNIT_TEST(_name, _flags, bootm_test) + +enum { + BUF_SIZE = 1024, +}; + +#define CONSOLE_STR "console=/dev/ttyS0" + +/* Test cmdline processing where nothing happens */ +static int bootm_test_nop(struct unit_test_state *uts) +{ + char buf[BUF_SIZE]; + + *buf = '\0'; + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true)); + ut_asserteq_str("", buf); + + strcpy(buf, "test"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true)); + ut_asserteq_str("test", buf); + + return 0; +} +BOOTM_TEST(bootm_test_nop, 0); + +/* Test cmdline processing when out of space */ +static int bootm_test_nospace(struct unit_test_state *uts) +{ + char buf[BUF_SIZE]; + + /* Zero buffer size */ + *buf = '\0'; + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, true)); + + /* Buffer string not terminated */ + memset(buf, 'a', BUF_SIZE); + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true)); + + /* Not enough space to copy string */ + memset(buf, '\0', BUF_SIZE); + memset(buf, 'a', BUF_SIZE / 2); + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true)); + + /* Just enough space */ + memset(buf, '\0', BUF_SIZE); + memset(buf, 'a', BUF_SIZE / 2 - 1); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true)); + + return 0; +} +BOOTM_TEST(bootm_test_nospace, 0); + +/* Test silent processing */ +static int bootm_test_silent(struct unit_test_state *uts) +{ + char buf[BUF_SIZE]; + + /* 'silent_linux' not set should do nothing */ + env_set("silent_linux", NULL); + strcpy(buf, CONSOLE_STR); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); + ut_asserteq_str(CONSOLE_STR, buf); + + ut_assertok(env_set("silent_linux", "no")); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); + ut_asserteq_str(CONSOLE_STR, buf); + + ut_assertok(env_set("silent_linux", "yes")); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); + ut_asserteq_str("console=", buf); + + /* Empty buffer should still add the string */ + *buf = '\0'; + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); + ut_asserteq_str("console=", buf); + + /* Check nothing happens when do_silent is false */ + *buf = '\0'; + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, 0)); + ut_asserteq_str("", buf); + + /* Not enough space */ + *buf = '\0'; + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 8, BOOTM_CL_SILENT)); + + /* Just enough space */ + *buf = '\0'; + ut_assertok(bootm_process_cmdline(buf, 9, BOOTM_CL_SILENT)); + + /* add at end */ + strcpy(buf, "something"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); + ut_asserteq_str("something console=", buf); + + /* change at start */ + strcpy(buf, CONSOLE_STR " something"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SILENT)); + ut_asserteq_str("console= something", buf); + + return 0; +} +BOOTM_TEST(bootm_test_silent, 0); + +/* Test substitution processing */ +static int bootm_test_subst(struct unit_test_state *uts) +{ + char buf[BUF_SIZE]; + + /* try with an unset variable */ + ut_assertok(env_set("var", NULL)); + strcpy(buf, "some${var}thing"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); + ut_asserteq_str("something", buf); + + /* Replace with shorter string */ + ut_assertok(env_set("var", "bb")); + strcpy(buf, "some${var}thing"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); + ut_asserteq_str("somebbthing", buf); + + /* Replace with same-length string */ + ut_assertok(env_set("var", "abc")); + strcpy(buf, "some${var}thing"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); + ut_asserteq_str("someabcthing", buf); + + /* Replace with longer string */ + ut_assertok(env_set("var", "abcde")); + strcpy(buf, "some${var}thing"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); + ut_asserteq_str("someabcdething", buf); + + /* Check it is case sensitive */ + ut_assertok(env_set("VAR", NULL)); + strcpy(buf, "some${VAR}thing"); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); + ut_asserteq_str("something", buf); + + /* Check too long - need 12 bytes for each string */ + strcpy(buf, "some${var}thing"); + ut_asserteq(-ENOSPC, + bootm_process_cmdline(buf, 12 * 2 - 1, BOOTM_CL_SUBST)); + + /* Check just enough space */ + strcpy(buf, "some${var}thing"); + ut_assertok(bootm_process_cmdline(buf, 16 * 2, BOOTM_CL_SUBST)); + ut_asserteq_str("someabcdething", buf); + + /* + * Check the substition string being too long. This results in a string + * of 12 (13 bytes). We need enough space for that plus the original + * "a${var}c" string of 9 bytes. So 12 + 9 = 21 bytes. + */ + ut_assertok(env_set("var", "1234567890")); + strcpy(buf, "a${var}c"); + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 21, BOOTM_CL_SUBST)); + + strcpy(buf, "a${var}c"); + ut_asserteq(0, bootm_process_cmdline(buf, 22, BOOTM_CL_SUBST)); + + /* Check multiple substitutions */ + ut_assertok(env_set("var", "abc")); + strcpy(buf, "some${var}thing${bvar}else"); + ut_asserteq(0, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); + ut_asserteq_str("someabcthingelse", buf); + + /* Check multiple substitutions */ + ut_assertok(env_set("bvar", "123")); + strcpy(buf, "some${var}thing${bvar}else"); + ut_asserteq(0, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); + ut_asserteq_str("someabcthing123else", buf); + + return 0; +} +BOOTM_TEST(bootm_test_subst, 0); + +/* Test silent processing in the bootargs variable */ +static int bootm_test_silent_var(struct unit_test_state *uts) +{ + env_set("bootargs", NULL); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SUBST)); + ut_assertnull(env_get("bootargs")); + + ut_assertok(env_set("bootargs", "some${var}thing")); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SUBST)); + ut_asserteq_str("something", env_get("bootargs")); + + return 0; +} +BOOTM_TEST(bootm_test_silent_var, 0); + +/* Test substitution processing in the bootargs variable */ +static int bootm_test_subst_var(struct unit_test_state *uts) +{ + env_set("bootargs", NULL); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); + ut_asserteq_str("console=", env_get("bootargs")); + + ut_assertok(env_set("var", "abc")); + ut_assertok(env_set("bootargs", "some${var}thing")); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); + ut_asserteq_str("some${var}thing console=", env_get("bootargs")); + + return 0; +} +BOOTM_TEST(bootm_test_subst_var, 0); + +/* Test substitution and silent console processing in the bootargs variable */ +static int bootm_test_subst_both(struct unit_test_state *uts) +{ + ut_assertok(env_set("silent_linux", "yes")); + env_set("bootargs", NULL); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_ALL)); + ut_asserteq_str("console=", env_get("bootargs")); + + ut_assertok(env_set("bootargs", "some${var}thing " CONSOLE_STR)); + ut_assertok(env_set("var", "1234567890")); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_ALL)); + ut_asserteq_str("some1234567890thing console=", env_get("bootargs")); + + return 0; +} +BOOTM_TEST(bootm_test_subst_both, 0); + +int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, bootm_test); + const int n_ents = ll_entry_count(struct unit_test, bootm_test); + + return cmd_ut_category("bootm", "bootm_test_", tests, n_ents, + argc, argv); +} diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 859dcda239..b2f71af847 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -4,3 +4,4 @@ obj-y += mem.o obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o +obj-y += setexpr.o diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c new file mode 100644 index 0000000000..fd6d869c0e --- /dev/null +++ b/test/cmd/setexpr.c @@ -0,0 +1,384 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for setexpr command + * + * Copyright 2020 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <common.h> +#include <console.h> +#include <mapmem.h> +#include <dm/test.h> +#include <test/suites.h> +#include <test/ut.h> + +#define BUF_SIZE 0x100 + +/* Declare a new mem test */ +#define SETEXPR_TEST(_name, _flags) UNIT_TEST(_name, _flags, setexpr_test) + +/* Test 'setexpr' command with simply setting integers */ +static int setexpr_test_int(struct unit_test_state *uts) +{ + u8 *buf; + + buf = map_sysmem(0, BUF_SIZE); + memset(buf, '\xff', BUF_SIZE); + + /* byte */ + buf[0x0] = 0x12; + ut_assertok(run_command("setexpr.b fred 0", 0)); + ut_asserteq_str("0", env_get("fred")); + ut_assertok(run_command("setexpr.b fred *0", 0)); + ut_asserteq_str("12", env_get("fred")); + + /* 16-bit */ + *(short *)buf = 0x2345; + ut_assertok(run_command("setexpr.w fred 0", 0)); + ut_asserteq_str("0", env_get("fred")); + ut_assertok(run_command("setexpr.w fred *0", 0)); + ut_asserteq_str("2345", env_get("fred")); + + /* 32-bit */ + *(u32 *)buf = 0x3456789a; + ut_assertok(run_command("setexpr.l fred 0", 0)); + ut_asserteq_str("0", env_get("fred")); + ut_assertok(run_command("setexpr.l fred *0", 0)); + ut_asserteq_str("3456789a", env_get("fred")); + + /* 64-bit */ + *(u64 *)buf = 0x456789abcdef0123; + ut_assertok(run_command("setexpr.q fred 0", 0)); + ut_asserteq_str("0", env_get("fred")); + ut_assertok(run_command("setexpr.q fred *0", 0)); + ut_asserteq_str("456789abcdef0123", env_get("fred")); + + /* default */ + ut_assertok(run_command("setexpr fred 0", 0)); + ut_asserteq_str("0", env_get("fred")); + ut_assertok(run_command("setexpr fred *0", 0)); + ut_asserteq_str("cdef0123", env_get("fred")); + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_int, UT_TESTF_CONSOLE_REC); + +/* Test 'setexpr' command with + operator */ +static int setexpr_test_plus(struct unit_test_state *uts) +{ + char *buf; + + buf = map_sysmem(0, BUF_SIZE); + memset(buf, '\xff', BUF_SIZE); + + /* byte */ + buf[0x0] = 0x12; + buf[0x10] = 0x34; + ut_assertok(run_command("setexpr.b fred *0 + *10", 0)); + ut_asserteq_str("46", env_get("fred")); + + /* 16-bit */ + *(short *)buf = 0x2345; + *(short *)(buf + 0x10) = 0xf012; + ut_assertok(run_command("setexpr.w fred *0 + *10", 0)); + ut_asserteq_str("11357", env_get("fred")); + + /* 32-bit */ + *(u32 *)buf = 0x3456789a; + *(u32 *)(buf + 0x10) = 0xc3384235; + ut_assertok(run_command("setexpr.l fred *0 + *10", 0)); + ut_asserteq_str("f78ebacf", env_get("fred")); + + /* 64-bit */ + *(u64 *)buf = 0x456789abcdef0123; + *(u64 *)(buf + 0x10) = 0x4987328372849283; + ut_assertok(run_command("setexpr.q fred *0 + *10", 0)); + ut_asserteq_str("8eeebc2f407393a6", env_get("fred")); + + /* default */ + ut_assertok(run_command("setexpr fred *0 + *10", 0)); + ut_asserteq_str("1407393a6", env_get("fred")); + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_plus, UT_TESTF_CONSOLE_REC); + +/* Test 'setexpr' command with other operators */ +static int setexpr_test_oper(struct unit_test_state *uts) +{ + char *buf; + + buf = map_sysmem(0, BUF_SIZE); + memset(buf, '\xff', BUF_SIZE); + + *(u32 *)buf = 0x1234; + *(u32 *)(buf + 0x10) = 0x560000; + + /* Quote | to avoid confusing hush */ + ut_assertok(run_command("setexpr fred *0 \"|\" *10", 0)); + ut_asserteq_str("561234", env_get("fred")); + + *(u32 *)buf = 0x561200; + *(u32 *)(buf + 0x10) = 0x1234; + + /* Quote & to avoid confusing hush */ + ut_assertok(run_command("setexpr.l fred *0 \"&\" *10", 0)); + ut_asserteq_str("1200", env_get("fred")); + + ut_assertok(run_command("setexpr.l fred *0 ^ *10", 0)); + ut_asserteq_str("560034", env_get("fred")); + + ut_assertok(run_command("setexpr.l fred *0 - *10", 0)); + ut_asserteq_str("55ffcc", env_get("fred")); + + ut_assertok(run_command("setexpr.l fred *0 * *10", 0)); + ut_asserteq_str("61ebfa800", env_get("fred")); + + ut_assertok(run_command("setexpr.l fred *0 / *10", 0)); + ut_asserteq_str("4ba", env_get("fred")); + + ut_assertok(run_command("setexpr.l fred *0 % *10", 0)); + ut_asserteq_str("838", env_get("fred")); + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_oper, UT_TESTF_CONSOLE_REC); + +/* Test 'setexpr' command with regex */ +static int setexpr_test_regex(struct unit_test_state *uts) +{ + char *buf, *val; + + buf = map_sysmem(0, BUF_SIZE); + + /* Single substitution */ + ut_assertok(run_command("setenv fred 'this is a test'", 0)); + ut_assertok(run_command("setexpr fred sub is us", 0)); + val = env_get("fred"); + ut_asserteq_str("thus is a test", val); + + /* Global substitution */ + ut_assertok(run_command("setenv fred 'this is a test'", 0)); + ut_assertok(run_command("setexpr fred gsub is us", 0)); + val = env_get("fred"); + ut_asserteq_str("thus us a test", val); + + /* Global substitution */ + ut_assertok(run_command("setenv fred 'this is a test'", 0)); + ut_assertok(run_command("setenv mary 'this is a test'", 0)); + ut_assertok(run_command("setexpr fred gsub is us \"${mary}\"", 0)); + val = env_get("fred"); + ut_asserteq_str("thus us a test", val); + val = env_get("mary"); + ut_asserteq_str("this is a test", val); + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_regex, UT_TESTF_CONSOLE_REC); + +/* Test 'setexpr' command with regex replacement that expands the string */ +static int setexpr_test_regex_inc(struct unit_test_state *uts) +{ + char *buf, *val; + + buf = map_sysmem(0, BUF_SIZE); + + ut_assertok(run_command("setenv fred 'this is a test'", 0)); + ut_assertok(run_command("setexpr fred gsub is much_longer_string", 0)); + val = env_get("fred"); + ut_asserteq_str("thmuch_longer_string much_longer_string a test", val); + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_regex_inc, UT_TESTF_CONSOLE_REC); + +/* Test setexpr_regex_sub() directly to check buffer usage */ +static int setexpr_test_sub(struct unit_test_state *uts) +{ + char *buf, *nbuf; + int i; + + buf = map_sysmem(0, BUF_SIZE); + nbuf = map_sysmem(0x1000, BUF_SIZE); + + /* Add a pattern so we can check the buffer limits */ + memset(buf, '\xff', BUF_SIZE); + memset(nbuf, '\xff', BUF_SIZE); + for (i = BUF_SIZE; i < 0x1000; i++) { + buf[i] = i & 0xff; + nbuf[i] = i & 0xff; + } + strcpy(buf, "this is a test"); + + /* + * This is a regression test, since a bug was found in the use of + * memmove() in setexpr + */ + ut_assertok(setexpr_regex_sub(buf, BUF_SIZE, nbuf, BUF_SIZE, "is", + "us it is longer", true)); + ut_asserteq_str("thus it is longer us it is longer a test", buf); + for (i = BUF_SIZE; i < 0x1000; i++) { + ut_assertf(buf[i] == (char)i, + "buf byte at %x should be %02x, got %02x)\n", + i, i & 0xff, (u8)buf[i]); + ut_assertf(nbuf[i] == (char)i, + "nbuf byte at %x should be %02x, got %02x)\n", + i, i & 0xff, (u8)nbuf[i]); + } + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_sub, UT_TESTF_CONSOLE_REC); + +/* Test setexpr_regex_sub() with back references */ +static int setexpr_test_backref(struct unit_test_state *uts) +{ + char *buf, *nbuf; + int i; + + buf = map_sysmem(0, BUF_SIZE); + nbuf = map_sysmem(0x1000, BUF_SIZE); + + /* Add a pattern so we can check the buffer limits */ + memset(buf, '\xff', BUF_SIZE); + memset(nbuf, '\xff', BUF_SIZE); + for (i = BUF_SIZE; i < 0x1000; i++) { + buf[i] = i & 0xff; + nbuf[i] = i & 0xff; + } + strcpy(buf, "this is surely a test is it? yes this is indeed a test"); + + /* + * This is a regression test, since a bug was found in the use of + * memmove() in setexpr + */ + ut_assertok(setexpr_regex_sub(buf, BUF_SIZE, nbuf, BUF_SIZE, + "(this) (is) (surely|indeed)", + "us \\1 \\2 \\3!", true)); + ut_asserteq_str("us this is surely! a test is it? yes us this is indeed! a test", + buf); + + /* The following checks fail at present due to a bug in setexpr */ + return 0; + for (i = BUF_SIZE; i < 0x1000; i++) { + ut_assertf(buf[i] == (char)i, + "buf byte at %x should be %02x, got %02x)\n", + i, i & 0xff, (u8)buf[i]); + ut_assertf(nbuf[i] == (char)i, + "nbuf byte at %x should be %02x, got %02x)\n", + i, i & 0xff, (u8)nbuf[i]); + } + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_backref, UT_TESTF_CONSOLE_REC); + +/* Test 'setexpr' command with setting strings */ +static int setexpr_test_str(struct unit_test_state *uts) +{ + ulong start_mem; + char *buf; + + buf = map_sysmem(0, BUF_SIZE); + memset(buf, '\xff', BUF_SIZE); + + /* + * Set 'fred' to the same length as we expect to get below, to avoid a + * new allocation in 'setexpr'. That way we can check for memory leaks. + */ + ut_assertok(env_set("fred", "x")); + start_mem = ut_check_free(); + strcpy(buf, "hello"); + ut_asserteq(1, run_command("setexpr.s fred 0", 0)); + ut_assertok(ut_check_delta(start_mem)); + + start_mem = ut_check_free(); + ut_assertok(env_set("fred", "12345")); + ut_assertok(run_command("setexpr.s fred *0", 0)); + ut_asserteq_str("hello", env_get("fred")); + ut_assertok(ut_check_delta(start_mem)); + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_str, UT_TESTF_CONSOLE_REC); + + +/* Test 'setexpr' command with concatenating strings */ +static int setexpr_test_str_oper(struct unit_test_state *uts) +{ + ulong start_mem; + char *buf; + + buf = map_sysmem(0, BUF_SIZE); + memset(buf, '\xff', BUF_SIZE); + strcpy(buf, "hello"); + strcpy(buf + 0x10, " there"); + + ut_assertok(console_record_reset_enable()); + start_mem = ut_check_free(); + ut_asserteq(1, run_command("setexpr.s fred *0 * *10", 0)); + ut_assertok(ut_check_delta(start_mem)); + ut_assert_nextline("invalid op"); + ut_assert_console_end(); + + /* + * Set 'fred' to the same length as we expect to get below, to avoid a + * new allocation in 'setexpr'. That way we can check for memory leaks. + */ + ut_assertok(env_set("fred", "12345012345")); + start_mem = ut_check_free(); + ut_assertok(run_command("setexpr.s fred *0 + *10", 0)); + ut_asserteq_str("hello there", env_get("fred")); + ut_assertok(ut_check_delta(start_mem)); + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_str_oper, UT_TESTF_CONSOLE_REC); + +/* Test 'setexpr' command with a string that is too long */ +static int setexpr_test_str_long(struct unit_test_state *uts) +{ + const int size = 128 << 10; /* setexpr strings are a max of 64KB */ + char *buf, *val; + + buf = map_sysmem(0, size); + memset(buf, 'a', size); + + /* String should be truncated to 64KB */ + ut_assertok(run_command("setexpr.s fred *0", 0)); + val = env_get("fred"); + ut_asserteq(64 << 10, strlen(val)); + + unmap_sysmem(buf); + + return 0; +} +SETEXPR_TEST(setexpr_test_str_long, UT_TESTF_CONSOLE_REC); + +int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, + setexpr_test); + const int n_ents = ll_entry_count(struct unit_test, setexpr_test); + + return cmd_ut_category("cmd_setexpr", "cmd_mem_", tests, n_ents, argc, + argv); +} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 8f0bc688a2..fad1c899a4 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -75,6 +75,8 @@ static struct cmd_tbl cmd_ut_sub[] = { U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_ut_log, "", ""), #endif U_BOOT_CMD_MKENT(mem, CONFIG_SYS_MAXARGS, 1, do_ut_mem, "", ""), + U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "", + ""), #ifdef CONFIG_UT_TIME U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""), #endif @@ -86,6 +88,7 @@ static struct cmd_tbl cmd_ut_sub[] = { "", ""), U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist, "", ""), + U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""), U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""), #endif @@ -153,6 +156,7 @@ static char ut_help_text[] = #ifdef CONFIG_UT_OVERLAY "ut overlay [test-name]\n" #endif + "ut setexpr [test-name] - test setexpr command\n" #ifdef CONFIG_SANDBOX "ut str - Basic test of string functions\n" #endif diff --git a/test/dm/acpi.c b/test/dm/acpi.c index f5eddac10d..e0a323ecd4 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -25,12 +25,12 @@ #define BUF_SIZE 4096 /** - * struct testacpi_platdata - Platform data for the test ACPI device + * struct testacpi_plat - Platform data for the test ACPI device * * @no_name: true to emit an empty ACPI name from testacpi_get_name() * @return_error: true to return an error instead of a name */ -struct testacpi_platdata { +struct testacpi_plat { bool return_error; bool no_name; }; @@ -53,7 +53,7 @@ static int testacpi_write_tables(const struct udevice *dev, static int testacpi_get_name(const struct udevice *dev, char *out_name) { - struct testacpi_platdata *plat = dev_get_platdata(dev); + struct testacpi_plat *plat = dev_get_plat(dev); if (plat->return_error) return -EINVAL; @@ -110,7 +110,7 @@ U_BOOT_DRIVER(testacpi_drv) = { .of_match = testacpi_ids, .id = UCLASS_TEST_ACPI, .bind = dm_scan_fdt_dev, - .platdata_auto_alloc_size = sizeof(struct testacpi_platdata), + .plat_auto = sizeof(struct testacpi_plat), ACPI_OPS_PTR(&testacpi_ops) }; @@ -123,7 +123,7 @@ UCLASS_DRIVER(testacpi) = { static int dm_test_acpi_get_name(struct unit_test_state *uts) { char name[ACPI_NAME_MAX]; - struct udevice *dev, *dev2, *i2c, *spi, *serial, *timer, *sound; + struct udevice *dev, *dev2, *i2c, *spi, *timer, *sound; struct udevice *pci, *root; /* Test getting the name from the driver */ @@ -146,10 +146,6 @@ static int dm_test_acpi_get_name(struct unit_test_state *uts) ut_assertok(acpi_get_name(spi, name)); ut_asserteq_str("SPI0", name); - /* The uart has no sequence number, so this should fail */ - ut_assertok(uclass_first_device(UCLASS_SERIAL, &serial)); - ut_asserteq(-ENXIO, acpi_get_name(serial, name)); - /* ACPI doesn't know about the timer */ ut_assertok(uclass_first_device(UCLASS_TIMER, &timer)); ut_asserteq(-ENOENT, acpi_get_name(timer, name)); @@ -422,7 +418,7 @@ DM_TEST(dm_test_acpi_cmd_dump, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); /* Test acpi_device_path() */ static int dm_test_acpi_device_path(struct unit_test_state *uts) { - struct testacpi_platdata *plat; + struct testacpi_plat *plat; char buf[ACPI_PATH_MAX]; struct udevice *dev, *child; @@ -442,13 +438,13 @@ static int dm_test_acpi_device_path(struct unit_test_state *uts) buf); /* Test handling of a device which doesn't produce a name */ - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); plat->no_name = true; ut_assertok(acpi_device_path(child, buf, sizeof(buf))); ut_asserteq_str("\\_SB." ACPI_TEST_CHILD_NAME, buf); /* Test handling of a device which returns an error */ - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); plat->return_error = true; ut_asserteq(-EINVAL, acpi_device_path(child, buf, sizeof(buf))); diff --git a/test/dm/adc.c b/test/dm/adc.c index 8c6e4b0604..740167e16b 100644 --- a/test/dm/adc.c +++ b/test/dm/adc.c @@ -67,7 +67,7 @@ static int dm_test_adc_supply(struct unit_test_state *uts) ut_assertok(regulator_set_value(supply, SANDBOX_BUCK2_SET_UV)); ut_asserteq(SANDBOX_BUCK2_SET_UV, regulator_get_value(supply)); - /* Update ADC platdata and get new Vdd value */ + /* Update ADC plat and get new Vdd value */ ut_assertok(adc_vdd_value(dev, &uV)); ut_asserteq(SANDBOX_BUCK2_SET_UV, uV); diff --git a/test/dm/blk.c b/test/dm/blk.c index f34c13f751..a39a1ebd28 100644 --- a/test/dm/blk.c +++ b/test/dm/blk.c @@ -19,9 +19,6 @@ static int dm_test_blk_base(struct unit_test_state *uts) { struct udevice *blk1, *blk3, *dev; - /* Make sure there are no block devices */ - ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_BLK, 0, &dev)); - /* Create two, one the parent of the other */ ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test", IF_TYPE_HOST, 1, 512, 2, &blk1)); @@ -139,7 +136,7 @@ static int dm_test_blk_devnum(struct unit_test_state *uts) * Check that the block device devnum matches its parent's * sequence number */ - desc = dev_get_uclass_platdata(dev); + desc = dev_get_uclass_plat(dev); ut_asserteq(desc->devnum, i); } diff --git a/test/dm/bus.c b/test/dm/bus.c index 27b7266645..e768eab695 100644 --- a/test/dm/bus.c +++ b/test/dm/bus.c @@ -19,104 +19,6 @@ DECLARE_GLOBAL_DATA_PTR; -struct dm_test_parent_platdata { - int count; - int bind_flag; - int uclass_bind_flag; -}; - -enum { - FLAG_CHILD_PROBED = 10, - FLAG_CHILD_REMOVED = -7, -}; - -static struct dm_test_state *test_state; - -static int testbus_drv_probe(struct udevice *dev) -{ - return dm_scan_fdt_dev(dev); -} - -static int testbus_child_post_bind(struct udevice *dev) -{ - struct dm_test_parent_platdata *plat; - - plat = dev_get_parent_platdata(dev); - plat->bind_flag = 1; - plat->uclass_bind_flag = 2; - - return 0; -} - -static int testbus_child_pre_probe(struct udevice *dev) -{ - struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev); - - parent_data->flag += FLAG_CHILD_PROBED; - - return 0; -} - -static int testbus_child_pre_probe_uclass(struct udevice *dev) -{ - struct dm_test_priv *priv = dev_get_priv(dev); - - priv->uclass_flag++; - - return 0; -} - -static int testbus_child_post_probe_uclass(struct udevice *dev) -{ - struct dm_test_priv *priv = dev_get_priv(dev); - - priv->uclass_postp++; - - return 0; -} - -static int testbus_child_post_remove(struct udevice *dev) -{ - struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev); - struct dm_test_state *dms = test_state; - - parent_data->flag += FLAG_CHILD_REMOVED; - if (dms) - dms->removed = dev; - - return 0; -} - -static const struct udevice_id testbus_ids[] = { - { - .compatible = "denx,u-boot-test-bus", - .data = DM_TEST_TYPE_FIRST }, - { } -}; - -U_BOOT_DRIVER(testbus_drv) = { - .name = "testbus_drv", - .of_match = testbus_ids, - .id = UCLASS_TEST_BUS, - .probe = testbus_drv_probe, - .child_post_bind = testbus_child_post_bind, - .priv_auto_alloc_size = sizeof(struct dm_test_priv), - .platdata_auto_alloc_size = sizeof(struct dm_test_pdata), - .per_child_auto_alloc_size = sizeof(struct dm_test_parent_data), - .per_child_platdata_auto_alloc_size = - sizeof(struct dm_test_parent_platdata), - .child_pre_probe = testbus_child_pre_probe, - .child_post_remove = testbus_child_post_remove, -}; - -UCLASS_DRIVER(testbus) = { - .name = "testbus", - .id = UCLASS_TEST_BUS, - .flags = DM_UC_FLAG_SEQ_ALIAS, - .child_pre_probe = testbus_child_pre_probe_uclass, - .child_post_probe = testbus_child_post_probe_uclass, -}; - /* Test that we can probe for children */ static int dm_test_bus_children(struct unit_test_state *uts) { @@ -153,20 +55,21 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts) ut_assertok(device_get_child(bus, 0, &dev)); ut_asserteq(-ENODEV, device_get_child(bus, 4, &dev)); ut_assertok(device_get_child_by_seq(bus, 5, &dev)); - ut_assert(dev->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED); ut_asserteq_str("c-test@5", dev->name); /* Device with sequence number 0 should be accessible */ - ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, true, &dev)); - ut_assertok(device_find_child_by_seq(bus, 0, true, &dev)); - ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); - ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 0, false, &dev)); + ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, &dev)); + ut_assertok(device_find_child_by_seq(bus, 0, &dev)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); + ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev)); ut_assertok(device_get_child_by_seq(bus, 0, &dev)); - ut_assert(dev->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED); + ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev)); /* There is no device with sequence number 2 */ - ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 2, false, &dev)); - ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 2, true, &dev)); + ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 2, &dev)); + ut_asserteq(-ENODEV, device_find_child_by_seq(bus, 2, &dev)); ut_asserteq(-ENODEV, device_get_child_by_seq(bus, 2, &dev)); /* Looking for something that is not a child */ @@ -193,10 +96,10 @@ static int dm_test_bus_children_of_offset(struct unit_test_state *uts) ut_assert(node > 0); ut_assertok(device_find_child_by_of_offset(bus, node, &dev)); ut_assertnonnull(dev); - ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); ut_assertok(device_get_child_by_of_offset(bus, node, &dev)); ut_assertnonnull(dev); - ut_assert(dev->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED); return 0; } @@ -220,7 +123,7 @@ static int dm_test_bus_children_iterators(struct unit_test_state *uts) ut_asserteq_ptr(dev, NULL); /* Move to the next child without using device_find_first_child() */ - ut_assertok(device_find_child_by_seq(bus, 5, true, &dev)); + ut_assertok(device_find_child_by_seq(bus, 5, &dev)); ut_asserteq_str("c-test@5", dev->name); ut_assertok(device_find_next_child(&dev)); ut_asserteq_str("c-test@0", dev->name); @@ -245,7 +148,7 @@ static int test_bus_parent_data(struct unit_test_state *uts) ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus)); /* Check that parent data is allocated */ - ut_assertok(device_find_child_by_seq(bus, 0, true, &dev)); + ut_assertok(device_find_child_by_seq(bus, 0, &dev)); ut_asserteq_ptr(NULL, dev_get_parent_priv(dev)); ut_assertok(device_get_child_by_seq(bus, 0, &dev)); parent_data = dev_get_parent_priv(dev); @@ -312,19 +215,19 @@ static int dm_test_bus_parent_data_uclass(struct unit_test_state *uts) /* Set the driver size to 0 so that the uclass size is used */ ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus)); drv = (struct driver *)bus->driver; - size = drv->per_child_auto_alloc_size; + size = drv->per_child_auto; #ifdef CONFIG_SANDBOX os_mprotect_allow(bus->uclass->uc_drv, sizeof(*bus->uclass->uc_drv)); os_mprotect_allow(drv, sizeof(*drv)); #endif - bus->uclass->uc_drv->per_child_auto_alloc_size = size; - drv->per_child_auto_alloc_size = 0; + bus->uclass->uc_drv->per_child_auto = size; + drv->per_child_auto = 0; ret = test_bus_parent_data(uts); if (ret) return ret; - bus->uclass->uc_drv->per_child_auto_alloc_size = 0; - drv->per_child_auto_alloc_size = size; + bus->uclass->uc_drv->per_child_auto = 0; + drv->per_child_auto = size; return 0; } @@ -335,11 +238,10 @@ DM_TEST(dm_test_bus_parent_data_uclass, static int dm_test_bus_parent_ops(struct unit_test_state *uts) { struct dm_test_parent_data *parent_data; - struct dm_test_state *dms = uts->priv; struct udevice *bus, *dev; struct uclass *uc; - test_state = dms; + testbus_get_clear_removed(); ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus)); ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc)); @@ -351,7 +253,7 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts) ut_assertok(device_probe(dev)); parent_data = dev_get_parent_priv(dev); - ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag); + ut_asserteq(TEST_FLAG_CHILD_PROBED, parent_data->flag); } uclass_foreach_dev(dev, uc) { @@ -359,20 +261,19 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts) if (dev->parent != bus) continue; parent_data = dev_get_parent_priv(dev); - ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag); + ut_asserteq(TEST_FLAG_CHILD_PROBED, parent_data->flag); ut_assertok(device_remove(dev, DM_REMOVE_NORMAL)); ut_asserteq_ptr(NULL, dev_get_parent_priv(dev)); - ut_asserteq_ptr(dms->removed, dev); + ut_asserteq_ptr(testbus_get_clear_removed(), dev); } - test_state = NULL; return 0; } DM_TEST(dm_test_bus_parent_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); -static int test_bus_parent_platdata(struct unit_test_state *uts) +static int test_bus_parent_plat(struct unit_test_state *uts) { - struct dm_test_parent_platdata *plat; + struct dm_test_parent_plat *plat; struct udevice *bus, *dev; /* Check that the bus has no children */ @@ -386,7 +287,7 @@ static int test_bus_parent_platdata(struct unit_test_state *uts) dev; device_find_next_child(&dev)) { /* Check that platform data is allocated */ - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); ut_assert(plat != NULL); /* @@ -398,7 +299,7 @@ static int test_bus_parent_platdata(struct unit_test_state *uts) device_probe(dev); device_remove(dev, DM_REMOVE_NORMAL); - ut_asserteq_ptr(plat, dev_get_parent_platdata(dev)); + ut_asserteq_ptr(plat, dev_get_parent_plat(dev)); ut_asserteq(1, plat->count); ut_assertok(device_probe(dev)); } @@ -410,7 +311,7 @@ static int test_bus_parent_platdata(struct unit_test_state *uts) dev; device_find_next_child(&dev)) { /* Check that platform data is allocated */ - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); ut_assert(plat != NULL); ut_asserteq(1, plat->count); } @@ -423,13 +324,13 @@ static int test_bus_parent_platdata(struct unit_test_state *uts) device_unbind(dev); } while (dev); - /* Now the child platdata should be removed and re-added */ + /* Now the child plat should be removed and re-added */ device_probe(bus); for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { /* Check that platform data is allocated */ - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); ut_assert(plat != NULL); ut_asserteq(0, plat->count); } @@ -439,14 +340,14 @@ static int test_bus_parent_platdata(struct unit_test_state *uts) } /* Test that the bus can store platform data about each child */ -static int dm_test_bus_parent_platdata(struct unit_test_state *uts) +static int dm_test_bus_parent_plat(struct unit_test_state *uts) { - return test_bus_parent_platdata(uts); + return test_bus_parent_plat(uts); } -DM_TEST(dm_test_bus_parent_platdata, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +DM_TEST(dm_test_bus_parent_plat, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); /* As above but the size is controlled by the uclass */ -static int dm_test_bus_parent_platdata_uclass(struct unit_test_state *uts) +static int dm_test_bus_parent_plat_uclass(struct unit_test_state *uts) { struct udevice *bus; struct driver *drv; @@ -456,28 +357,28 @@ static int dm_test_bus_parent_platdata_uclass(struct unit_test_state *uts) /* Set the driver size to 0 so that the uclass size is used */ ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus)); drv = (struct driver *)bus->driver; - size = drv->per_child_platdata_auto_alloc_size; + size = drv->per_child_plat_auto; #ifdef CONFIG_SANDBOX os_mprotect_allow(bus->uclass->uc_drv, sizeof(*bus->uclass->uc_drv)); os_mprotect_allow(drv, sizeof(*drv)); #endif - bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size; - drv->per_child_platdata_auto_alloc_size = 0; - ret = test_bus_parent_platdata(uts); + bus->uclass->uc_drv->per_child_plat_auto = size; + drv->per_child_plat_auto = 0; + ret = test_bus_parent_plat(uts); if (ret) return ret; - bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = 0; - drv->per_child_platdata_auto_alloc_size = size; + bus->uclass->uc_drv->per_child_plat_auto = 0; + drv->per_child_plat_auto = size; return 0; } -DM_TEST(dm_test_bus_parent_platdata_uclass, +DM_TEST(dm_test_bus_parent_plat_uclass, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); /* Test that the child post_bind method is called */ static int dm_test_bus_child_post_bind(struct unit_test_state *uts) { - struct dm_test_parent_platdata *plat; + struct dm_test_parent_plat *plat; struct udevice *bus, *dev; ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus)); @@ -485,7 +386,7 @@ static int dm_test_bus_child_post_bind(struct unit_test_state *uts) dev; device_find_next_child(&dev)) { /* Check that platform data is allocated */ - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); ut_assert(plat != NULL); ut_asserteq(1, plat->bind_flag); } @@ -498,7 +399,7 @@ DM_TEST(dm_test_bus_child_post_bind, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); /* Test that the child post_bind method is called */ static int dm_test_bus_child_post_bind_uclass(struct unit_test_state *uts) { - struct dm_test_parent_platdata *plat; + struct dm_test_parent_plat *plat; struct udevice *bus, *dev; ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus)); @@ -506,7 +407,7 @@ static int dm_test_bus_child_post_bind_uclass(struct unit_test_state *uts) dev; device_find_next_child(&dev)) { /* Check that platform data is allocated */ - plat = dev_get_parent_platdata(dev); + plat = dev_get_parent_plat(dev); ut_assert(plat != NULL); ut_asserteq(2, plat->uclass_bind_flag); } diff --git a/test/dm/clk.c b/test/dm/clk.c index edca3b49f6..21997ed892 100644 --- a/test/dm/clk.c +++ b/test/dm/clk.c @@ -117,6 +117,28 @@ static int dm_test_clk(struct unit_test_state *uts) ut_asserteq(20000, sandbox_clk_test_get_rate(dev_test, SANDBOX_CLK_TEST_ID_I2C)); + ut_asserteq(5000, sandbox_clk_test_round_rate(dev_test, + SANDBOX_CLK_TEST_ID_SPI, + 5000)); + ut_asserteq(7000, sandbox_clk_test_round_rate(dev_test, + SANDBOX_CLK_TEST_ID_I2C, + 7000)); + + ut_asserteq(10000, sandbox_clk_test_get_rate(dev_test, + SANDBOX_CLK_TEST_ID_SPI)); + ut_asserteq(20000, sandbox_clk_test_get_rate(dev_test, + SANDBOX_CLK_TEST_ID_I2C)); + + rate = sandbox_clk_test_round_rate(dev_test, SANDBOX_CLK_TEST_ID_SPI, 0); + ut_assert(IS_ERR_VALUE(rate)); + rate = sandbox_clk_test_round_rate(dev_test, SANDBOX_CLK_TEST_ID_I2C, 0); + ut_assert(IS_ERR_VALUE(rate)); + + ut_asserteq(10000, sandbox_clk_test_get_rate(dev_test, + SANDBOX_CLK_TEST_ID_SPI)); + ut_asserteq(20000, sandbox_clk_test_get_rate(dev_test, + SANDBOX_CLK_TEST_ID_I2C)); + ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI)); ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C)); ut_asserteq(10000, sandbox_clk_query_rate(dev_clk, SANDBOX_CLK_ID_SPI)); diff --git a/test/dm/core.c b/test/dm/core.c index 6f380a574c..1f5ca570dc 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -43,29 +43,29 @@ static const struct dm_test_pdata test_pdata_pre_reloc = { .ping_add = TEST_INTVAL_PRE_RELOC, }; -U_BOOT_DEVICE(dm_test_info1) = { +U_BOOT_DRVINFO(dm_test_info1) = { .name = "test_drv", - .platdata = &test_pdata[0], + .plat = &test_pdata[0], }; -U_BOOT_DEVICE(dm_test_info2) = { +U_BOOT_DRVINFO(dm_test_info2) = { .name = "test_drv", - .platdata = &test_pdata[1], + .plat = &test_pdata[1], }; -U_BOOT_DEVICE(dm_test_info3) = { +U_BOOT_DRVINFO(dm_test_info3) = { .name = "test_drv", - .platdata = &test_pdata[2], + .plat = &test_pdata[2], }; static struct driver_info driver_info_manual = { .name = "test_manual_drv", - .platdata = &test_pdata_manual, + .plat = &test_pdata_manual, }; static struct driver_info driver_info_pre_reloc = { .name = "test_pre_reloc_drv", - .platdata = &test_pdata_pre_reloc, + .plat = &test_pdata_pre_reloc, }; static struct driver_info driver_info_act_dma = { @@ -105,7 +105,7 @@ int dm_leak_check_end(struct unit_test_state *uts) return 0; } -/* Test that binding with platdata occurs correctly */ +/* Test that binding with plat occurs correctly */ static int dm_test_autobind(struct unit_test_state *uts) { struct dm_test_state *dms = uts->priv; @@ -116,14 +116,14 @@ static int dm_test_autobind(struct unit_test_state *uts) * device with no children. */ ut_assert(dms->root); - ut_asserteq(1, list_count_items(&gd->uclass_root)); + ut_asserteq(1, list_count_items(gd->uclass_root)); ut_asserteq(0, list_count_items(&gd->dm_root->child_head)); ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]); - ut_assertok(dm_scan_platdata(false)); + ut_assertok(dm_scan_plat(false)); /* We should have our test class now at least, plus more children */ - ut_assert(1 < list_count_items(&gd->uclass_root)); + ut_assert(1 < list_count_items(gd->uclass_root)); ut_assert(0 < list_count_items(&gd->dm_root->child_head)); /* Our 3 dm_test_infox children should be bound to the test uclass */ @@ -131,7 +131,7 @@ static int dm_test_autobind(struct unit_test_state *uts) /* No devices should be probed */ list_for_each_entry(dev, &gd->dm_root->child_head, sibling_node) - ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); /* Our test driver should have been bound 3 times */ ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == 3); @@ -140,7 +140,7 @@ static int dm_test_autobind(struct unit_test_state *uts) } DM_TEST(dm_test_autobind, 0); -/* Test that binding with uclass platdata allocation occurs correctly */ +/* Test that binding with uclass plat allocation occurs correctly */ static int dm_test_autobind_uclass_pdata_alloc(struct unit_test_state *uts) { struct dm_test_perdev_uc_pdata *uc_pdata; @@ -152,16 +152,16 @@ static int dm_test_autobind_uclass_pdata_alloc(struct unit_test_state *uts) /** * Test if test uclass driver requires allocation for the uclass - * platform data and then check the dev->uclass_platdata pointer. + * platform data and then check the dev->uclass_plat pointer. */ - ut_assert(uc->uc_drv->per_device_platdata_auto_alloc_size); + ut_assert(uc->uc_drv->per_device_plat_auto); for (uclass_find_first_device(UCLASS_TEST, &dev); dev; uclass_find_next_device(&dev)) { ut_assertnonnull(dev); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ut_assert(uc_pdata); } @@ -169,7 +169,7 @@ static int dm_test_autobind_uclass_pdata_alloc(struct unit_test_state *uts) } DM_TEST(dm_test_autobind_uclass_pdata_alloc, UT_TESTF_SCAN_PDATA); -/* Test that binding with uclass platdata setting occurs correctly */ +/* Test that binding with uclass plat setting occurs correctly */ static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts) { struct dm_test_perdev_uc_pdata *uc_pdata; @@ -184,7 +184,7 @@ static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts) uclass_find_next_device(&dev)) { ut_assertnonnull(dev); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ut_assert(uc_pdata); ut_assert(uc_pdata->intval1 == TEST_UC_PDATA_INTVAL1); ut_assert(uc_pdata->intval2 == TEST_UC_PDATA_INTVAL2); @@ -212,7 +212,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts) ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]); /* The root device should not be activated until needed */ - ut_assert(dms->root->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED); /* * We should be able to find the three test devices, and they should @@ -222,17 +222,17 @@ static int dm_test_autoprobe(struct unit_test_state *uts) for (i = 0; i < 3; i++) { ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev)); ut_assert(dev); - ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED), + ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED), "Driver %d/%s already activated", i, dev->name); /* This should activate it */ ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev)); ut_assert(dev); - ut_assert(dev->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED); /* Activating a device should activate the root device */ if (!i) - ut_assert(dms->root->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED); } /* @@ -255,7 +255,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts) ut_assert(priv); ut_asserteq(expected_base_add, priv->base_add); - pdata = dev->platdata; + pdata = dev_get_plat(dev); expected_base_add += pdata->ping_add; } @@ -263,8 +263,8 @@ static int dm_test_autoprobe(struct unit_test_state *uts) } DM_TEST(dm_test_autoprobe, UT_TESTF_SCAN_PDATA); -/* Check that we see the correct platdata in each device */ -static int dm_test_platdata(struct unit_test_state *uts) +/* Check that we see the correct plat in each device */ +static int dm_test_plat(struct unit_test_state *uts) { const struct dm_test_pdata *pdata; struct udevice *dev; @@ -273,13 +273,13 @@ static int dm_test_platdata(struct unit_test_state *uts) for (i = 0; i < 3; i++) { ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev)); ut_assert(dev); - pdata = dev->platdata; + pdata = dev_get_plat(dev); ut_assert(pdata->ping_add == test_pdata[i].ping_add); } return 0; } -DM_TEST(dm_test_platdata, UT_TESTF_SCAN_PDATA); +DM_TEST(dm_test_plat, UT_TESTF_SCAN_PDATA); /* Test that we can bind, probe, remove, unbind a driver */ static int dm_test_lifecycle(struct unit_test_state *uts) @@ -297,7 +297,7 @@ static int dm_test_lifecycle(struct unit_test_state *uts) ut_assert(dev); ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == op_count[DM_TEST_OP_BIND] + 1); - ut_assert(!dev->priv); + ut_assert(!dev_get_priv(dev)); /* Probe the device - it should fail allocating private data */ dms->force_fail_alloc = 1; @@ -305,14 +305,14 @@ static int dm_test_lifecycle(struct unit_test_state *uts) ut_assert(ret == -ENOMEM); ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE] == op_count[DM_TEST_OP_PROBE] + 1); - ut_assert(!dev->priv); + ut_assert(!dev_get_priv(dev)); /* Try again without the alloc failure */ dms->force_fail_alloc = 0; ut_assertok(device_probe(dev)); ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE] == op_count[DM_TEST_OP_PROBE] + 2); - ut_assert(dev->priv); + ut_assert(dev_get_priv(dev)); /* This should be device 3 in the uclass */ ut_assertok(uclass_find_device(UCLASS_TEST, 3, &test_dev)); @@ -400,10 +400,10 @@ int dm_check_operations(struct unit_test_state *uts, struct udevice *dev, int expected; int pingret; - /* Getting the child device should allocate platdata / priv */ + /* Getting the child device should allocate plat / priv */ ut_assertok(testfdt_ping(dev, 10, &pingret)); - ut_assert(dev->priv); - ut_assert(dev->platdata); + ut_assert(dev_get_priv(dev)); + ut_assert(dev_get_plat(dev)); expected = 10 + base; ut_asserteq(expected, pingret); @@ -414,7 +414,7 @@ int dm_check_operations(struct unit_test_state *uts, struct udevice *dev, ut_asserteq(expected, pingret); /* Now check the ping_total */ - priv = dev->priv; + priv = dev_get_priv(dev); ut_asserteq(DM_TEST_START_TOTAL + 10 + 20 + base * 2, priv->ping_total); @@ -438,13 +438,13 @@ static int dm_test_operations(struct unit_test_state *uts) /* * Get the 'reg' property, which tells us what the ping add - * should be. We don't use the platdata because we want + * should be. We don't use the plat because we want * to test the code that sets that up (testfdt_drv_probe()). */ base = test_pdata[i].ping_add; debug("dev=%d, base=%d\n", i, base); - ut_assert(!dm_check_operations(uts, dev, base, dev->priv)); + ut_assert(!dm_check_operations(uts, dev, base, dev_get_priv(dev))); } return 0; @@ -460,13 +460,13 @@ static int dm_test_remove(struct unit_test_state *uts) for (i = 0; i < 3; i++) { ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev)); ut_assert(dev); - ut_assertf(dev->flags & DM_FLAG_ACTIVATED, + ut_assertf(dev_get_flags(dev) & DM_FLAG_ACTIVATED, "Driver %d/%s not activated", i, dev->name); ut_assertok(device_remove(dev, DM_REMOVE_NORMAL)); - ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED), + ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED), "Driver %d/%s should have deactivated", i, dev->name); - ut_assert(!dev->priv); + ut_assert(!dev_get_priv(dev)); } return 0; @@ -485,8 +485,8 @@ static int dm_test_leak(struct unit_test_state *uts) dm_leak_check_start(uts); - ut_assertok(dm_scan_platdata(false)); - ut_assertok(dm_scan_fdt(gd->fdt_blob, false)); + ut_assertok(dm_scan_plat(false)); + ut_assertok(dm_scan_fdt(false)); /* Scanning the uclass is enough to probe all the devices */ for (id = UCLASS_ROOT; id < UCLASS_COUNT; id++) { @@ -512,7 +512,7 @@ static int dm_test_uclass(struct unit_test_state *uts) ut_assertok(uclass_get(UCLASS_TEST, &uc)); ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]); ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_DESTROY]); - ut_assert(uc->priv); + ut_assert(uclass_get_priv(uc)); ut_assertok(uclass_destroy(uc)); ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]); @@ -547,7 +547,7 @@ static int create_children(struct unit_test_state *uts, struct udevice *parent, &driver_info_manual, &dev)); pdata = calloc(1, sizeof(*pdata)); pdata->ping_add = key + i; - dev->platdata = pdata; + dev_set_plat(dev, pdata); if (child) child[i] = dev; } @@ -1052,8 +1052,8 @@ static int dm_test_inactive_child(struct unit_test_state *uts) */ ut_asserteq(-ENODEV, device_find_first_inactive_child(parent, UCLASS_TEST, &dev1)); - ut_assertok(device_bind_ofnode(parent, DM_GET_DRIVER(test_drv), - "test_child", 0, ofnode_null(), &dev1)); + ut_assertok(device_bind(parent, DM_DRIVER_GET(test_drv), + "test_child", 0, ofnode_null(), &dev1)); ut_assertok(device_find_first_inactive_child(parent, UCLASS_TEST, &dev2)); @@ -1066,3 +1066,22 @@ static int dm_test_inactive_child(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_inactive_child, UT_TESTF_SCAN_PDATA); + +/* Make sure all bound devices have a sequence number */ +static int dm_test_all_have_seq(struct unit_test_state *uts) +{ + struct udevice *dev; + struct uclass *uc; + + list_for_each_entry(uc, gd->uclass_root, sibling_node) { + list_for_each_entry(dev, &uc->dev_head, uclass_node) { + if (dev->seq_ == -1) + printf("Device '%s' has no seq (%d)\n", + dev->name, dev->seq_); + ut_assert(dev->seq_ != -1); + } + } + + return 0; +} +DM_TEST(dm_test_all_have_seq, UT_TESTF_SCAN_PDATA); diff --git a/test/dm/cpu.c b/test/dm/cpu.c index 28869c1d6f..ed12cafee2 100644 --- a/test/dm/cpu.c +++ b/test/dm/cpu.c @@ -25,7 +25,7 @@ static int dm_test_cpu(struct unit_test_state *uts) for (uclass_find_first_device(UCLASS_CPU, &dev); dev; uclass_find_next_device(&dev)) - ut_assert(dev->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED); ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev)); ut_asserteq_ptr(cpu_get_current_dev(), dev); diff --git a/test/dm/devres.c b/test/dm/devres.c index e1e088a3ca..4f959d11da 100644 --- a/test/dm/devres.c +++ b/test/dm/devres.c @@ -158,8 +158,8 @@ static int dm_test_devres_phase(struct unit_test_state *uts) ut_asserteq(1, stats.allocs); ut_asserteq(TEST_DEVRES_SIZE, stats.total_size); - /* Getting platdata should add one allocation */ - ut_assertok(device_ofdata_to_platdata(dev)); + /* Getting plat should add one allocation */ + ut_assertok(device_of_to_plat(dev)); devres_get_stats(dev, &stats); ut_asserteq(2, stats.allocs); ut_asserteq(TEST_DEVRES_SIZE + TEST_DEVRES_SIZE3, stats.total_size); diff --git a/test/dm/gpio.c b/test/dm/gpio.c index 54e960b185..d7b85e74ce 100644 --- a/test/dm/gpio.c +++ b/test/dm/gpio.c @@ -30,7 +30,7 @@ static int dm_test_gpio(struct unit_test_state *uts) /* * We expect to get 4 banks. One is anonymous (just numbered) and - * comes from platdata. The other are named a (20 gpios), + * comes from plat. The other are named a (20 gpios), * b (10 gpios) and c (10 gpios) and come from the device tree. See * test/dm/test.dts. */ diff --git a/test/dm/i2c.c b/test/dm/i2c.c index 681ce45107..d74f5f9fbc 100644 --- a/test/dm/i2c.c +++ b/test/dm/i2c.c @@ -28,9 +28,6 @@ static int dm_test_i2c_find(struct unit_test_state *uts) struct udevice *bus, *dev; const int no_chip = 0x10; - ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_I2C, busnum, - false, &bus)); - /* * The post_bind() method will bind devices to chip selects. Check * this then remove the emulation and the slave device. diff --git a/test/dm/mux-emul.c b/test/dm/mux-emul.c index 141fd4d908..45154cea50 100644 --- a/test/dm/mux-emul.c +++ b/test/dm/mux-emul.c @@ -60,7 +60,7 @@ U_BOOT_DRIVER(emul_mux) = { .of_match = mux_emul_of_match, .ops = &mux_emul_ops, .probe = mux_emul_probe, - .priv_auto_alloc_size = sizeof(struct mux_emul_priv), + .priv_auto = sizeof(struct mux_emul_priv), }; static int dm_test_mux_emul_default_state(struct unit_test_state *uts) diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index 4f3cc159d0..cfc43a5b03 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -8,7 +8,7 @@ #include <test/ut.h> /* Test that we can find a device using of-platdata */ -static int dm_test_of_platdata_base(struct unit_test_state *uts) +static int dm_test_of_plat_base(struct unit_test_state *uts) { struct udevice *dev; @@ -17,10 +17,10 @@ static int dm_test_of_platdata_base(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_of_platdata_base, UT_TESTF_SCAN_PDATA); +DM_TEST(dm_test_of_plat_base, UT_TESTF_SCAN_PDATA); /* Test that we can read properties from a device */ -static int dm_test_of_platdata_props(struct unit_test_state *uts) +static int dm_test_of_plat_props(struct unit_test_state *uts) { struct dtd_sandbox_spl_test *plat; struct udevice *dev; @@ -31,7 +31,7 @@ static int dm_test_of_platdata_props(struct unit_test_state *uts) ut_asserteq_str("sandbox_clk_test", dev->name); ut_assertok(uclass_next_device_err(&dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); ut_assert(plat->boolval); ut_asserteq(1, plat->intval); ut_asserteq(4, ARRAY_SIZE(plat->intarray)); @@ -54,7 +54,7 @@ static int dm_test_of_platdata_props(struct unit_test_state *uts) ut_asserteq_str("", plat->stringarray[2]); ut_assertok(uclass_next_device_err(&dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); ut_assert(!plat->boolval); ut_asserteq(3, plat->intval); ut_asserteq(5, plat->intarray[0]); @@ -74,14 +74,14 @@ static int dm_test_of_platdata_props(struct unit_test_state *uts) ut_asserteq_str("message", plat->stringarray[2]); ut_assertok(uclass_next_device_err(&dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); ut_assert(!plat->boolval); ut_asserteq_str("one", plat->stringarray[0]); ut_asserteq_str("", plat->stringarray[1]); ut_asserteq_str("", plat->stringarray[2]); ut_assertok(uclass_next_device_err(&dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); ut_assert(!plat->boolval); ut_asserteq_str("spl", plat->stringarray[0]); @@ -89,7 +89,7 @@ static int dm_test_of_platdata_props(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_of_platdata_props, UT_TESTF_SCAN_PDATA); +DM_TEST(dm_test_of_plat_props, UT_TESTF_SCAN_PDATA); /* * find_driver_info - recursively find the driver_info for a device @@ -139,7 +139,7 @@ static int find_driver_info(struct unit_test_state *uts, struct udevice *parent, } /* Check that every device is recorded in its driver_info struct */ -static int dm_test_of_platdata_dev(struct unit_test_state *uts) +static int dm_test_of_plat_dev(struct unit_test_state *uts) { const struct driver_info *info = ll_entry_start(struct driver_info, driver_info); @@ -171,17 +171,17 @@ static int dm_test_of_platdata_dev(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_of_platdata_dev, UT_TESTF_SCAN_PDATA); +DM_TEST(dm_test_of_plat_dev, UT_TESTF_SCAN_PDATA); /* Test handling of phandles that point to other devices */ -static int dm_test_of_platdata_phandle(struct unit_test_state *uts) +static int dm_test_of_plat_phandle(struct unit_test_state *uts) { struct dtd_sandbox_clk_test *plat; struct udevice *dev, *clk; ut_assertok(uclass_first_device_err(UCLASS_MISC, &dev)); ut_asserteq_str("sandbox_clk_test", dev->name); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); ut_assertok(device_get_by_driver_info_idx(plat->clocks[0].idx, &clk)); ut_asserteq_str("fixed_clock", clk->name); @@ -204,11 +204,11 @@ static int dm_test_of_platdata_phandle(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_of_platdata_phandle, UT_TESTF_SCAN_PDATA); +DM_TEST(dm_test_of_plat_phandle, UT_TESTF_SCAN_PDATA); #if CONFIG_IS_ENABLED(OF_PLATDATA_PARENT) /* Test that device parents are correctly set up */ -static int dm_test_of_platdata_parent(struct unit_test_state *uts) +static int dm_test_of_plat_parent(struct unit_test_state *uts) { struct udevice *rtc, *i2c; @@ -218,5 +218,5 @@ static int dm_test_of_platdata_parent(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_of_platdata_parent, UT_TESTF_SCAN_PDATA); +DM_TEST(dm_test_of_plat_parent, UT_TESTF_SCAN_PDATA); #endif diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index fb1ceb1318..c539134296 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -249,3 +249,15 @@ static int dm_test_ofnode_get_child_count(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_get_child_count, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +static int dm_test_ofnode_is_enabled(struct unit_test_state *uts) +{ + ofnode root_node = ofnode_path("/"); + ofnode node = ofnode_path("/usb@0"); + + ut_assert(ofnode_is_enabled(root_node)); + ut_assert(!ofnode_is_enabled(node)); + + return 0; +} +DM_TEST(dm_test_ofnode_is_enabled, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); diff --git a/test/dm/ofread.c b/test/dm/ofread.c index 9064426e21..8c7dd82513 100644 --- a/test/dm/ofread.c +++ b/test/dm/ofread.c @@ -33,7 +33,7 @@ static int dm_test_ofnode_get_property_by_prop(struct unit_test_state *uts) ut_asserteq(4, len); break; case 3: - /* only for platdata */ + /* only for plat */ ut_asserteq_str("name", propname); ut_asserteq(6, len); ut_asserteq_str("flash", value); diff --git a/test/dm/pci.c b/test/dm/pci.c index 76490befdf..fa2e4a8559 100644 --- a/test/dm/pci.c +++ b/test/dm/pci.c @@ -120,13 +120,13 @@ static int dm_test_pci_drvdata(struct unit_test_state *uts) ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap)); ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data); - ut_assertok(dev_of_valid(swap)); + ut_assertok(dev_has_ofnode(swap)); ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x0c, 0), &swap)); ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data); - ut_assertok(dev_of_valid(swap)); + ut_assertok(dev_has_ofnode(swap)); ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x10, 0), &swap)); ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data); - ut_assertok(!dev_of_valid(swap)); + ut_assertok(!dev_has_ofnode(swap)); return 0; } diff --git a/test/dm/regmap.c b/test/dm/regmap.c index 2effef3c1c..22a293096c 100644 --- a/test/dm/regmap.c +++ b/test/dm/regmap.c @@ -280,7 +280,7 @@ U_BOOT_DRIVER(regmap_test) = { .of_match = regmaptest_ids, .id = UCLASS_NOP, .probe = remaptest_probe, - .priv_auto_alloc_size = sizeof(struct regmaptest_priv), + .priv_auto = sizeof(struct regmaptest_priv), }; static int dm_test_devm_regmap(struct unit_test_state *uts) diff --git a/test/dm/regulator.c b/test/dm/regulator.c index 0e7a232a70..86f4862d9d 100644 --- a/test/dm/regulator.c +++ b/test/dm/regulator.c @@ -50,7 +50,7 @@ static const char *regulator_names[OUTPUT_COUNT][OUTPUT_NAME_COUNT] = { /* Test regulator get method */ static int dm_test_power_regulator_get(struct unit_test_state *uts) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev_by_devname; struct udevice *dev_by_platname; const char *devname; @@ -77,7 +77,7 @@ static int dm_test_power_regulator_get(struct unit_test_state *uts) * a device with the name equal to the requested one. */ ut_assertok(regulator_get_by_platname(platname, &dev_by_platname)); - uc_pdata = dev_get_uclass_platdata(dev_by_platname); + uc_pdata = dev_get_uclass_plat(dev_by_platname); ut_assert(uc_pdata); ut_asserteq_str(platname, uc_pdata->name); @@ -95,7 +95,7 @@ DM_TEST(dm_test_power_regulator_get, UT_TESTF_SCAN_FDT); /* Test regulator set and get Voltage method */ static int dm_test_power_regulator_set_get_voltage(struct unit_test_state *uts) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; const char *platname; int val_set, val_get; @@ -104,7 +104,7 @@ static int dm_test_power_regulator_set_get_voltage(struct unit_test_state *uts) platname = regulator_names[BUCK1][PLATNAME]; ut_assertok(regulator_get_by_platname(platname, &dev)); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ut_assert(uc_pdata); val_set = uc_pdata->min_uV; @@ -122,7 +122,7 @@ DM_TEST(dm_test_power_regulator_set_get_voltage, UT_TESTF_SCAN_FDT); /* Test regulator set and get Current method */ static int dm_test_power_regulator_set_get_current(struct unit_test_state *uts) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; const char *platname; int val_set, val_get; @@ -131,7 +131,7 @@ static int dm_test_power_regulator_set_get_current(struct unit_test_state *uts) platname = regulator_names[LDO1][PLATNAME]; ut_assertok(regulator_get_by_platname(platname, &dev)); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ut_assert(uc_pdata); val_set = uc_pdata->min_uA; @@ -146,7 +146,7 @@ static int dm_test_power_regulator_set_get_current(struct unit_test_state *uts) platname = regulator_names[LDO2][PLATNAME]; ut_assertok(regulator_get_by_platname(platname, &dev)); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ut_assert(uc_pdata); ut_asserteq(-ENODATA, uc_pdata->min_uA); ut_asserteq(-ENODATA, uc_pdata->max_uA); @@ -220,7 +220,7 @@ DM_TEST(dm_test_power_regulator_set_get_mode, UT_TESTF_SCAN_FDT); /* Test regulator set and get suspend Voltage method */ static int dm_test_power_regulator_set_get_suspend_voltage(struct unit_test_state *uts) { - struct dm_regulator_uclass_platdata *uc_pdata; + struct dm_regulator_uclass_plat *uc_pdata; const struct dm_regulator_ops *ops; struct udevice *dev; const char *platname; @@ -230,7 +230,7 @@ static int dm_test_power_regulator_set_get_suspend_voltage(struct unit_test_stat platname = regulator_names[BUCK1][PLATNAME]; ut_assertok(regulator_get_by_platname(platname, &dev)); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ut_assert(uc_pdata); ops = dev_get_driver_ops(dev); diff --git a/test/dm/spi.c b/test/dm/spi.c index fb180aed1f..ee4ad3abaa 100644 --- a/test/dm/spi.c +++ b/test/dm/spi.c @@ -9,6 +9,7 @@ #include <spi.h> #include <spi_flash.h> #include <asm/state.h> +#include <asm/test.h> #include <dm/device-internal.h> #include <dm/test.h> #include <dm/uclass-internal.h> @@ -22,13 +23,10 @@ static int dm_test_spi_find(struct unit_test_state *uts) struct sandbox_state *state = state_get_current(); struct spi_slave *slave; struct udevice *bus, *dev; - const int busnum = 0, cs = 0, mode = 0, speed = 1000000, cs_b = 1; + const int busnum = 0, cs = 0, mode = 0, speed = 1000000, cs_b = 2; struct spi_cs_info info; ofnode node; - ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_SPI, busnum, - false, &bus)); - /* * The post_bind() method will bind devices to chip selects. Check * this then remove the emulation and the slave device. @@ -94,6 +92,87 @@ static int dm_test_spi_find(struct unit_test_state *uts) } DM_TEST(dm_test_spi_find, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +/* dm_test_spi_switch_slaves - Helper function to check whether spi_claim_bus + * operates correctly with two spi slaves. + * + * Check that switching back and forth between two slaves claiming the bus + * will update dm_spi_bus->speed and sandbox_spi bus speed/mode correctly. + * + * @uts - unit test state + * @slave_a - first spi slave used for testing + * @slave_b - second spi slave used for testing + */ +static int dm_test_spi_switch_slaves(struct unit_test_state *uts, + struct spi_slave *slave_a, + struct spi_slave *slave_b) +{ + struct udevice *bus; + struct dm_spi_bus *bus_data; + + /* Check that slaves are on the same bus */ + ut_asserteq_ptr(dev_get_parent(slave_a->dev), + dev_get_parent(slave_b->dev)); + + bus = dev_get_parent(slave_a->dev); + bus_data = dev_get_uclass_priv(bus); + + ut_assertok(spi_claim_bus(slave_a)); + ut_asserteq(slave_a->max_hz, bus_data->speed); + ut_asserteq(slave_a->max_hz, sandbox_spi_get_speed(bus)); + ut_asserteq(slave_a->mode, sandbox_spi_get_mode(bus)); + spi_release_bus(slave_a); + + ut_assertok(spi_claim_bus(slave_b)); + ut_asserteq(slave_b->max_hz, bus_data->speed); + ut_asserteq(slave_b->max_hz, sandbox_spi_get_speed(bus)); + ut_asserteq(slave_b->mode, sandbox_spi_get_mode(bus)); + spi_release_bus(slave_b); + + ut_assertok(spi_claim_bus(slave_a)); + ut_asserteq(slave_a->max_hz, bus_data->speed); + ut_asserteq(slave_a->max_hz, sandbox_spi_get_speed(bus)); + ut_asserteq(slave_a->mode, sandbox_spi_get_mode(bus)); + spi_release_bus(slave_a); + + return 0; +} + +static int dm_test_spi_claim_bus(struct unit_test_state *uts) +{ + struct udevice *bus; + struct spi_slave *slave_a, *slave_b; + struct dm_spi_slave_plat *slave_plat; + const int busnum = 0, cs_a = 0, cs_b = 1, mode = 0; + + /* Get spi slave on CS0 */ + ut_assertok(spi_get_bus_and_cs(busnum, cs_a, 1000000, mode, NULL, 0, + &bus, &slave_a)); + /* Get spi slave on CS1 */ + ut_assertok(spi_get_bus_and_cs(busnum, cs_b, 1000000, mode, NULL, 0, + &bus, &slave_b)); + + /* Different max_hz, different mode. */ + ut_assert(slave_a->max_hz != slave_b->max_hz); + ut_assert(slave_a->mode != slave_b->mode); + dm_test_spi_switch_slaves(uts, slave_a, slave_b); + + /* Different max_hz, same mode. */ + slave_a->mode = slave_b->mode; + dm_test_spi_switch_slaves(uts, slave_a, slave_b); + + /* + * Same max_hz, different mode. + * Restore original mode for slave_a, from platdata. + */ + slave_plat = dev_get_parent_plat(slave_a->dev); + slave_a->mode = slave_plat->mode; + slave_a->max_hz = slave_b->max_hz; + dm_test_spi_switch_slaves(uts, slave_a, slave_b); + + return 0; +} +DM_TEST(dm_test_spi_claim_bus, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + /* Test that sandbox SPI works correctly */ static int dm_test_spi_xfer(struct unit_test_state *uts) { diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c index 08bdf01194..a67f5d3f98 100644 --- a/test/dm/test-driver.c +++ b/test/dm/test-driver.c @@ -12,6 +12,7 @@ #include <log.h> #include <malloc.h> #include <asm/io.h> +#include <dm/device-internal.h> #include <dm/test.h> #include <test/test.h> #include <test/ut.h> @@ -21,7 +22,7 @@ static struct unit_test_state *uts = &global_dm_test_state; static int testdrv_ping(struct udevice *dev, int pingval, int *pingret) { - const struct dm_test_pdata *pdata = dev_get_platdata(dev); + const struct dm_test_pdata *pdata = dev_get_plat(dev); struct dm_test_priv *priv = dev_get_priv(dev); *pingret = pingval + pdata->ping_add; @@ -67,7 +68,7 @@ static int test_remove(struct udevice *dev) static int test_unbind(struct udevice *dev) { /* Private data should not be allocated */ - ut_assert(!dev->priv); + ut_assert(!dev_get_priv(dev)); dm_testdrv_op_count[DM_TEST_OP_UNBIND]++; return 0; @@ -81,7 +82,7 @@ U_BOOT_DRIVER(test_drv) = { .probe = test_probe, .remove = test_remove, .unbind = test_unbind, - .priv_auto_alloc_size = sizeof(struct dm_test_priv), + .priv_auto = sizeof(struct dm_test_priv), }; U_BOOT_DRIVER(test2_drv) = { @@ -92,7 +93,7 @@ U_BOOT_DRIVER(test2_drv) = { .probe = test_probe, .remove = test_remove, .unbind = test_unbind, - .priv_auto_alloc_size = sizeof(struct dm_test_priv), + .priv_auto = sizeof(struct dm_test_priv), }; static int test_manual_drv_ping(struct udevice *dev, int pingval, int *pingret) @@ -119,8 +120,8 @@ static int test_manual_probe(struct udevice *dev) dm_testdrv_op_count[DM_TEST_OP_PROBE]++; if (!dms->force_fail_alloc) - dev->priv = calloc(1, sizeof(struct dm_test_priv)); - if (!dev->priv) + dev_set_priv(dev, calloc(1, sizeof(struct dm_test_priv))); + if (!dev_get_priv(dev)) return -ENOMEM; return 0; diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index cc12419ea0..b5ac9bba24 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -5,6 +5,7 @@ #include <common.h> #include <dm.h> +#include <dm/device_compat.h> #include <errno.h> #include <fdtdec.h> #include <log.h> @@ -23,116 +24,13 @@ DECLARE_GLOBAL_DATA_PTR; -static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret) -{ - const struct dm_test_pdata *pdata = dev->platdata; - struct dm_test_priv *priv = dev_get_priv(dev); - - *pingret = pingval + pdata->ping_add; - priv->ping_total += *pingret; - - return 0; -} - -static const struct test_ops test_ops = { - .ping = testfdt_drv_ping, -}; - -static int testfdt_ofdata_to_platdata(struct udevice *dev) -{ - struct dm_test_pdata *pdata = dev_get_platdata(dev); - - pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "ping-add", -1); - pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), - "ping-expect"); - - return 0; -} - -static int testfdt_drv_probe(struct udevice *dev) -{ - struct dm_test_priv *priv = dev_get_priv(dev); - - priv->ping_total += DM_TEST_START_TOTAL; - - /* - * If this device is on a bus, the uclass_flag will be set before - * calling this function. In the meantime the uclass_postp is - * initlized to a value -1. These are used respectively by - * dm_test_bus_child_pre_probe_uclass() and - * dm_test_bus_child_post_probe_uclass(). - */ - priv->uclass_total += priv->uclass_flag; - priv->uclass_postp = -1; - - return 0; -} - -static const struct udevice_id testfdt_ids[] = { - { - .compatible = "denx,u-boot-fdt-test", - .data = DM_TEST_TYPE_FIRST }, - { - .compatible = "google,another-fdt-test", - .data = DM_TEST_TYPE_SECOND }, - { } -}; - -U_BOOT_DRIVER(testfdt_drv) = { - .name = "testfdt_drv", - .of_match = testfdt_ids, - .id = UCLASS_TEST_FDT, - .ofdata_to_platdata = testfdt_ofdata_to_platdata, - .probe = testfdt_drv_probe, - .ops = &test_ops, - .priv_auto_alloc_size = sizeof(struct dm_test_priv), - .platdata_auto_alloc_size = sizeof(struct dm_test_pdata), -}; - -static const struct udevice_id testfdt1_ids[] = { - { - .compatible = "denx,u-boot-fdt-test1", - .data = DM_TEST_TYPE_FIRST }, - { } -}; - -U_BOOT_DRIVER(testfdt1_drv) = { - .name = "testfdt1_drv", - .of_match = testfdt1_ids, - .id = UCLASS_TEST_FDT, - .ofdata_to_platdata = testfdt_ofdata_to_platdata, - .probe = testfdt_drv_probe, - .ops = &test_ops, - .priv_auto_alloc_size = sizeof(struct dm_test_priv), - .platdata_auto_alloc_size = sizeof(struct dm_test_pdata), - .flags = DM_FLAG_PRE_RELOC, -}; - -/* From here is the testfdt uclass code */ -int testfdt_ping(struct udevice *dev, int pingval, int *pingret) -{ - const struct test_ops *ops = device_get_ops(dev); - - if (!ops->ping) - return -ENOSYS; - - return ops->ping(dev, pingval, pingret); -} - -UCLASS_DRIVER(testfdt) = { - .name = "testfdt", - .id = UCLASS_TEST_FDT, - .flags = DM_UC_FLAG_SEQ_ALIAS, -}; - struct dm_testprobe_pdata { int probe_err; }; static int testprobe_drv_probe(struct udevice *dev) { - struct dm_testprobe_pdata *pdata = dev_get_platdata(dev); + struct dm_testprobe_pdata *pdata = dev_get_plat(dev); return pdata->probe_err; } @@ -147,7 +45,7 @@ U_BOOT_DRIVER(testprobe_drv) = { .of_match = testprobe_ids, .id = UCLASS_TEST_PROBE, .probe = testprobe_drv_probe, - .platdata_auto_alloc_size = sizeof(struct dm_testprobe_pdata), + .plat_auto = sizeof(struct dm_testprobe_pdata), }; UCLASS_DRIVER(testprobe) = { @@ -167,14 +65,14 @@ struct dm_testdevres_priv { static int testdevres_drv_bind(struct udevice *dev) { - struct dm_testdevres_pdata *pdata = dev_get_platdata(dev); + struct dm_testdevres_pdata *pdata = dev_get_plat(dev); pdata->ptr = devm_kmalloc(dev, TEST_DEVRES_SIZE, 0); return 0; } -static int testdevres_drv_ofdata_to_platdata(struct udevice *dev) +static int testdevres_drv_of_to_plat(struct udevice *dev) { struct dm_testdevres_priv *priv = dev_get_priv(dev); @@ -202,10 +100,10 @@ U_BOOT_DRIVER(testdevres_drv) = { .of_match = testdevres_ids, .id = UCLASS_TEST_DEVRES, .bind = testdevres_drv_bind, - .ofdata_to_platdata = testdevres_drv_ofdata_to_platdata, + .of_to_plat = testdevres_drv_of_to_plat, .probe = testdevres_drv_probe, - .platdata_auto_alloc_size = sizeof(struct dm_testdevres_pdata), - .priv_auto_alloc_size = sizeof(struct dm_testdevres_priv), + .plat_auto = sizeof(struct dm_testdevres_pdata), + .priv_auto = sizeof(struct dm_testdevres_priv), }; UCLASS_DRIVER(testdevres) = { @@ -232,7 +130,7 @@ int dm_check_devices(struct unit_test_state *uts, int num_devices) /* * Get the 'ping-expect' property, which tells us what the - * ping add should be. We don't use the platdata because we + * ping add should be. We don't use the plat because we * want to test the code that sets that up * (testfdt_drv_probe()). */ @@ -257,7 +155,7 @@ static int dm_test_fdt(struct unit_test_state *uts) int ret; int i; - ret = dm_extended_scan_fdt(gd->fdt_blob, false); + ret = dm_extended_scan(false); ut_assert(!ret); ret = uclass_get(UCLASS_TEST_FDT, &uc); @@ -271,7 +169,7 @@ static int dm_test_fdt(struct unit_test_state *uts) ret = uclass_find_device(UCLASS_TEST_FDT, i, &dev); ut_assert(!ret); ut_assert(!dev_get_priv(dev)); - ut_assert(dev->platdata); + ut_assert(dev_get_plat(dev)); } ut_assertok(dm_check_devices(uts, num_devices)); @@ -308,7 +206,7 @@ static int dm_test_fdt_pre_reloc(struct unit_test_state *uts) struct uclass *uc; int ret; - ret = dm_scan_fdt(gd->fdt_blob, true); + ret = dm_scan_fdt(true); ut_assert(!ret); ret = uclass_get(UCLASS_TEST_FDT, &uc); @@ -331,22 +229,30 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) struct udevice *dev; /* A few basic santiy tests */ - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 3, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 3, &dev)); ut_asserteq_str("b-test", dev->name); + ut_asserteq(3, dev_seq(dev)); - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 8, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 8, &dev)); ut_asserteq_str("a-test", dev->name); + ut_asserteq(8, dev_seq(dev)); - ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 5, - true, &dev)); + /* + * This device has no alias so gets the next value after all available + * aliases. The last alias is testfdt12 + */ + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 13, &dev)); + ut_asserteq_str("d-test", dev->name); + ut_asserteq(13, dev_seq(dev)); + + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 9, + &dev)); ut_asserteq_ptr(NULL, dev); /* Test aliases */ ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 6, &dev)); ut_asserteq_str("e-test", dev->name); - - ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 7, - true, &dev)); + ut_asserteq(6, dev_seq(dev)); /* * Note that c-test nodes are not probed since it is not a top-level @@ -354,6 +260,7 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) */ ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 3, &dev)); ut_asserteq_str("b-test", dev->name); + ut_asserteq(3, dev_seq(dev)); /* * d-test wants sequence number 3 also, but it can't have it because @@ -361,36 +268,98 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) */ ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev)); ut_asserteq_str("d-test", dev->name); + ut_asserteq(13, dev_seq(dev)); + + /* g-test gets the next value after f-test */ + ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 15, &dev)); + ut_asserteq_str("g-test", dev->name); + ut_asserteq(15, dev_seq(dev)); + + /* And we should still have holes in our sequence numbers */ + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 0, + &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 1, + &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2, + &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4, + &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 7, + &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 9, + &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 10, + &dev)); + ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 11, + &dev)); + + return 0; +} +DM_TEST(dm_test_fdt_uclass_seq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +/* More tests for sequence numbers */ +static int dm_test_fdt_uclass_seq_manual(struct unit_test_state *uts) +{ + struct udevice *dev; /* - * d-test actually gets 9, because thats the next free one after the - * aliases. + * Since DM_UC_FLAG_NO_AUTO_SEQ is set for this uclass, only testfdtm1 + * should get a sequence number assigned */ - ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 9, &dev)); - ut_asserteq_str("d-test", dev->name); + ut_assertok(uclass_get_device(UCLASS_TEST_FDT_MANUAL, 0, &dev)); + ut_asserteq_str("testfdtm0", dev->name); + ut_asserteq(-1, dev_seq(dev)); - /* initially no one wants seq 10 */ - ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, - &dev)); - ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev)); - ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev)); + ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT_MANUAL, 1, &dev)); + ut_asserteq_str("testfdtm1", dev->name); + ut_asserteq(1, dev_seq(dev)); + + ut_assertok(uclass_get_device(UCLASS_TEST_FDT_MANUAL, 2, &dev)); + ut_asserteq_str("testfdtm2", dev->name); + ut_asserteq(-1, dev_seq(dev)); + + return 0; +} +DM_TEST(dm_test_fdt_uclass_seq_manual, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts) +{ + struct udevice *dev; + ofnode node; - /* But now that it is probed, we can find it */ - ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 10, &dev)); - ut_asserteq_str("f-test", dev->name); + /* Check creating a device with an alias */ + node = ofnode_path("/some-bus/c-test@1"); + ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(testfdt_drv), + "c-test@1", NULL, node, &dev)); + ut_asserteq(12, dev_seq(dev)); + ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 12, &dev)); + ut_asserteq_str("c-test@1", dev->name); /* - * And we should still have holes in our sequence numbers, that is 2 - * and 4 should not be used. + * Now bind a device without an alias. It should not get the next + * sequence number after all aliases, and existing bound devices. The + * last alias is 12, so we have: + * + * 13 d-test + * 14 f-test + * 15 g-test + * 16 h-test + * 17 another-test + * 18 chosen-test + * + * So next available is 19 */ - ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 2, - true, &dev)); - ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 4, - true, &dev)); + ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(testfdt_drv), + "fred", NULL, ofnode_null(), &dev)); + ut_asserteq(19, dev_seq(dev)); + + ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(testfdt_drv), + "fred2", NULL, ofnode_null(), &dev)); + ut_asserteq(20, dev_seq(dev)); return 0; } -DM_TEST(dm_test_fdt_uclass_seq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +DM_TEST(dm_test_fdt_uclass_seq_more, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); /* Test that we can find a device by device tree offset */ static int dm_test_fdt_offset(struct unit_test_state *uts) @@ -445,7 +414,7 @@ static int dm_test_first_next_device(struct unit_test_state *uts) /* Remove them and try again, with an error on the second one */ ut_assertok(uclass_get_device(UCLASS_TEST_PROBE, 1, &dev)); - pdata = dev_get_platdata(dev); + pdata = dev_get_plat(dev); pdata->probe_err = -ENOMEM; device_remove(parent, DM_REMOVE_NORMAL); ut_assertok(uclass_first_device(UCLASS_TEST_PROBE, &dev)); @@ -454,7 +423,7 @@ static int dm_test_first_next_device(struct unit_test_state *uts) /* Now an error on the first one */ ut_assertok(uclass_get_device(UCLASS_TEST_PROBE, 0, &dev)); - pdata = dev_get_platdata(dev); + pdata = dev_get_plat(dev); pdata->probe_err = -ENOENT; device_remove(parent, DM_REMOVE_NORMAL); ut_asserteq(-ENOENT, uclass_first_device(UCLASS_TEST_PROBE, &dev)); @@ -541,21 +510,21 @@ static int dm_test_first_next_ok_device(struct unit_test_state *uts) ut_assertok(check_devices(uts, devlist, 0)); /* Remove them and try again, with an error on the second one */ - pdata = dev_get_platdata(devlist[1]); + pdata = dev_get_plat(devlist[1]); pdata->probe_err = -ENOENT - 1; device_remove(parent, DM_REMOVE_NORMAL); ut_assertok(check_devices(uts, devlist, 1 << 1)); /* Now an error on the first one */ - pdata = dev_get_platdata(devlist[0]); + pdata = dev_get_plat(devlist[0]); pdata->probe_err = -ENOENT - 0; device_remove(parent, DM_REMOVE_NORMAL); ut_assertok(check_devices(uts, devlist, 3 << 0)); /* Now errors on all */ - pdata = dev_get_platdata(devlist[2]); + pdata = dev_get_plat(devlist[2]); pdata->probe_err = -ENOENT - 2; - pdata = dev_get_platdata(devlist[3]); + pdata = dev_get_plat(devlist[3]); pdata->probe_err = -ENOENT - 3; device_remove(parent, DM_REMOVE_NORMAL); ut_assertok(check_devices(uts, devlist, 0xf << 0)); @@ -581,36 +550,103 @@ U_BOOT_DRIVER(fdt_dummy_drv) = { .id = UCLASS_TEST_DUMMY, }; +static int zero_size_cells_bus_bind(struct udevice *dev) +{ + ofnode child; + int err; + + ofnode_for_each_subnode(child, dev_ofnode(dev)) { + if (ofnode_get_property(child, "compatible", NULL)) + continue; + + err = device_bind_driver_to_node(dev, + "zero_size_cells_bus_child_drv", + "zero_size_cells_bus_child", + child, NULL); + if (err) { + dev_err(dev, "%s: failed to bind %s\n", __func__, + ofnode_get_name(child)); + return err; + } + } + + return 0; +} + +static const struct udevice_id zero_size_cells_bus_ids[] = { + { .compatible = "sandbox,zero-size-cells-bus" }, + { } +}; + +U_BOOT_DRIVER(zero_size_cells_bus) = { + .name = "zero_size_cells_bus_drv", + .id = UCLASS_TEST_DUMMY, + .of_match = zero_size_cells_bus_ids, + .bind = zero_size_cells_bus_bind, +}; + +static int zero_size_cells_bus_child_bind(struct udevice *dev) +{ + ofnode child; + int err; + + ofnode_for_each_subnode(child, dev_ofnode(dev)) { + err = lists_bind_fdt(dev, child, NULL, false); + if (err) { + dev_err(dev, "%s: lists_bind_fdt, err=%d\n", + __func__, err); + return err; + } + } + + return 0; +} + +U_BOOT_DRIVER(zero_size_cells_bus_child_drv) = { + .name = "zero_size_cells_bus_child_drv", + .id = UCLASS_TEST_DUMMY, + .bind = zero_size_cells_bus_child_bind, +}; + static int dm_test_fdt_translation(struct unit_test_state *uts) { struct udevice *dev; fdt32_t dma_addr[2]; /* Some simple translations */ - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); ut_asserteq_str("dev@0,0", dev->name); ut_asserteq(0x8000, dev_read_addr(dev)); - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 1, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 1, &dev)); ut_asserteq_str("dev@1,100", dev->name); ut_asserteq(0x9000, dev_read_addr(dev)); - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 2, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 2, &dev)); ut_asserteq_str("dev@2,200", dev->name); ut_asserteq(0xA000, dev_read_addr(dev)); /* No translation for busses with #size-cells == 0 */ - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 3, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 3, &dev)); ut_asserteq_str("dev@42", dev->name); + /* No translation for busses with #size-cells == 0 */ ut_asserteq(0x42, dev_read_addr(dev)); + /* Translation for busses with #size-cells == 0 */ + gd->dm_flags |= GD_DM_FLG_SIZE_CELLS_0; + ut_asserteq(0x8042, dev_read_addr(dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 4, &dev)); + ut_asserteq_str("dev@19", dev->name); + ut_asserteq(0xc019, dev_read_addr(dev)); + gd->dm_flags &= ~GD_DM_FLG_SIZE_CELLS_0; + /* dma address translation */ - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); dma_addr[0] = cpu_to_be32(0); dma_addr[1] = cpu_to_be32(0); ut_asserteq(0x10000000, dev_translate_dma_address(dev, dma_addr)); - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 1, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 1, &dev)); dma_addr[0] = cpu_to_be32(1); dma_addr[1] = cpu_to_be32(0x100); ut_asserteq(0x20000000, dev_translate_dma_address(dev, dma_addr)); @@ -628,7 +664,7 @@ static int dm_test_fdt_get_addr_ptr_flat(struct unit_test_state *uts) ut_assertok(uclass_first_device_err(UCLASS_GPIO, &gpio)); ut_assertnull(devfdt_get_addr_ptr(gpio)); - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); ptr = devfdt_get_addr_ptr(dev); ut_asserteq_ptr((void *)0x8000, ptr); @@ -643,7 +679,7 @@ static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts) fdt_addr_t addr; void *paddr; - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); addr = devfdt_get_addr(dev); ut_asserteq(0x8000, addr); @@ -664,7 +700,7 @@ static int dm_test_fdt_remap_addr_index_flat(struct unit_test_state *uts) fdt_size_t size; void *paddr; - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); addr = devfdt_get_addr_size_index(dev, 0, &size); ut_asserteq(0x8000, addr); @@ -686,7 +722,7 @@ static int dm_test_fdt_remap_addr_name_flat(struct unit_test_state *uts) fdt_size_t size; void *paddr; - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); addr = devfdt_get_addr_size_name(dev, "sandbox-dummy-0", &size); ut_asserteq(0x8000, addr); @@ -707,7 +743,7 @@ static int dm_test_fdt_remap_addr_live(struct unit_test_state *uts) fdt_addr_t addr; void *paddr; - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); addr = dev_read_addr(dev); ut_asserteq(0x8000, addr); @@ -728,7 +764,7 @@ static int dm_test_fdt_remap_addr_index_live(struct unit_test_state *uts) fdt_size_t size; void *paddr; - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); addr = dev_read_addr_size_index(dev, 0, &size); ut_asserteq(0x8000, addr); @@ -750,7 +786,7 @@ static int dm_test_fdt_remap_addr_name_live(struct unit_test_state *uts) fdt_size_t size; void *paddr; - ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, &dev)); addr = dev_read_addr_size_name(dev, "sandbox-dummy-0", &size); ut_asserteq(0x8000, addr); @@ -785,7 +821,7 @@ static int dm_test_fdt_livetree_writing(struct unit_test_state *uts) device_bind_driver_to_node(dm_root(), "usb_sandbox", "usb@2", node, &dev); - ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, true, &dev)); + ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, &dev)); /* Test string property setting */ @@ -1062,9 +1098,9 @@ static int dm_test_child_ofdata(struct unit_test_state *uts) ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus)); count = 0; - device_foreach_child_ofdata_to_platdata(dev, bus) { - ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID); - ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); + device_foreach_child_of_to_plat(dev, bus) { + ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); count++; } ut_asserteq(3, count); @@ -1082,8 +1118,8 @@ static int dm_test_first_child_probe(struct unit_test_state *uts) ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus)); count = 0; device_foreach_child_probe(dev, bus) { - ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID); - ut_assert(dev->flags & DM_FLAG_ACTIVATED); + ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID); + ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED); count++; } ut_asserteq(3, count); @@ -1099,20 +1135,100 @@ static int dm_test_ofdata_order(struct unit_test_state *uts) ut_assertok(uclass_find_first_device(UCLASS_I2C, &bus)); ut_assertnonnull(bus); - ut_assert(!(bus->flags & DM_FLAG_PLATDATA_VALID)); + ut_assert(!(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID)); ut_assertok(device_find_first_child(bus, &dev)); ut_assertnonnull(dev); - ut_assert(!(dev->flags & DM_FLAG_PLATDATA_VALID)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)); /* read the child's ofdata which should cause the parent's to be read */ - ut_assertok(device_ofdata_to_platdata(dev)); - ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID); - ut_assert(bus->flags & DM_FLAG_PLATDATA_VALID); + ut_assertok(device_of_to_plat(dev)); + ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID); + ut_assert(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID); - ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); - ut_assert(!(bus->flags & DM_FLAG_ACTIVATED)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); + ut_assert(!(dev_get_flags(bus) & DM_FLAG_ACTIVATED)); return 0; } DM_TEST(dm_test_ofdata_order, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +/* Test dev_decode_display_timing() */ +static int dm_test_decode_display_timing(struct unit_test_state *uts) +{ + struct udevice *dev; + struct display_timing timing; + + ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev)); + ut_asserteq_str("a-test", dev->name); + + ut_assertok(dev_decode_display_timing(dev, 0, &timing)); + ut_assert(timing.hactive.typ == 240); + ut_assert(timing.hback_porch.typ == 7); + ut_assert(timing.hfront_porch.typ == 6); + ut_assert(timing.hsync_len.typ == 1); + ut_assert(timing.vactive.typ == 320); + ut_assert(timing.vback_porch.typ == 5); + ut_assert(timing.vfront_porch.typ == 8); + ut_assert(timing.vsync_len.typ == 2); + ut_assert(timing.pixelclock.typ == 6500000); + ut_assert(timing.flags & DISPLAY_FLAGS_HSYNC_HIGH); + ut_assert(!(timing.flags & DISPLAY_FLAGS_HSYNC_LOW)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_VSYNC_HIGH)); + ut_assert(timing.flags & DISPLAY_FLAGS_VSYNC_LOW); + ut_assert(timing.flags & DISPLAY_FLAGS_DE_HIGH); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DE_LOW)); + ut_assert(timing.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE); + ut_assert(!(timing.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)); + ut_assert(timing.flags & DISPLAY_FLAGS_INTERLACED); + ut_assert(timing.flags & DISPLAY_FLAGS_DOUBLESCAN); + ut_assert(timing.flags & DISPLAY_FLAGS_DOUBLECLK); + + ut_assertok(dev_decode_display_timing(dev, 1, &timing)); + ut_assert(timing.hactive.typ == 480); + ut_assert(timing.hback_porch.typ == 59); + ut_assert(timing.hfront_porch.typ == 10); + ut_assert(timing.hsync_len.typ == 12); + ut_assert(timing.vactive.typ == 800); + ut_assert(timing.vback_porch.typ == 15); + ut_assert(timing.vfront_porch.typ == 17); + ut_assert(timing.vsync_len.typ == 16); + ut_assert(timing.pixelclock.typ == 9000000); + ut_assert(!(timing.flags & DISPLAY_FLAGS_HSYNC_HIGH)); + ut_assert(timing.flags & DISPLAY_FLAGS_HSYNC_LOW); + ut_assert(timing.flags & DISPLAY_FLAGS_VSYNC_HIGH); + ut_assert(!(timing.flags & DISPLAY_FLAGS_VSYNC_LOW)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DE_HIGH)); + ut_assert(timing.flags & DISPLAY_FLAGS_DE_LOW); + ut_assert(!(timing.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)); + ut_assert(timing.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE); + ut_assert(!(timing.flags & DISPLAY_FLAGS_INTERLACED)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DOUBLESCAN)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DOUBLECLK)); + + ut_assertok(dev_decode_display_timing(dev, 2, &timing)); + ut_assert(timing.hactive.typ == 800); + ut_assert(timing.hback_porch.typ == 89); + ut_assert(timing.hfront_porch.typ == 164); + ut_assert(timing.hsync_len.typ == 11); + ut_assert(timing.vactive.typ == 480); + ut_assert(timing.vback_porch.typ == 23); + ut_assert(timing.vfront_porch.typ == 10); + ut_assert(timing.vsync_len.typ == 13); + ut_assert(timing.pixelclock.typ == 33500000); + ut_assert(!(timing.flags & DISPLAY_FLAGS_HSYNC_HIGH)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_HSYNC_LOW)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_VSYNC_HIGH)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_VSYNC_LOW)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DE_HIGH)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DE_LOW)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_INTERLACED)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DOUBLESCAN)); + ut_assert(!(timing.flags & DISPLAY_FLAGS_DOUBLECLK)); + + ut_assert(dev_decode_display_timing(dev, 3, &timing)); + return 0; +} +DM_TEST(dm_test_decode_display_timing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); diff --git a/test/dm/test-main.c b/test/dm/test-main.c index fd24635006..69458d62c8 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -89,12 +89,12 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, uts->start = mallinfo(); if (test->flags & UT_TESTF_SCAN_PDATA) - ut_assertok(dm_scan_platdata(false)); + ut_assertok(dm_scan_plat(false)); if (test->flags & UT_TESTF_PROBE_TEST) ut_assertok(do_autoprobe(uts)); if (!CONFIG_IS_ENABLED(OF_PLATDATA) && (test->flags & UT_TESTF_SCAN_FDT)) - ut_assertok(dm_extended_scan_fdt(gd->fdt_blob, false)); + ut_assertok(dm_extended_scan(false)); /* * Silence the console and rely on console recording to get @@ -211,9 +211,9 @@ int dm_test_main(const char *test_name) gd_set_of_root(uts->of_root); gd->dm_root = NULL; ut_assertok(dm_init(CONFIG_IS_ENABLED(OF_LIVE))); - dm_scan_platdata(false); + dm_scan_plat(false); if (!CONFIG_IS_ENABLED(OF_PLATDATA)) - dm_scan_fdt(gd->fdt_blob, false); + dm_scan_fdt(false); return uts->fail_count ? CMD_RET_FAILURE : 0; } diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c index 760731b066..f1b7aaa727 100644 --- a/test/dm/test-uclass.c +++ b/test/dm/test-uclass.c @@ -36,7 +36,7 @@ static int test_post_bind(struct udevice *dev) dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++; ut_assert(!device_active(dev)); - uc_pdata = dev_get_uclass_platdata(dev); + uc_pdata = dev_get_uclass_plat(dev); ut_assert(uc_pdata); uc_pdata->intval1 = TEST_UC_PDATA_INTVAL1; @@ -82,7 +82,7 @@ static int test_post_probe(struct udevice *dev) if (&prev->uclass_node != &uc->dev_head) { struct dm_test_uclass_perdev_priv *prev_uc_priv = dev_get_uclass_priv(prev); - struct dm_test_pdata *pdata = prev->platdata; + struct dm_test_pdata *pdata = dev_get_plat(prev); ut_assert(pdata); ut_assert(prev_uc_priv); @@ -102,7 +102,7 @@ static int test_pre_remove(struct udevice *dev) static int test_init(struct uclass *uc) { dm_testdrv_op_count[DM_TEST_OP_INIT]++; - ut_assert(uc->priv); + ut_assert(uclass_get_priv(uc)); return 0; } @@ -124,8 +124,7 @@ UCLASS_DRIVER(test) = { .pre_remove = test_pre_remove, .init = test_init, .destroy = test_destroy, - .priv_auto_alloc_size = sizeof(struct dm_test_uclass_priv), - .per_device_auto_alloc_size = sizeof(struct dm_test_uclass_perdev_priv), - .per_device_platdata_auto_alloc_size = - sizeof(struct dm_test_perdev_uc_pdata), + .priv_auto = sizeof(struct dm_test_uclass_priv), + .per_device_auto = sizeof(struct dm_test_uclass_perdev_priv), + .per_device_plat_auto = sizeof(struct dm_test_perdev_uc_pdata), }; diff --git a/test/dm/video.c b/test/dm/video.c index 1af948dca3..da0ae3622f 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -107,7 +107,7 @@ static int select_vidconsole(struct unit_test_state *uts, const char *drv_name) ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev)); ut_assert(!device_active(dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); plat->vidconsole_drv_name = "vidconsole0"; return 0; @@ -217,7 +217,7 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev)); ut_assert(!device_active(dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); plat->rot = rot; ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev)); @@ -359,7 +359,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts) ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev)); ut_assert(!device_active(dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); plat->font_size = 100; ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev)); @@ -380,7 +380,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev)); ut_assert(!device_active(dev)); - plat = dev_get_platdata(dev); + plat = dev_get_plat(dev); plat->font_size = 100; ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev)); diff --git a/test/dm/virtio.c b/test/dm/virtio.c index 2e876c36e4..ad355981cf 100644 --- a/test/dm/virtio.c +++ b/test/dm/virtio.c @@ -122,7 +122,7 @@ static int dm_test_virtio_remove(struct unit_test_state *uts) ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK)); /* check the device can be successfully removed */ - dev->flags |= DM_FLAG_ACTIVATED; + dev_or_flags(dev, DM_FLAG_ACTIVATED); ut_assertok(device_remove(bus, DM_REMOVE_ACTIVE_ALL)); return 0; diff --git a/test/env/hashtable.c b/test/env/hashtable.c index 339cc19ba1..70102f9121 100644 --- a/test/env/hashtable.c +++ b/test/env/hashtable.c @@ -80,7 +80,7 @@ static int htab_create_delete(struct unit_test_state *uts, ut_asserteq_str(key, ritem->key); ut_asserteq_str(key, ritem->data); - ut_asserteq(1, hdelete_r(key, htab, 0)); + ut_asserteq(0, hdelete_r(key, htab, 0)); } return 0; diff --git a/test/nokia_rx51_test.sh b/test/nokia_rx51_test.sh index 23fa935310..ee45e8d6dd 100755 --- a/test/nokia_rx51_test.sh +++ b/test/nokia_rx51_test.sh @@ -150,6 +150,15 @@ fakeroot sh -c ' ' /usr/sbin/ubinize -o ubi.img -p 128KiB -m 2048 -s 512 ubi.ini +# Generate bootmenu for U-Boot serial console testing +cat > bootmenu_uboot << EOF +setenv bootmenu_0 'Serial console test=echo; echo "Testing serial console"; echo; echo "Successfully booted"; echo; poweroff'; +setenv bootmenu_1; +setenv bootmenu_delay 1; +setenv bootdelay 1; +EOF +./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu_uboot -d bootmenu_uboot bootmenu_uboot.scr + # Generate bootmenu for eMMC booting cat > bootmenu_emmc << EOF setenv bootmenu_0 'uImage-2.6.28-omap1 from eMMC=setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat; setenv bootargs; setenv setup_omap_atag 1; setenv mmckernfile uImage-2.6.28-omap1; run trymmckernboot'; @@ -177,6 +186,11 @@ dd if=kernel_2.6.28/boot/zImage-2.6.28-20103103+0m5.fiasco of=zImage-2.6.28-omap cp u-boot.bin combined_hack.bin dd if=uImage-2.6.28-omap1 of=combined_hack.bin bs=1024 seek=$((2048-2)) +# Generate FAT32 eMMC image for U-Boot serial console testing +truncate -s 50MiB emmc_uboot.img +mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_uboot.img +mcopy bootmenu_uboot.scr ::/bootmenu.scr -i emmc_uboot.img + # Generate FAT32 eMMC image for eMMC booting truncate -s 50MiB emmc_emmc.img mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_emmc.img @@ -188,6 +202,10 @@ truncate -s 50MiB emmc_nand.img mformat -m 0xf8 -F -h 4 -s 16 -c 1 -t $((50*1024*1024/(4*16*512))) :: -i emmc_nand.img mcopy bootmenu_nand.scr ::/bootmenu.scr -i emmc_nand.img +# Generate MTD image for U-Boot serial console testing +rm -f mtd_uboot.img +./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd_uboot.img + # Generate MTD image for RAM booting from bootloader nolo images, compiled image and rootfs image rm -f mtd_ram.img ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined.bin -r ubi.img -m rx51 -o mtd_ram.img @@ -208,6 +226,18 @@ echo "========== Running test images in n900 qemu ==========" echo "======================================================" echo +# Run MTD image in qemu and wait for 300s if U-Boot prints testing string to serial console and poweroff +rm -f qemu_uboot.log +./qemu-system-arm -M n900 -mtdblock mtd_uboot.img -sd emmc_uboot.img -serial /dev/stdout -display none > qemu_uboot.log & +qemu_pid=$! +tail -F qemu_uboot.log & +tail_pid=$! +sleep 300 & +sleep_pid=$! +wait -n $sleep_pid $qemu_pid || true +kill -9 $tail_pid $sleep_pid $qemu_pid 2>/dev/null || true +wait || true + # Run MTD image in qemu and wait for 300s if kernel from RAM is correctly booted rm -f qemu_ram.log ./qemu-system-arm -M n900 -mtdblock mtd_ram.img -serial /dev/stdout -display none > qemu_ram.log & @@ -250,13 +280,14 @@ echo "========== Results ==========" echo "=============================" echo +if grep -q 'Successfully booted' qemu_uboot.log; then echo "U-Boot serial console is working"; else echo "U-Boot serial console test failed"; fi if grep -q 'Successfully booted' qemu_ram.log; then echo "Kernel was successfully booted from RAM"; else echo "Failed to boot kernel from RAM"; fi if grep -q 'Successfully booted' qemu_emmc.log; then echo "Kernel was successfully booted from eMMC"; else echo "Failed to boot kernel from eMMC"; fi if grep -q 'Successfully booted' qemu_nand.log; then echo "Kernel was successfully booted from OneNAND"; else echo "Failed to boot kernel from OneNAND"; fi echo -if grep -q 'Successfully booted' qemu_ram.log && grep -q 'Successfully booted' qemu_emmc.log && grep -q 'Successfully booted' qemu_nand.log; then +if grep -q 'Successfully booted' qemu_uboot.log && grep -q 'Successfully booted' qemu_ram.log && grep -q 'Successfully booted' qemu_emmc.log && grep -q 'Successfully booted' qemu_nand.log; then echo "All tests passed" exit 0 else diff --git a/test/py/tests/test_efi_capsule/capsule_defs.py b/test/py/tests/test_efi_capsule/capsule_defs.py new file mode 100644 index 0000000000..4fd6353c20 --- /dev/null +++ b/test/py/tests/test_efi_capsule/capsule_defs.py @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ + +# Directories +CAPSULE_DATA_DIR = '/EFI/CapsuleTestData' +CAPSULE_INSTALL_DIR = '/EFI/UpdateCapsule' diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py new file mode 100644 index 0000000000..6ad5608cd7 --- /dev/null +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2020, Linaro Limited +# Author: AKASHI Takahiro <takahiro.akashi@linaro.org> + +import os +import os.path +import re +from subprocess import call, check_call, check_output, CalledProcessError +import pytest +from capsule_defs import * + +# +# Fixture for UEFI secure boot test +# + + +@pytest.fixture(scope='session') +def efi_capsule_data(request, u_boot_config): + """Set up a file system to be used in UEFI capsule test. + + Args: + request: Pytest request object. + u_boot_config: U-boot configuration. + + Return: + A path to disk image to be used for testing + """ + global CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR + + mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule' + data_dir = mnt_point + CAPSULE_DATA_DIR + install_dir = mnt_point + CAPSULE_INSTALL_DIR + image_path = u_boot_config.persistent_data_dir + '/test_efi_capsule.img' + + try: + # Create a target device + check_call('dd if=/dev/zero of=./spi.bin bs=1MiB count=16', shell=True) + + check_call('rm -rf %s' % mnt_point, shell=True) + check_call('mkdir -p %s' % data_dir, shell=True) + check_call('mkdir -p %s' % install_dir, shell=True) + + # Create capsule files + # two regions: one for u-boot.bin and the other for u-boot.env + check_call('cd %s; echo -n u-boot:Old > u-boot.bin.old; echo -n u-boot:New > u-boot.bin.new; echo -n u-boot-env:Old -> u-boot.env.old; echo -n u-boot-env:New > u-boot.env.new' % data_dir, + shell=True) + check_call('sed -e \"s?BINFILE1?u-boot.bin.new?\" -e \"s?BINFILE2?u-boot.env.new?\" %s/test/py/tests/test_efi_capsule/uboot_bin_env.its > %s/uboot_bin_env.its' % + (u_boot_config.source_dir, data_dir), + shell=True) + check_call('cd %s; %s/tools/mkimage -f uboot_bin_env.its uboot_bin_env.itb' % + (data_dir, u_boot_config.build_dir), + shell=True) + check_call('cd %s; %s/tools/mkeficapsule --fit uboot_bin_env.itb --index 1 Test01' % + (data_dir, u_boot_config.build_dir), + shell=True) + check_call('cd %s; %s/tools/mkeficapsule --raw u-boot.bin.new --index 1 Test02' % + (data_dir, u_boot_config.build_dir), + shell=True) + + # Create a disk image with EFI system partition + check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s %s' % + (mnt_point, image_path), shell=True) + check_call('sgdisk %s -A 1:set:0 -t 1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B' % + image_path, shell=True) + + except CalledProcessError as exception: + pytest.skip('Setup failed: %s' % exception.cmd) + return + else: + yield image_path + finally: + call('rm -rf %s' % mnt_point, shell=True) + call('rm -f %s' % image_path, shell=True) + call('rm -f ./spi.bin', shell=True) diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware.py b/test/py/tests/test_efi_capsule/test_capsule_firmware.py new file mode 100644 index 0000000000..f006fa95d6 --- /dev/null +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py @@ -0,0 +1,241 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2020, Linaro Limited +# Author: AKASHI Takahiro <takahiro.akashi@linaro.org> +# +# U-Boot UEFI: Firmware Update Test + +""" +This test verifies capsule-on-disk firmware update +""" + +from subprocess import check_call, check_output, CalledProcessError +import pytest +from capsule_defs import * + + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('efi_capsule_firmware_fit') +@pytest.mark.buildconfigspec('efi_capsule_firmware_raw') +@pytest.mark.buildconfigspec('efi_capsule_on_disk') +@pytest.mark.buildconfigspec('dfu') +@pytest.mark.buildconfigspec('dfu_sf') +@pytest.mark.buildconfigspec('cmd_efidebug') +@pytest.mark.buildconfigspec('cmd_fat') +@pytest.mark.buildconfigspec('cmd_memory') +@pytest.mark.buildconfigspec('cmd_nvedit_efi') +@pytest.mark.buildconfigspec('cmd_sf') +@pytest.mark.slow +class TestEfiCapsuleFirmwareFit(object): + def test_efi_capsule_fw1( + self, u_boot_config, u_boot_console, efi_capsule_data): + """ + Test Case 1 - Update U-Boot and U-Boot environment on SPI Flash + but with OsIndications unset + No update should happen + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) + """ + disk_img = efi_capsule_data + with u_boot_console.log.section('Test Case 1-a, before reboot'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'efidebug boot add 1 TEST host 0:1 /helloworld.efi ""', + 'efidebug boot order 1', + 'env set -e OsIndications', + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'env save']) + + # initialize contents + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.bin.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 100000 10', + 'sf read 5000000 100000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.env.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 150000 10', + 'sf read 5000000 150000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + + # place a capsule file + output = u_boot_console.run_command_list([ + 'fatload host 0:1 4000000 %s/Test01' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test01 $filesize' % CAPSULE_INSTALL_DIR, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' in ''.join(output) + + # reboot + u_boot_console.restart_uboot() + + capsule_early = u_boot_config.buildconfig.get( + 'config_efi_capsule_on_disk_early') + with u_boot_console.log.section('Test Case 1-b, after reboot'): + if not capsule_early: + # make sure that dfu_alt_info exists even persistent variables + # are not available. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' in ''.join(output) + + # need to run uefi command to initiate capsule handling + output = u_boot_console.run_command( + 'env print -e -all Capsule0000') + + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' in ''.join(output) + + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'sf read 4000000 100000 10', + 'md.b 4000000 10']) + assert 'u-boot:Old' in ''.join(output) + + output = u_boot_console.run_command_list([ + 'sf read 4000000 150000 10', + 'md.b 4000000 10']) + assert 'u-boot-env:Old' in ''.join(output) + + def test_efi_capsule_fw2( + self, u_boot_config, u_boot_console, efi_capsule_data): + """ + Test Case 2 - Update U-Boot and U-Boot environment on SPI Flash + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) + """ + disk_img = efi_capsule_data + with u_boot_console.log.section('Test Case 2-a, before reboot'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'efidebug boot add 1 TEST host 0:1 /helloworld.efi ""', + 'efidebug boot order 1', + 'env set -e -nv -bs -rt OsIndications =0x0000000000000004', + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'env save']) + + # initialize contents + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.bin.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 100000 10', + 'sf read 5000000 100000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.env.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 150000 10', + 'sf read 5000000 150000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + + # place a capsule file + output = u_boot_console.run_command_list([ + 'fatload host 0:1 4000000 %s/Test01' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test01 $filesize' % CAPSULE_INSTALL_DIR, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' in ''.join(output) + + # reboot + u_boot_console.restart_uboot() + + capsule_early = u_boot_config.buildconfig.get( + 'config_efi_capsule_on_disk_early') + with u_boot_console.log.section('Test Case 2-b, after reboot'): + if not capsule_early: + # make sure that dfu_alt_info exists even persistent variables + # are not available. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' in ''.join(output) + + # need to run uefi command to initiate capsule handling + output = u_boot_console.run_command( + 'env print -e -all Capsule0000') + + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' not in ''.join(output) + + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'sf read 4000000 100000 10', + 'md.b 4000000 10']) + assert 'u-boot:New' in ''.join(output) + + output = u_boot_console.run_command_list([ + 'sf read 4000000 150000 10', + 'md.b 4000000 10']) + assert 'u-boot-env:New' in ''.join(output) + + def test_efi_capsule_fw3( + self, u_boot_config, u_boot_console, efi_capsule_data): + """ + Test Case 3 - Update U-Boot on SPI Flash, raw image format + 0x100000-0x150000: U-Boot binary (but dummy) + """ + disk_img = efi_capsule_data + with u_boot_console.log.section('Test Case 3-a, before reboot'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'efidebug boot add 1 TEST host 0:1 /helloworld.efi ""', + 'efidebug boot order 1', + 'env set -e -nv -bs -rt OsIndications =0x0000000000000004', + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'env save']) + + # initialize content + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.bin.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 100000 10', + 'sf read 5000000 100000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + + # place a capsule file + output = u_boot_console.run_command_list([ + 'fatload host 0:1 4000000 %s/Test02' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test02 $filesize' % CAPSULE_INSTALL_DIR, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test02' in ''.join(output) + + # reboot + u_boot_console.restart_uboot() + + capsule_early = u_boot_config.buildconfig.get( + 'config_efi_capsule_on_disk_early') + with u_boot_console.log.section('Test Case 3-b, after reboot'): + if not capsule_early: + # make sure that dfu_alt_info exists even persistent variables + # are not available. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test02' in ''.join(output) + + # need to run uefi command to initiate capsule handling + output = u_boot_console.run_command( + 'env print -e -all Capsule0000') + + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test02' not in ''.join(output) + + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'sf read 4000000 100000 10', + 'md.b 4000000 10']) + assert 'u-boot:New' in ''.join(output) diff --git a/test/py/tests/test_efi_capsule/uboot_bin_env.its b/test/py/tests/test_efi_capsule/uboot_bin_env.its new file mode 100644 index 0000000000..31e2f8049f --- /dev/null +++ b/test/py/tests/test_efi_capsule/uboot_bin_env.its @@ -0,0 +1,36 @@ +/* + * Automatic software update for U-Boot + * Make sure the flashing addresses ('load' prop) is correct for your board! + */ + +/dts-v1/; + +/ { + description = "Automatic U-Boot environment update"; + #address-cells = <2>; + + images { + u-boot-bin@100000 { + description = "U-Boot binary on SPI Flash"; + data = /incbin/("BINFILE1"); + compression = "none"; + type = "firmware"; + arch = "sandbox"; + load = <0>; + hash-1 { + algo = "sha1"; + }; + }; + u-boot-env@150000 { + description = "U-Boot environment on SPI Flash"; + data = /incbin/("BINFILE2"); + compression = "none"; + type = "firmware"; + arch = "sandbox"; + load = <0>; + hash-1 { + algo = "sha1"; + }; + }; + }; +}; diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py index 78837a3c00..d55338e37e 100644 --- a/test/py/tests/test_ofplatdata.py +++ b/test/py/tests/test_ofplatdata.py @@ -17,7 +17,6 @@ def test_spl_devicetree(u_boot_console): assert "u-boot,dm-spl" not in output assert "u-boot,dm-tpl" not in output - assert "spl-test4" in output assert "spl-test5" not in output assert "spl-test6" not in output assert "spl-test7" in output diff --git a/test/py/tests/test_sandbox_exit.py b/test/py/tests/test_sandbox_exit.py index 2d242ae0f6..706f5fa359 100644 --- a/test/py/tests/test_sandbox_exit.py +++ b/test/py/tests/test_sandbox_exit.py @@ -19,3 +19,27 @@ def test_ctrl_c(u_boot_console): u_boot_console.kill(signal.SIGINT) assert(u_boot_console.validate_exited()) + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('cmd_exception') +@pytest.mark.buildconfigspec('sandbox_crash_reset') +def test_exception_reset(u_boot_console): + """Test that SIGILL causes a reset.""" + + u_boot_console.run_command('exception undefined', wait_for_prompt=False) + m = u_boot_console.p.expect(['resetting ...', 'U-Boot']) + if m != 0: + raise Exception('SIGILL did not lead to reset') + m = u_boot_console.p.expect(['U-Boot', '=>']) + if m != 0: + raise Exception('SIGILL did not lead to reset') + u_boot_console.restart_uboot() + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('cmd_exception') +@pytest.mark.notbuildconfigspec('sandbox_crash_reset') +def test_exception_exit(u_boot_console): + """Test that SIGILL causes a reset.""" + + u_boot_console.run_command('exception undefined', wait_for_prompt=False) + assert(u_boot_console.validate_exited()) diff --git a/test/unicode_ut.c b/test/unicode_ut.c index 33fc8b0ee1..6130ef0b54 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -603,7 +603,7 @@ static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts) u16 *pos; memset(buf, 0xeb, sizeof(buf)); - pos = efi_create_indexed_name(buf, "Capsule", 0x0af9); + pos = efi_create_indexed_name(buf, sizeof(buf), "Capsule", 0x0af9); ut_asserteq_mem(expected, buf, sizeof(expected)); ut_asserteq(pos - buf, u16_strnlen(buf, SIZE_MAX)); diff --git a/tools/Makefile b/tools/Makefile index 253a6b9706..9b1aa51b10 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -104,6 +104,7 @@ dumpimage-mkimage-objs := aisimage.o \ stm32image.o \ $(ROCKCHIP_OBS) \ socfpgaimage.o \ + sunxi_egon.o \ lib/crc16.o \ lib/sha1.o \ lib/sha256.o \ @@ -221,6 +222,9 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include +mkeficapsule-objs := mkeficapsule.o $(LIBFDT_OBJS) +hostprogs-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += mkeficapsule + # We build some files with extra pedantic flags to try to minimize things # that won't build on some weird host compiler -- though there are lots of # exceptions for files that aren't complaint. diff --git a/tools/binman/elf.py b/tools/binman/elf.py index 5e566e56cb..249074a334 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -158,9 +158,9 @@ def MakeElf(elf_fname, text, data): # Spilt the text into two parts so that we can make the entry point two # bytes after the start of the text section - text_bytes1 = ['\t.byte\t%#x' % tools.ToByte(byte) for byte in text[:2]] - text_bytes2 = ['\t.byte\t%#x' % tools.ToByte(byte) for byte in text[2:]] - data_bytes = ['\t.byte\t%#x' % tools.ToByte(byte) for byte in data] + text_bytes1 = ['\t.byte\t%#x' % byte for byte in text[:2]] + text_bytes2 = ['\t.byte\t%#x' % byte for byte in text[2:]] + data_bytes = ['\t.byte\t%#x' % byte for byte in data] with open(s_file, 'w') as fd: print('''/* Auto-generated C program to produce an ELF file for testing */ diff --git a/tools/binman/etype/fmap.py b/tools/binman/etype/fmap.py index 3e9b815d11..fe81c6f64a 100644 --- a/tools/binman/etype/fmap.py +++ b/tools/binman/etype/fmap.py @@ -52,7 +52,7 @@ class Entry_fmap(Entry): if pos is not None: pos -= entry.section.GetRootSkipAtStart() areas.append(fmap_util.FmapArea(pos or 0, entry.size or 0, - tools.FromUnicode(entry.name), 0)) + entry.name, 0)) entries = self.GetImage().GetEntries() areas = [] diff --git a/tools/binman/fdt_test.py b/tools/binman/fdt_test.py index c491d40e9e..3e12540f62 100644 --- a/tools/binman/fdt_test.py +++ b/tools/binman/fdt_test.py @@ -50,37 +50,37 @@ class TestFdt(unittest.TestCase): self.assertEquals('me.bin', val) prop = node.props['intval'] - self.assertEquals(fdt.TYPE_INT, prop.type) + self.assertEquals(fdt.Type.INT, prop.type) self.assertEquals(3, fdt_util.GetInt(node, 'intval')) prop = node.props['intarray'] - self.assertEquals(fdt.TYPE_INT, prop.type) + self.assertEquals(fdt.Type.INT, prop.type) self.assertEquals(list, type(prop.value)) self.assertEquals(2, len(prop.value)) self.assertEquals([5, 6], [fdt_util.fdt32_to_cpu(val) for val in prop.value]) prop = node.props['byteval'] - self.assertEquals(fdt.TYPE_BYTE, prop.type) + self.assertEquals(fdt.Type.BYTE, prop.type) self.assertEquals(chr(8), prop.value) prop = node.props['bytearray'] - self.assertEquals(fdt.TYPE_BYTE, prop.type) + self.assertEquals(fdt.Type.BYTE, prop.type) self.assertEquals(list, type(prop.value)) self.assertEquals(str, type(prop.value[0])) self.assertEquals(3, len(prop.value)) self.assertEquals([chr(1), '#', '4'], prop.value) prop = node.props['longbytearray'] - self.assertEquals(fdt.TYPE_INT, prop.type) + self.assertEquals(fdt.Type.INT, prop.type) self.assertEquals(0x090a0b0c, fdt_util.GetInt(node, 'longbytearray')) prop = node.props['stringval'] - self.assertEquals(fdt.TYPE_STRING, prop.type) + self.assertEquals(fdt.Type.STRING, prop.type) self.assertEquals('message2', fdt_util.GetString(node, 'stringval')) prop = node.props['stringarray'] - self.assertEquals(fdt.TYPE_STRING, prop.type) + self.assertEquals(fdt.Type.STRING, prop.type) self.assertEquals(list, type(prop.value)) self.assertEquals(3, len(prop.value)) self.assertEquals(['another', 'multi-word', 'message'], prop.value) diff --git a/tools/binman/fmap_util.py b/tools/binman/fmap_util.py index 25fe60a9cc..b03fc28fbb 100644 --- a/tools/binman/fmap_util.py +++ b/tools/binman/fmap_util.py @@ -111,8 +111,7 @@ def EncodeFmap(image_size, name, areas): ConvertName(names, params) return struct.pack(fmt, *params) - values = FmapHeader(FMAP_SIGNATURE, 1, 0, 0, image_size, - tools.FromUnicode(name), len(areas)) + values = FmapHeader(FMAP_SIGNATURE, 1, 0, 0, image_size, name, len(areas)) blob = _FormatBlob(FMAP_HEADER_FORMAT, FMAP_HEADER_NAMES, values) for area in areas: blob += _FormatBlob(FMAP_AREA_FORMAT, FMAP_AREA_NAMES, area) diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 48fcd6cf7e..d664868582 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -13,6 +13,7 @@ from patman import command from patman import gitutil RETURN_CODE_RETRY = -1 +BASE_ELF_FILENAMES = ['u-boot', 'spl/u-boot-spl', 'tpl/u-boot-tpl'] def Mkdir(dirname, parents = False): """Make a directory if it doesn't already exist. @@ -240,6 +241,17 @@ class BuilderThread(threading.Thread): args.extend(self.builder.toolchains.GetMakeArguments(brd)) args.extend(self.toolchain.MakeArgs()) + # Remove any output targets. Since we use a build directory that + # was previously used by another board, it may have produced an + # SPL image. If we don't remove it (i.e. see do_config and + # self.mrproper below) then it will appear to be the output of + # this build, even if it does not produce SPL images. + build_dir = self.builder.GetBuildDir(commit_upto, brd.target) + for elf in BASE_ELF_FILENAMES: + fname = os.path.join(out_dir, elf) + if os.path.exists(fname): + os.remove(fname) + # If we need to reconfigure, do that now if do_config: config_out = '' @@ -335,7 +347,7 @@ class BuilderThread(threading.Thread): for var in sorted(env.keys()): print('%s="%s"' % (var, env[var]), file=fd) lines = [] - for fname in ['u-boot', 'spl/u-boot-spl']: + for fname in BASE_ELF_FILENAMES: cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname] nm_result = command.RunPipe([cmd], capture=True, capture_stderr=True, cwd=result.out_dir, diff --git a/tools/concurrencytest/concurrencytest.py b/tools/concurrencytest/concurrencytest.py index 418d7eed21..5e88b94f41 100644 --- a/tools/concurrencytest/concurrencytest.py +++ b/tools/concurrencytest/concurrencytest.py @@ -68,7 +68,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT): pid = os.fork() if pid == 0: try: - stream = os.fdopen(c2pwrite, 'wb', 1) + stream = os.fdopen(c2pwrite, 'wb') os.close(c2pread) # Leave stderr and stdout open so we can see test noise # Close stdin so that the child goes away if it decides to @@ -92,7 +92,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT): os._exit(0) else: os.close(c2pwrite) - stream = os.fdopen(c2pread, 'rb', 1) + stream = os.fdopen(c2pread, 'rb') test = ProtocolTestCase(stream) result.append(test) return result diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 9b27aecc14..b7abaed67a 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -9,19 +9,24 @@ This supports converting device tree data to C structures definitions and static data. + +See doc/driver-model/of-plat.rst for more informaiton """ import collections import copy +from enum import IntEnum import os import re import sys from dtoc import fdt from dtoc import fdt_util -from patman import tools +from dtoc import src_scan +from dtoc.src_scan import conv_name_to_c -# When we see these properties we ignore them - i.e. do not create a structure member +# When we see these properties we ignore them - i.e. do not create a structure +# member PROP_IGNORE_LIST = [ '#address-cells', '#gpio-cells', @@ -35,18 +40,29 @@ PROP_IGNORE_LIST = [ 'u-boot,dm-spl', ] -# C type declarations for the tyues we support +# C type declarations for the types we support TYPE_NAMES = { - fdt.TYPE_INT: 'fdt32_t', - fdt.TYPE_BYTE: 'unsigned char', - fdt.TYPE_STRING: 'const char *', - fdt.TYPE_BOOL: 'bool', - fdt.TYPE_INT64: 'fdt64_t', + fdt.Type.INT: 'fdt32_t', + fdt.Type.BYTE: 'unsigned char', + fdt.Type.STRING: 'const char *', + fdt.Type.BOOL: 'bool', + fdt.Type.INT64: 'fdt64_t', } STRUCT_PREFIX = 'dtd_' VAL_PREFIX = 'dtv_' +class Ftype(IntEnum): + SOURCE, HEADER = range(2) + + +# This holds information about each type of output file dtoc can create +# type: Type of file (Ftype) +# fname: Filename excluding directory, e.g. 'dt-plat.c' +# hdr_comment: Comment explaining the purpose of the file +OutputFile = collections.namedtuple('OutputFile', + ['ftype', 'fname', 'method', 'hdr_comment']) + # This holds information about a property which includes phandles. # # max_args: integer: Maximum number or arguments that any phandle uses (int). @@ -62,32 +78,15 @@ PhandleInfo = collections.namedtuple('PhandleInfo', ['max_args', 'args']) PhandleLink = collections.namedtuple('PhandleLink', ['var_node', 'dev_name']) -def conv_name_to_c(name): - """Convert a device-tree name to a C identifier - - This uses multiple replace() calls instead of re.sub() since it is faster - (400ms for 1m calls versus 1000ms for the 're' version). - - Args: - name: Name to convert - Return: - String containing the C version of this name - """ - new = name.replace('@', '_at_') - new = new.replace('-', '_') - new = new.replace(',', '_') - new = new.replace('.', '_') - return new - def tab_to(num_tabs, line): """Append tabs to a line of text to reach a tab stop. Args: - num_tabs: Tab stop to obtain (0 = column 0, 1 = column 8, etc.) - line: Line of text to append to + num_tabs (int): Tab stop to obtain (0 = column 0, 1 = column 8, etc.) + line (str): Line of text to append to Returns: - line with the correct number of tabs appeneded. If the line already + str: line with the correct number of tabs appeneded. If the line already extends past that tab stop then a single space is appended. """ if len(line) >= num_tabs * 8: @@ -103,37 +102,29 @@ def get_value(ftype, value): For booleans this return 'true' Args: - type: Data type (fdt_util) - value: Data value, as a string of bytes + ftype (fdt.Type): Data type (fdt_util) + value (bytes): Data value, as a string of bytes + + Returns: + str: String representation of the value """ - if ftype == fdt.TYPE_INT: - return '%#x' % fdt_util.fdt32_to_cpu(value) - elif ftype == fdt.TYPE_BYTE: - return '%#x' % tools.ToByte(value[0]) - elif ftype == fdt.TYPE_STRING: + if ftype == fdt.Type.INT: + val = '%#x' % fdt_util.fdt32_to_cpu(value) + elif ftype == fdt.Type.BYTE: + char = value[0] + val = '%#x' % (ord(char) if isinstance(char, str) else char) + elif ftype == fdt.Type.STRING: # Handle evil ACPI backslashes by adding another backslash before them. # So "\\_SB.GPO0" in the device tree effectively stays like that in C - return '"%s"' % value.replace('\\', '\\\\') - elif ftype == fdt.TYPE_BOOL: - return 'true' - elif ftype == fdt.TYPE_INT64: - return '%#x' % value - -def get_compat_name(node): - """Get the node's list of compatible string as a C identifiers - - Args: - node: Node object to check - Return: - List of C identifiers for all the compatible strings - """ - compat = node.props['compatible'].value - if not isinstance(compat, list): - compat = [compat] - return [conv_name_to_c(c) for c in compat] + val = '"%s"' % value.replace('\\', '\\\\') + elif ftype == fdt.Type.BOOL: + val = 'true' + else: # ftype == fdt.Type.INT64: + val = '%#x' % value + return val -class DtbPlatdata(object): +class DtbPlatdata(): """Provide a means to convert device tree binary data to platform data The output of this process is C structures which can be used in space- @@ -141,89 +132,103 @@ class DtbPlatdata(object): code is not affordable. Properties: + _scan: Scan object, for scanning and reporting on useful information + from the U-Boot source code _fdt: Fdt object, referencing the device tree _dtb_fname: Filename of the input device tree binary file _valid_nodes: A list of Node object with compatible strings. The list is ordered by conv_name_to_c(node.name) _include_disabled: true to include nodes marked status = "disabled" _outfile: The current output file (sys.stdout or a real file) - _warning_disabled: true to disable warnings about driver names not found _lines: Stashed list of output lines for outputting in the future - _drivers: List of valid driver names found in drivers/ - _driver_aliases: Dict that holds aliases for driver names - key: Driver alias declared with - U_BOOT_DRIVER_ALIAS(driver_alias, driver_name) - value: Driver name declared with U_BOOT_DRIVER(driver_name) - _drivers_additional: List of additional drivers to use during scanning + _dirname: Directory to hold output files, or None for none (all files + go to stdout) + _struct_data (dict): OrderedDict of dtplat structures to output + key (str): Node name, as a C identifier + value: dict containing structure fields: + key (str): Field name + value: Prop object with field information + _basedir (str): Base directory of source tree """ - def __init__(self, dtb_fname, include_disabled, warning_disabled, - drivers_additional=[]): + def __init__(self, scan, dtb_fname, include_disabled): + self._scan = scan self._fdt = None self._dtb_fname = dtb_fname self._valid_nodes = None self._include_disabled = include_disabled self._outfile = None - self._warning_disabled = warning_disabled self._lines = [] - self._drivers = [] - self._driver_aliases = {} - self._drivers_additional = drivers_additional + self._dirnames = [None] * len(Ftype) + self._struct_data = collections.OrderedDict() + self._basedir = None - def get_normalized_compat_name(self, node): - """Get a node's normalized compat name + def setup_output_dirs(self, output_dirs): + """Set up the output directories - Returns a valid driver name by retrieving node's list of compatible - string as a C identifier and performing a check against _drivers - and a lookup in driver_aliases printing a warning in case of failure. + This should be done before setup_output() is called Args: - node: Node object to check - Return: - Tuple: - Driver name associated with the first compatible string - List of C identifiers for all the other compatible strings - (possibly empty) - In case of no match found, the return will be the same as - get_compat_name() + output_dirs (tuple of str): + Directory to use for C output files. + Use None to write files relative current directory + Directory to use for H output files. + Defaults to the C output dir """ - compat_list_c = get_compat_name(node) - - for compat_c in compat_list_c: - if not compat_c in self._drivers: - compat_c = self._driver_aliases.get(compat_c) - if not compat_c: - continue - - aliases_c = compat_list_c - if compat_c in aliases_c: - aliases_c.remove(compat_c) - return compat_c, aliases_c - - if not self._warning_disabled: - print('WARNING: the driver %s was not found in the driver list' - % (compat_list_c[0])) - - return compat_list_c[0], compat_list_c[1:] - - def setup_output(self, fname): + def process_dir(ftype, dirname): + if dirname: + os.makedirs(dirname, exist_ok=True) + self._dirnames[ftype] = dirname + + if output_dirs: + c_dirname = output_dirs[0] + h_dirname = output_dirs[1] if len(output_dirs) > 1 else c_dirname + process_dir(Ftype.SOURCE, c_dirname) + process_dir(Ftype.HEADER, h_dirname) + + def setup_output(self, ftype, fname): """Set up the output destination Once this is done, future calls to self.out() will output to this - file. + file. The file used is as follows: + + self._dirnames[ftype] is None: output to fname, or stdout if None + self._dirnames[ftype] is not None: output to fname in that directory + + Calling this function multiple times will close the old file and open + the new one. If they are the same file, nothing happens and output will + continue to the same file. Args: - fname: Filename to send output to, or '-' for stdout + ftype (str): Type of file to create ('c' or 'h') + fname (str): Filename to send output to. If there is a directory in + self._dirnames for this file type, it will be put in that + directory """ - if fname == '-': - self._outfile = sys.stdout + dirname = self._dirnames[ftype] + if dirname: + pathname = os.path.join(dirname, fname) + if self._outfile: + self._outfile.close() + self._outfile = open(pathname, 'w') + elif fname: + if not self._outfile: + self._outfile = open(fname, 'w') else: - self._outfile = open(fname, 'w') + self._outfile = sys.stdout + + def finish_output(self): + """Finish outputing to a file + + This closes the output file, if one is in use + """ + if self._outfile != sys.stdout: + self._outfile.close() def out(self, line): """Output a string to the output file Args: - line: String to output + line (str): String to output """ self._outfile.write(line) @@ -231,7 +236,7 @@ class DtbPlatdata(object): """Buffer up a string to send later Args: - line: String to add to our 'buffer' list + line (str): String to add to our 'buffer' list """ self._lines.append(line) @@ -239,21 +244,26 @@ class DtbPlatdata(object): """Get the contents of the output buffer, and clear it Returns: - The output buffer, which is then cleared for future use + list(str): The output buffer, which is then cleared for future use """ lines = self._lines self._lines = [] return lines - def out_header(self): - """Output a message indicating that this is an auto-generated file""" + def out_header(self, outfile): + """Output a message indicating that this is an auto-generated file + + Args: + outfile: OutputFile describing the file being generated + """ self.out('''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * %s. + * This was generated by dtoc from a .dtb (device tree binary) file. */ -''') +''' % outfile.hdr_comment) def get_phandle_argc(self, prop, node_name): """Check if a node contains phandles @@ -262,9 +272,14 @@ class DtbPlatdata(object): or not. As an interim measure, use a list of known property names. Args: - prop: Prop object to check - Return: - Number of argument cells is this is a phandle, else None + prop (fdt.Prop): Prop object to check + node_name (str): Node name, only used for raising an error + Returns: + int or None: Number of argument cells is this is a phandle, + else None + Raises: + ValueError: if the phandle cannot be parsed or the required property + is not present """ if prop.name in ['clocks', 'cd-gpios']: if not isinstance(prop.value, list): @@ -293,7 +308,7 @@ class DtbPlatdata(object): break if not cells: raise ValueError("Node '%s' has no cells property" % - (target.name)) + (target.name)) num_args = fdt_util.fdt32_to_cpu(cells.value) max_args = max(max_args, num_args) args.append(num_args) @@ -301,62 +316,6 @@ class DtbPlatdata(object): return PhandleInfo(max_args, args) return None - def scan_driver(self, fn): - """Scan a driver file to build a list of driver names and aliases - - This procedure will populate self._drivers and self._driver_aliases - - Args - fn: Driver filename to scan - """ - with open(fn, encoding='utf-8') as fd: - try: - buff = fd.read() - except UnicodeDecodeError: - # This seems to happen on older Python versions - print("Skipping file '%s' due to unicode error" % fn) - return - - # The following re will search for driver names declared as - # U_BOOT_DRIVER(driver_name) - drivers = re.findall('U_BOOT_DRIVER\((.*)\)', buff) - - for driver in drivers: - self._drivers.append(driver) - - # The following re will search for driver aliases declared as - # U_BOOT_DRIVER_ALIAS(alias, driver_name) - driver_aliases = re.findall('U_BOOT_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)', - buff) - - for alias in driver_aliases: # pragma: no cover - if len(alias) != 2: - continue - self._driver_aliases[alias[1]] = alias[0] - - def scan_drivers(self): - """Scan the driver folders to build a list of driver names and aliases - - This procedure will populate self._drivers and self._driver_aliases - - """ - basedir = sys.argv[0].replace('tools/dtoc/dtoc', '') - if basedir == '': - basedir = './' - for (dirpath, dirnames, filenames) in os.walk(basedir): - for fn in filenames: - if not fn.endswith('.c'): - continue - self.scan_driver(dirpath + '/' + fn) - - for fn in self._drivers_additional: - if not isinstance(fn, str) or len(fn) == 0: - continue - if fn[0] == '/': - self.scan_driver(fn) - else: - self.scan_driver(basedir + '/' + fn) - def scan_dtb(self): """Scan the device tree to obtain a tree of nodes and properties @@ -371,8 +330,8 @@ class DtbPlatdata(object): This adds each node to self._valid_nodes. Args: - root: Root node for scan - valid_nodes: List of Node objects to add to + root (Node): Root node for scan + valid_nodes (list of Node): List of Node objects to add to """ for node in root.subnodes: if 'compatible' in node.props: @@ -403,7 +362,7 @@ class DtbPlatdata(object): """Get the number of cells in addresses and sizes for this node Args: - node: Node to check + node (fdt.None): Node to check Returns: Tuple: @@ -411,15 +370,15 @@ class DtbPlatdata(object): Number of size cells for this node """ parent = node.parent - na, ns = 2, 2 + num_addr, num_size = 2, 2 if parent: - na_prop = parent.props.get('#address-cells') - ns_prop = parent.props.get('#size-cells') - if na_prop: - na = fdt_util.fdt32_to_cpu(na_prop.value) - if ns_prop: - ns = fdt_util.fdt32_to_cpu(ns_prop.value) - return na, ns + addr_prop = parent.props.get('#address-cells') + size_prop = parent.props.get('#size-cells') + if addr_prop: + num_addr = fdt_util.fdt32_to_cpu(addr_prop.value) + if size_prop: + num_size = fdt_util.fdt32_to_cpu(size_prop.value) + return num_addr, num_size def scan_reg_sizes(self): """Scan for 64-bit 'reg' properties and update the values @@ -432,30 +391,31 @@ class DtbPlatdata(object): reg = node.props.get('reg') if not reg: continue - na, ns = self.get_num_cells(node) - total = na + ns + num_addr, num_size = self.get_num_cells(node) + total = num_addr + num_size - if reg.type != fdt.TYPE_INT: + if reg.type != fdt.Type.INT: raise ValueError("Node '%s' reg property is not an int" % node.name) if len(reg.value) % total: - raise ValueError("Node '%s' reg property has %d cells " - 'which is not a multiple of na + ns = %d + %d)' % - (node.name, len(reg.value), na, ns)) - reg.na = na - reg.ns = ns - if na != 1 or ns != 1: - reg.type = fdt.TYPE_INT64 + raise ValueError( + "Node '%s' reg property has %d cells " + 'which is not a multiple of na + ns = %d + %d)' % + (node.name, len(reg.value), num_addr, num_size)) + reg.num_addr = num_addr + reg.num_size = num_size + if num_addr != 1 or num_size != 1: + reg.type = fdt.Type.INT64 i = 0 new_value = [] val = reg.value if not isinstance(val, list): val = [val] while i < len(val): - addr = fdt_util.fdt_cells_to_cpu(val[i:], reg.na) - i += na - size = fdt_util.fdt_cells_to_cpu(val[i:], reg.ns) - i += ns + addr = fdt_util.fdt_cells_to_cpu(val[i:], reg.num_addr) + i += num_addr + size = fdt_util.fdt_cells_to_cpu(val[i:], reg.num_size) + i += num_size new_value += [addr, size] reg.value = new_value @@ -470,16 +430,11 @@ class DtbPlatdata(object): Once the widest property is determined, all other properties are updated to match that width. - Returns: - dict containing structures: - key (str): Node name, as a C identifier - value: dict containing structure fields: - key (str): Field name - value: Prop object with field information + The results are written to self._struct_data """ - structs = collections.OrderedDict() + structs = self._struct_data for node in self._valid_nodes: - node_name, _ = self.get_normalized_compat_name(node) + node_name, _ = self._scan.get_normalized_compat_name(node) fields = {} # Get a list of all the valid properties in this node. @@ -501,16 +456,12 @@ class DtbPlatdata(object): else: structs[node_name] = fields - upto = 0 for node in self._valid_nodes: - node_name, _ = self.get_normalized_compat_name(node) + node_name, _ = self._scan.get_normalized_compat_name(node) struct = structs[node_name] for name, prop in node.props.items(): if name not in PROP_IGNORE_LIST and name[0] != '#': prop.Widen(struct[name]) - upto += 1 - - return structs def scan_phandles(self): """Figure out what phandles each node uses @@ -540,22 +491,14 @@ class DtbPlatdata(object): pos += 1 + args - def generate_structs(self, structs): + def generate_structs(self): """Generate struct defintions for the platform data This writes out the body of a header file consisting of structure definitions for node in self._valid_nodes. See the documentation in doc/driver-model/of-plat.rst for more information. - - Args: - structs: dict containing structures: - key (str): Node name, as a C identifier - value: dict containing structure fields: - key (str): Field name - value: Prop object with field information - """ - self.out_header() + structs = self._struct_data self.out('#include <stdbool.h>\n') self.out('#include <linux/libfdt.h>\n') @@ -580,154 +523,198 @@ class DtbPlatdata(object): self.out(';\n') self.out('};\n') - def output_node(self, node): - """Output the C code for a node + def _output_list(self, node, prop): + """Output the C code for a devicetree property that holds a list Args: - node: node to output + node (fdt.Node): Node to output + prop (fdt.Prop): Prop to output """ - def _output_list(node, prop): - """Output the C code for a devicetree property that holds a list - - Args: - node (fdt.Node): Node to output - prop (fdt.Prop): Prop to output - """ - self.buf('{') - vals = [] - # For phandles, output a reference to the platform data - # of the target node. - info = self.get_phandle_argc(prop, node.name) - if info: - # Process the list as pairs of (phandle, id) - pos = 0 - item = 0 - for args in info.args: - phandle_cell = prop.value[pos] - phandle = fdt_util.fdt32_to_cpu(phandle_cell) - target_node = self._fdt.phandle_to_node[phandle] - name = conv_name_to_c(target_node.name) - arg_values = [] - for i in range(args): - arg_values.append( - str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i]))) - pos += 1 + args - vals.append('\t{%d, {%s}}' % (target_node.idx, - ', '.join(arg_values))) - item += 1 - for val in vals: - self.buf('\n\t\t%s,' % val) - else: - for val in prop.value: - vals.append(get_value(prop.type, val)) + self.buf('{') + vals = [] + # For phandles, output a reference to the platform data + # of the target node. + info = self.get_phandle_argc(prop, node.name) + if info: + # Process the list as pairs of (phandle, id) + pos = 0 + for args in info.args: + phandle_cell = prop.value[pos] + phandle = fdt_util.fdt32_to_cpu(phandle_cell) + target_node = self._fdt.phandle_to_node[phandle] + arg_values = [] + for i in range(args): + arg_values.append( + str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i]))) + pos += 1 + args + vals.append('\t{%d, {%s}}' % (target_node.idx, + ', '.join(arg_values))) + for val in vals: + self.buf('\n\t\t%s,' % val) + else: + for val in prop.value: + vals.append(get_value(prop.type, val)) - # Put 8 values per line to avoid very long lines. - for i in range(0, len(vals), 8): - if i: - self.buf(',\n\t\t') - self.buf(', '.join(vals[i:i + 8])) - self.buf('}') + # Put 8 values per line to avoid very long lines. + for i in range(0, len(vals), 8): + if i: + self.buf(',\n\t\t') + self.buf(', '.join(vals[i:i + 8])) + self.buf('}') - struct_name, _ = self.get_normalized_compat_name(node) - var_name = conv_name_to_c(node.name) - self.buf('/* Node %s index %d */\n' % (node.path, node.idx)) - self.buf('static struct %s%s %s%s = {\n' % - (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name)) - for pname in sorted(node.props): - prop = node.props[pname] - if pname in PROP_IGNORE_LIST or pname[0] == '#': - continue - member_name = conv_name_to_c(prop.name) - self.buf('\t%s= ' % tab_to(3, '.' + member_name)) + def _declare_device(self, var_name, struct_name, node_parent): + """Add a device declaration to the output - # Special handling for lists - if isinstance(prop.value, list): - _output_list(node, prop) - else: - self.buf(get_value(prop.type, prop.value)) - self.buf(',\n') - self.buf('};\n') + This declares a U_BOOT_DRVINFO() for the device being processed - # Add a device declaration - self.buf('U_BOOT_DEVICE(%s) = {\n' % var_name) + Args: + var_name (str): C name for the node + struct_name (str): Name for the dt struct associated with the node + node_parent (Node): Parent of the node (or None if none) + """ + self.buf('U_BOOT_DRVINFO(%s) = {\n' % var_name) self.buf('\t.name\t\t= "%s",\n' % struct_name) - self.buf('\t.platdata\t= &%s%s,\n' % (VAL_PREFIX, var_name)) - self.buf('\t.platdata_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name)) + self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name)) + self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name)) idx = -1 - if node.parent and node.parent in self._valid_nodes: - idx = node.parent.idx + if node_parent and node_parent in self._valid_nodes: + idx = node_parent.idx self.buf('\t.parent_idx\t= %d,\n' % idx) self.buf('};\n') self.buf('\n') + def _output_prop(self, node, prop): + """Output a line containing the value of a struct member + + Args: + node (Node): Node being output + prop (Prop): Prop object to output + """ + if prop.name in PROP_IGNORE_LIST or prop.name[0] == '#': + return + member_name = conv_name_to_c(prop.name) + self.buf('\t%s= ' % tab_to(3, '.' + member_name)) + + # Special handling for lists + if isinstance(prop.value, list): + self._output_list(node, prop) + else: + self.buf(get_value(prop.type, prop.value)) + self.buf(',\n') + + def _output_values(self, var_name, struct_name, node): + """Output the definition of a device's struct values + + Args: + var_name (str): C name for the node + struct_name (str): Name for the dt struct associated with the node + node (Node): Node being output + """ + self.buf('static struct %s%s %s%s = {\n' % + (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name)) + for pname in sorted(node.props): + self._output_prop(node, node.props[pname]) + self.buf('};\n') + + def output_node(self, node): + """Output the C code for a node + + Args: + node (fdt.Node): node to output + """ + struct_name, _ = self._scan.get_normalized_compat_name(node) + var_name = conv_name_to_c(node.name) + self.buf('/* Node %s index %d */\n' % (node.path, node.idx)) + + self._output_values(var_name, struct_name, node) + self._declare_device(var_name, struct_name, node.parent) + self.out(''.join(self.get_buf())) - def generate_tables(self): + def generate_plat(self): """Generate device defintions for the platform data This writes out C platform data initialisation data and - U_BOOT_DEVICE() declarations for each valid node. Where a node has + U_BOOT_DRVINFO() declarations for each valid node. Where a node has multiple compatible strings, a #define is used to make them equivalent. See the documentation in doc/driver-model/of-plat.rst for more information. """ - self.out_header() - self.out('/* Allow use of U_BOOT_DEVICE() in this file */\n') - self.out('#define DT_PLATDATA_C\n') + self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n') + self.out('#define DT_PLAT_C\n') self.out('\n') self.out('#include <common.h>\n') self.out('#include <dm.h>\n') self.out('#include <dt-structs.h>\n') self.out('\n') - nodes_to_output = list(self._valid_nodes) - - # Keep outputing nodes until there is none left - while nodes_to_output: - node = nodes_to_output[0] - # Output all the node's dependencies first - for req_node in node.phandles: - if req_node in nodes_to_output: - self.output_node(req_node) - nodes_to_output.remove(req_node) - self.output_node(node) - nodes_to_output.remove(node) - # Define dm_populate_phandle_data() which will add the linking between - # nodes using DM_GET_DEVICE - # dtv_dmc_at_xxx.clocks[0].node = DM_GET_DEVICE(clock_controller_at_xxx) - self.buf('void dm_populate_phandle_data(void) {\n') - self.buf('}\n') + for node in self._valid_nodes: + self.output_node(node) self.out(''.join(self.get_buf())) -def run_steps(args, dtb_file, include_disabled, output, warning_disabled=False, - drivers_additional=[]): + +# Types of output file we understand +# key: Command used to generate this file +# value: OutputFile for this command +OUTPUT_FILES = { + 'struct': + OutputFile(Ftype.HEADER, 'dt-structs-gen.h', + DtbPlatdata.generate_structs, + 'Defines the structs used to hold devicetree data'), + 'platdata': + OutputFile(Ftype.SOURCE, 'dt-plat.c', DtbPlatdata.generate_plat, + 'Declares the U_BOOT_DRIVER() records and platform data'), + } + + +def run_steps(args, dtb_file, include_disabled, output, output_dirs, + warning_disabled=False, drivers_additional=None, basedir=None): """Run all the steps of the dtoc tool Args: - args: List of non-option arguments provided to the problem - dtb_file: Filename of dtb file to process - include_disabled: True to include disabled nodes - output: Name of output file + args (list): List of non-option arguments provided to the problem + dtb_file (str): Filename of dtb file to process + include_disabled (bool): True to include disabled nodes + output (str): Name of output file (None for stdout) + output_dirs (tuple of str): + Directory to put C output files + Directory to put H output files + warning_disabled (bool): True to avoid showing warnings about missing + drivers + drivers_additional (list): List of additional drivers to use during + scanning + basedir (str): Base directory of U-Boot source code. Defaults to the + grandparent of this file's directory + Raises: + ValueError: if args has no command, or an unknown command """ if not args: - raise ValueError('Please specify a command: struct, platdata') + raise ValueError('Please specify a command: struct, platdata, all') + if output and output_dirs and any(output_dirs): + raise ValueError('Must specify either output or output_dirs, not both') - plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled, drivers_additional) - plat.scan_drivers() + scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional) + plat = DtbPlatdata(scan, dtb_file, include_disabled) + scan.scan_drivers() plat.scan_dtb() plat.scan_tree() plat.scan_reg_sizes() - plat.setup_output(output) - structs = plat.scan_structs() + plat.setup_output_dirs(output_dirs) + plat.scan_structs() plat.scan_phandles() - for cmd in args[0].split(','): - if cmd == 'struct': - plat.generate_structs(structs) - elif cmd == 'platdata': - plat.generate_tables() - else: - raise ValueError("Unknown command '%s': (use: struct, platdata)" % - cmd) + cmds = args[0].split(',') + if 'all' in cmds: + cmds = sorted(OUTPUT_FILES.keys()) + for cmd in cmds: + outfile = OUTPUT_FILES.get(cmd) + if not outfile: + raise ValueError("Unknown command '%s': (use: %s)" % + (cmd, ', '.join(sorted(OUTPUT_FILES.keys())))) + plat.setup_output(outfile.ftype, + outfile.fname if output_dirs else output) + plat.out_header(outfile) + outfile.method(plat) + plat.finish_output() diff --git a/tools/dtoc/dtoc_test_scan_drivers.cxx b/tools/dtoc/dtoc_test_scan_drivers.cxx index 557c692ba2..f448767670 100644 --- a/tools/dtoc/dtoc_test_scan_drivers.cxx +++ b/tools/dtoc/dtoc_test_scan_drivers.cxx @@ -1 +1 @@ -U_BOOT_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2) +DM_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias2) diff --git a/tools/dtoc/dtoc_test_simple.dts b/tools/dtoc/dtoc_test_simple.dts index fd168cb593..1c87b89192 100644 --- a/tools/dtoc/dtoc_test_simple.dts +++ b/tools/dtoc/dtoc_test_simple.dts @@ -44,11 +44,6 @@ longbytearray = [09 0a 0b 0c 0d 0e 0f 10]; }; - spl-test4 { - u-boot,dm-pre-reloc; - compatible = "sandbox,spl-test.2"; - }; - i2c@0 { compatible = "sandbox,i2c-test"; u-boot,dm-pre-reloc; diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 03b86773d5..4a78c73725 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -5,6 +5,7 @@ # Written by Simon Glass <sjg@chromium.org> # +from enum import IntEnum import struct import sys @@ -22,7 +23,25 @@ from patman import tools # so it is fairly efficient. # A list of types we support -(TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, TYPE_INT64) = range(5) +class Type(IntEnum): + (BYTE, INT, STRING, BOOL, INT64) = range(5) + + def is_wider_than(self, other): + """Check if another type is 'wider' than this one + + A wider type is one that holds more information than an earlier one, + similar to the concept of type-widening in C. + + This uses a simple arithmetic comparison, since type values are in order + from narrowest (BYTE) to widest (INT64). + + Args: + other: Other type to compare against + + Return: + True if the other type is wider + """ + return self.value > other.value def CheckErr(errnum, msg): if errnum: @@ -41,9 +60,9 @@ def BytesToValue(data): Type of data Data, either a single element or a list of elements. Each element is one of: - TYPE_STRING: str/bytes value from the property - TYPE_INT: a byte-swapped integer stored as a 4-byte str/bytes - TYPE_BYTE: a byte stored as a single-byte str/bytes + Type.STRING: str/bytes value from the property + Type.INT: a byte-swapped integer stored as a 4-byte str/bytes + Type.BYTE: a byte stored as a single-byte str/bytes """ data = bytes(data) size = len(data) @@ -63,21 +82,21 @@ def BytesToValue(data): is_string = False if is_string: if count == 1: - return TYPE_STRING, strings[0].decode() + return Type.STRING, strings[0].decode() else: - return TYPE_STRING, [s.decode() for s in strings[:-1]] + return Type.STRING, [s.decode() for s in strings[:-1]] if size % 4: if size == 1: - return TYPE_BYTE, tools.ToChar(data[0]) + return Type.BYTE, chr(data[0]) else: - return TYPE_BYTE, [tools.ToChar(ch) for ch in list(data)] + return Type.BYTE, [chr(ch) for ch in list(data)] val = [] for i in range(0, size, 4): val.append(data[i:i + 4]) if size == 4: - return TYPE_INT, val[0] + return Type.INT, val[0] else: - return TYPE_INT, val + return Type.INT, val class Prop: @@ -97,7 +116,7 @@ class Prop: self.bytes = bytes(data) self.dirty = False if not data: - self.type = TYPE_BOOL + self.type = Type.BOOL self.value = True return self.type, self.value = BytesToValue(bytes(data)) @@ -128,15 +147,14 @@ class Prop: update the current property to be like the second, since it is less specific. """ - if newprop.type < self.type: - # Special handling to convert an int into bytes - if self.type == TYPE_INT and newprop.type == TYPE_BYTE: + if self.type.is_wider_than(newprop.type): + if self.type == Type.INT and newprop.type == Type.BYTE: if type(self.value) == list: new_value = [] for val in self.value: - new_value += [tools.ToChar(by) for by in val] + new_value += [chr(by) for by in val] else: - new_value = [tools.ToChar(by) for by in self.value] + new_value = [chr(by) for by in self.value] self.value = new_value self.type = newprop.type @@ -155,11 +173,11 @@ class Prop: Returns: A single value of the given type """ - if type == TYPE_BYTE: + if type == Type.BYTE: return chr(0) - elif type == TYPE_INT: + elif type == Type.INT: return struct.pack('>I', 0); - elif type == TYPE_STRING: + elif type == Type.STRING: return '' else: return True @@ -184,7 +202,7 @@ class Prop: """ self.bytes = struct.pack('>I', val); self.value = self.bytes - self.type = TYPE_INT + self.type = Type.INT self.dirty = True def SetData(self, bytes): diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py index b94d9c301f..b0ad0f3952 100755 --- a/tools/dtoc/main.py +++ b/tools/dtoc/main.py @@ -13,11 +13,7 @@ having to link against libfdt. By putting the data from the device tree into C structures, normal C code can be used. This helps to reduce the size of the compiled program. -Dtoc produces two output files: - - dt-structs.h - contains struct definitions - dt-platdata.c - contains data from the device tree using the struct - definitions, as well as U-Boot driver definitions. +Dtoc produces several output files - see OUTPUT_FILES in dtb_platdata.py This tool is used in U-Boot to provide device tree data to SPL without increasing the code size of SPL. This supports the CONFIG_SPL_OF_PLATDATA @@ -42,37 +38,27 @@ sys.path.insert(0, os.path.join(our_path, from dtoc import dtb_platdata from patman import test_util -def run_tests(args): +def run_tests(processes, args): """Run all the test we have for dtoc Args: + processes: Number of processes to use to run tests (None=same as #CPUs) args: List of positional args provided to dtoc. This can hold a test name to execute (as in 'dtoc -t test_empty_file', for example) """ - import test_dtoc + from dtoc import test_src_scan + from dtoc import test_dtoc result = unittest.TestResult() sys.argv = [sys.argv[0]] test_name = args and args[0] or None - for module in (test_dtoc.TestDtoc,): - if test_name: - try: - suite = unittest.TestLoader().loadTestsFromName(test_name, module) - except AttributeError: - continue - else: - suite = unittest.TestLoader().loadTestsFromTestCase(module) - suite.run(result) - - print(result) - for _, err in result.errors: - print(err) - for _, err in result.failures: - print(err) - if result.errors or result.failures: - print('dtoc tests FAILED') - return 1 - return 0 + + test_util.RunTestSuites( + result, debug=True, verbosity=1, test_preserve_dirs=False, + processes=processes, test_name=test_name, toolpath=[], + test_class_list=[test_dtoc.TestDtoc,test_src_scan.TestSrcScan]) + + return test_util.ReportResult('binman', test_name, result) def RunTestCoverage(): """Run the tests and check that we get 100% coverage""" @@ -87,11 +73,15 @@ if __name__ != '__main__': parser = OptionParser() parser.add_option('-B', '--build-dir', type='string', default='b', help='Directory containing the build output') +parser.add_option('-c', '--c-output-dir', action='store', + help='Select output directory for C files') +parser.add_option('-C', '--h-output-dir', action='store', + help='Select output directory for H files (defaults to --c-output-di)') parser.add_option('-d', '--dtb-file', action='store', help='Specify the .dtb input file') parser.add_option('--include-disabled', action='store_true', help='Include disabled nodes') -parser.add_option('-o', '--output', action='store', default='-', +parser.add_option('-o', '--output', action='store', help='Select output filename') parser.add_option('-P', '--processes', type=int, help='set number of processes to use for running tests') @@ -103,7 +93,7 @@ parser.add_option('-T', '--test-coverage', action='store_true', # Run our meagre tests if options.test: - ret_code = run_tests(args) + ret_code = run_tests(options.processes, args) sys.exit(ret_code) elif options.test_coverage: @@ -111,4 +101,5 @@ elif options.test_coverage: else: dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled, - options.output) + options.output, + [options.c_output_dir, options.h_output_dir]) diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py new file mode 100644 index 0000000000..f63c9fc166 --- /dev/null +++ b/tools/dtoc/src_scan.py @@ -0,0 +1,185 @@ +#!/usr/bin/python +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2017 Google, Inc +# Written by Simon Glass <sjg@chromium.org> +# + +"""Scanning of U-Boot source for drivers and structs + +This scans the source tree to find out things about all instances of +U_BOOT_DRIVER(), UCLASS_DRIVER and all struct declarations in header files. + +See doc/driver-model/of-plat.rst for more informaiton +""" + +import os +import re +import sys + + +def conv_name_to_c(name): + """Convert a device-tree name to a C identifier + + This uses multiple replace() calls instead of re.sub() since it is faster + (400ms for 1m calls versus 1000ms for the 're' version). + + Args: + name (str): Name to convert + Return: + str: String containing the C version of this name + """ + new = name.replace('@', '_at_') + new = new.replace('-', '_') + new = new.replace(',', '_') + new = new.replace('.', '_') + return new + +def get_compat_name(node): + """Get the node's list of compatible string as a C identifiers + + Args: + node (fdt.Node): Node object to check + Return: + list of str: List of C identifiers for all the compatible strings + """ + compat = node.props['compatible'].value + if not isinstance(compat, list): + compat = [compat] + return [conv_name_to_c(c) for c in compat] + + +class Driver: + """Information about a driver in U-Boot + + Attributes: + name: Name of driver. For U_BOOT_DRIVER(x) this is 'x' + """ + def __init__(self, name): + self.name = name + + def __eq__(self, other): + return self.name == other.name + + def __repr__(self): + return "Driver(name='%s')" % self.name + + +class Scanner: + """Scanning of the U-Boot source tree + + Properties: + _basedir (str): Base directory of U-Boot source code. Defaults to the + grandparent of this file's directory + _drivers: Dict of valid driver names found in drivers/ + key: Driver name + value: Driver for that driver + _driver_aliases: Dict that holds aliases for driver names + key: Driver alias declared with + DM_DRIVER_ALIAS(driver_alias, driver_name) + value: Driver name declared with U_BOOT_DRIVER(driver_name) + _warning_disabled: true to disable warnings about driver names not found + _drivers_additional (list or str): List of additional drivers to use + during scanning + """ + def __init__(self, basedir, warning_disabled, drivers_additional): + """Set up a new Scanner + """ + if not basedir: + basedir = sys.argv[0].replace('tools/dtoc/dtoc', '') + if basedir == '': + basedir = './' + self._basedir = basedir + self._drivers = {} + self._driver_aliases = {} + self._drivers_additional = drivers_additional or [] + self._warning_disabled = warning_disabled + + def get_normalized_compat_name(self, node): + """Get a node's normalized compat name + + Returns a valid driver name by retrieving node's list of compatible + string as a C identifier and performing a check against _drivers + and a lookup in driver_aliases printing a warning in case of failure. + + Args: + node (Node): Node object to check + Return: + Tuple: + Driver name associated with the first compatible string + List of C identifiers for all the other compatible strings + (possibly empty) + In case of no match found, the return will be the same as + get_compat_name() + """ + compat_list_c = get_compat_name(node) + + for compat_c in compat_list_c: + if not compat_c in self._drivers.keys(): + compat_c = self._driver_aliases.get(compat_c) + if not compat_c: + continue + + aliases_c = compat_list_c + if compat_c in aliases_c: + aliases_c.remove(compat_c) + return compat_c, aliases_c + + if not self._warning_disabled: + print('WARNING: the driver %s was not found in the driver list' + % (compat_list_c[0])) + + return compat_list_c[0], compat_list_c[1:] + + def scan_driver(self, fname): + """Scan a driver file to build a list of driver names and aliases + + This procedure will populate self._drivers and self._driver_aliases + + Args + fname: Driver filename to scan + """ + with open(fname, encoding='utf-8') as inf: + try: + buff = inf.read() + except UnicodeDecodeError: + # This seems to happen on older Python versions + print("Skipping file '%s' due to unicode error" % fname) + return + + # The following re will search for driver names declared as + # U_BOOT_DRIVER(driver_name) + drivers = re.findall(r'U_BOOT_DRIVER\((.*)\)', buff) + + for driver in drivers: + self._drivers[driver] = Driver(driver) + + # The following re will search for driver aliases declared as + # DM_DRIVER_ALIAS(alias, driver_name) + driver_aliases = re.findall( + r'DM_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)', + buff) + + for alias in driver_aliases: # pragma: no cover + if len(alias) != 2: + continue + self._driver_aliases[alias[1]] = alias[0] + + def scan_drivers(self): + """Scan the driver folders to build a list of driver names and aliases + + This procedure will populate self._drivers and self._driver_aliases + """ + for (dirpath, _, filenames) in os.walk(self._basedir): + for fname in filenames: + if not fname.endswith('.c'): + continue + self.scan_driver(dirpath + '/' + fname) + + for fname in self._drivers_additional: + if not isinstance(fname, str) or len(fname) == 0: + continue + if fname[0] == '/': + self.scan_driver(fname) + else: + self.scan_driver(self._basedir + '/' + fname) diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index a5836e04b7..d961d67b8f 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -10,29 +10,29 @@ tool. """ import collections +import glob import os import struct -import sys -import tempfile import unittest -from dtoc import dtb_platdata -from dtb_platdata import conv_name_to_c -from dtb_platdata import get_compat_name from dtb_platdata import get_value from dtb_platdata import tab_to +from dtoc import dtb_platdata from dtoc import fdt from dtoc import fdt_util +from dtoc.src_scan import conv_name_to_c +from dtoc.src_scan import get_compat_name from patman import test_util from patman import tools -our_path = os.path.dirname(os.path.realpath(__file__)) +OUR_PATH = os.path.dirname(os.path.realpath(__file__)) HEADER = '''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * Defines the structs used to hold devicetree data. + * This was generated by dtoc from a .dtb (device tree binary) file. */ #include <stdbool.h> @@ -41,33 +41,33 @@ HEADER = '''/* C_HEADER = '''/* * DO NOT MODIFY * - * This file was generated by dtoc from a .dtb (device tree binary) file. + * Declares the U_BOOT_DRIVER() records and platform data. + * This was generated by dtoc from a .dtb (device tree binary) file. */ -/* Allow use of U_BOOT_DEVICE() in this file */ -#define DT_PLATDATA_C +/* Allow use of U_BOOT_DRVINFO() in this file */ +#define DT_PLAT_C #include <common.h> #include <dm.h> #include <dt-structs.h> ''' -C_EMPTY_POPULATE_PHANDLE_DATA = '''void dm_populate_phandle_data(void) { -} -''' - +# This is a test so is allowed to access private things in the module it is +# testing +# pylint: disable=W0212 def get_dtb_file(dts_fname, capture_stderr=False): """Compile a .dts file to a .dtb Args: - dts_fname: Filename of .dts file in the current directory - capture_stderr: True to capture and discard stderr output + dts_fname (str): Filename of .dts file in the current directory + capture_stderr (bool): True to capture and discard stderr output Returns: - Filename of compiled file in output directory + str: Filename of compiled file in output directory """ - return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname), + return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, dts_fname), capture_stderr=capture_stderr) @@ -80,20 +80,21 @@ class TestDtoc(unittest.TestCase): @classmethod def tearDownClass(cls): - tools._RemoveOutputDir() + tools.FinaliseOutputDir() - def _WritePythonString(self, fname, data): + @staticmethod + def _write_python_string(fname, data): """Write a string with tabs expanded as done in this Python file Args: - fname: Filename to write to - data: Raw string to convert + fname (str): Filename to write to + data (str): Raw string to convert """ data = data.replace('\t', '\\t') - with open(fname, 'w') as fd: - fd.write(data) + with open(fname, 'w') as fout: + fout.write(data) - def _CheckStrings(self, expected, actual): + def _check_strings(self, expected, actual): """Check that a string matches its expected value If the strings do not match, they are written to the /tmp directory in @@ -101,18 +102,25 @@ class TestDtoc(unittest.TestCase): easy comparison and update of the tests. Args: - expected: Expected string - actual: Actual string + expected (str): Expected string + actual (str): Actual string """ if expected != actual: - self._WritePythonString('/tmp/binman.expected', expected) - self._WritePythonString('/tmp/binman.actual', actual) + self._write_python_string('/tmp/binman.expected', expected) + self._write_python_string('/tmp/binman.actual', actual) print('Failures written to /tmp/binman.{expected,actual}') - self.assertEquals(expected, actual) + self.assertEqual(expected, actual) + @staticmethod + def run_test(args, dtb_file, output): + """Run a test using dtoc - def run_test(self, args, dtb_file, output): - dtb_platdata.run_steps(args, dtb_file, False, output, True) + Args: + args (list of str): List of arguments for dtoc + dtb_file (str): Filename of .dtb file + output (str): Filename of output file + """ + dtb_platdata.run_steps(args, dtb_file, False, output, [], True) def test_name(self): """Test conversion of device tree names to C identifiers""" @@ -134,13 +142,13 @@ class TestDtoc(unittest.TestCase): def test_get_value(self): """Test operation of get_value() function""" self.assertEqual('0x45', - get_value(fdt.TYPE_INT, struct.pack('>I', 0x45))) + get_value(fdt.Type.INT, struct.pack('>I', 0x45))) self.assertEqual('0x45', - get_value(fdt.TYPE_BYTE, struct.pack('<I', 0x45))) + get_value(fdt.Type.BYTE, struct.pack('<I', 0x45))) self.assertEqual('0x0', - get_value(fdt.TYPE_BYTE, struct.pack('>I', 0x45))) - self.assertEqual('"test"', get_value(fdt.TYPE_STRING, 'test')) - self.assertEqual('true', get_value(fdt.TYPE_BOOL, None)) + get_value(fdt.Type.BYTE, struct.pack('>I', 0x45))) + self.assertEqual('"test"', get_value(fdt.Type.STRING, 'test')) + self.assertEqual('true', get_value(fdt.Type.BOOL, None)) def test_get_compat_name(self): """Test operation of get_compat_name() function""" @@ -160,7 +168,7 @@ class TestDtoc(unittest.TestCase): prop = Prop(['rockchip,rk3399-sdhci-5.1', 'arasan,sdhci-5.1', 'third']) node = Node({'compatible': prop}) self.assertEqual((['rockchip_rk3399_sdhci_5_1', - 'arasan_sdhci_5_1', 'third']), + 'arasan_sdhci_5_1', 'third']), get_compat_name(node)) def test_empty_file(self): @@ -175,17 +183,9 @@ class TestDtoc(unittest.TestCase): self.run_test(['platdata'], dtb_file, output) with open(output) as infile: lines = infile.read().splitlines() - self.assertEqual(C_HEADER.splitlines() + [''] + - C_EMPTY_POPULATE_PHANDLE_DATA.splitlines(), lines) + self.assertEqual(C_HEADER.splitlines() + [''], lines) - def test_simple(self): - """Test output from some simple nodes with various types of data""" - dtb_file = get_dtb_file('dtoc_test_simple.dts') - output = tools.GetOutputFilename('output') - self.run_test(['struct'], dtb_file, output) - with open(output) as infile: - data = infile.read() - self._CheckStrings(HEADER + ''' + struct_text = HEADER + ''' struct dtd_sandbox_i2c_test { }; struct dtd_sandbox_pmic_test { @@ -204,21 +204,16 @@ struct dtd_sandbox_spl_test { \tconst char *\tstringarray[3]; \tconst char *\tstringval; }; -struct dtd_sandbox_spl_test_2 { -}; -''', data) +''' - self.run_test(['platdata'], dtb_file, output) - with open(output) as infile: - data = infile.read() - self._CheckStrings(C_HEADER + ''' + platdata_text = C_HEADER + ''' /* Node /i2c@0 index 0 */ static struct dtd_sandbox_i2c_test dtv_i2c_at_0 = { }; -U_BOOT_DEVICE(i2c_at_0) = { +U_BOOT_DRVINFO(i2c_at_0) = { \t.name\t\t= "sandbox_i2c_test", -\t.platdata\t= &dtv_i2c_at_0, -\t.platdata_size\t= sizeof(dtv_i2c_at_0), +\t.plat\t= &dtv_i2c_at_0, +\t.plat_size\t= sizeof(dtv_i2c_at_0), \t.parent_idx\t= -1, }; @@ -227,10 +222,10 @@ static struct dtd_sandbox_pmic_test dtv_pmic_at_9 = { \t.low_power\t\t= true, \t.reg\t\t\t= {0x9, 0x0}, }; -U_BOOT_DEVICE(pmic_at_9) = { +U_BOOT_DRVINFO(pmic_at_9) = { \t.name\t\t= "sandbox_pmic_test", -\t.platdata\t= &dtv_pmic_at_9, -\t.platdata_size\t= sizeof(dtv_pmic_at_9), +\t.plat\t= &dtv_pmic_at_9, +\t.plat_size\t= sizeof(dtv_pmic_at_9), \t.parent_idx\t= 0, }; @@ -247,10 +242,10 @@ static struct dtd_sandbox_spl_test dtv_spl_test = { \t.stringarray\t\t= {"multi-word", "message", ""}, \t.stringval\t\t= "message", }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test, -\t.platdata_size\t= sizeof(dtv_spl_test), +\t.plat\t= &dtv_spl_test, +\t.plat_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -266,10 +261,10 @@ static struct dtd_sandbox_spl_test dtv_spl_test2 = { \t.stringarray\t\t= {"another", "multi-word", "message"}, \t.stringval\t\t= "message2", }; -U_BOOT_DEVICE(spl_test2) = { +U_BOOT_DRVINFO(spl_test2) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test2, -\t.platdata_size\t= sizeof(dtv_spl_test2), +\t.plat\t= &dtv_spl_test2, +\t.plat_size\t= sizeof(dtv_spl_test2), \t.parent_idx\t= -1, }; @@ -279,24 +274,35 @@ static struct dtd_sandbox_spl_test dtv_spl_test3 = { \t\t0x0}, \t.stringarray\t\t= {"one", "", ""}, }; -U_BOOT_DEVICE(spl_test3) = { +U_BOOT_DRVINFO(spl_test3) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test3, -\t.platdata_size\t= sizeof(dtv_spl_test3), +\t.plat\t= &dtv_spl_test3, +\t.plat_size\t= sizeof(dtv_spl_test3), \t.parent_idx\t= -1, }; -/* Node /spl-test4 index 5 */ -static struct dtd_sandbox_spl_test_2 dtv_spl_test4 = { -}; -U_BOOT_DEVICE(spl_test4) = { -\t.name\t\t= "sandbox_spl_test_2", -\t.platdata\t= &dtv_spl_test4, -\t.platdata_size\t= sizeof(dtv_spl_test4), -\t.parent_idx\t= -1, -}; +''' -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) + def test_simple(self): + """Test output from some simple nodes with various types of data""" + dtb_file = get_dtb_file('dtoc_test_simple.dts') + output = tools.GetOutputFilename('output') + self.run_test(['struct'], dtb_file, output) + with open(output) as infile: + data = infile.read() + + self._check_strings(self.struct_text, data) + + self.run_test(['platdata'], dtb_file, output) + with open(output) as infile: + data = infile.read() + + self._check_strings(self.platdata_text, data) + + # Try the 'all' command + self.run_test(['all'], dtb_file, output) + data = tools.ReadFile(output, binary=False) + self._check_strings(self.platdata_text + self.struct_text, data) def test_driver_alias(self): """Test output from a device tree file with a driver alias""" @@ -305,7 +311,7 @@ U_BOOT_DEVICE(spl_test4) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_gpio { \tconst char *\tgpio_bank_name; \tbool\t\tgpio_controller; @@ -316,54 +322,50 @@ struct dtd_sandbox_gpio { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /gpios@0 index 0 */ static struct dtd_sandbox_gpio dtv_gpios_at_0 = { \t.gpio_bank_name\t\t= "a", \t.gpio_controller\t= true, \t.sandbox_gpio_count\t= 0x14, }; -U_BOOT_DEVICE(gpios_at_0) = { +U_BOOT_DRVINFO(gpios_at_0) = { \t.name\t\t= "sandbox_gpio", -\t.platdata\t= &dtv_gpios_at_0, -\t.platdata_size\t= sizeof(dtv_gpios_at_0), +\t.plat\t= &dtv_gpios_at_0, +\t.plat_size\t= sizeof(dtv_gpios_at_0), \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_invalid_driver(self): """Test output from a device tree file with an invalid driver""" dtb_file = get_dtb_file('dtoc_test_invalid_driver.dts') output = tools.GetOutputFilename('output') - with test_util.capture_sys_output() as (stdout, stderr): - dtb_platdata.run_steps(['struct'], dtb_file, False, output) + with test_util.capture_sys_output() as _: + dtb_platdata.run_steps(['struct'], dtb_file, False, output, []) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_invalid { }; ''', data) - with test_util.capture_sys_output() as (stdout, stderr): - dtb_platdata.run_steps(['platdata'], dtb_file, False, output) + with test_util.capture_sys_output() as _: + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, []) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /spl-test index 0 */ static struct dtd_invalid dtv_spl_test = { }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "invalid", -\t.platdata\t= &dtv_spl_test, -\t.platdata_size\t= sizeof(dtv_spl_test), +\t.plat\t= &dtv_spl_test, +\t.plat_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle(self): @@ -373,7 +375,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_source { \tstruct phandle_2_arg clocks[4]; }; @@ -385,15 +387,15 @@ struct dtd_target { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle2-target index 0 */ static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(phandle2_target) = { +U_BOOT_DRVINFO(phandle2_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle2_target, -\t.platdata_size\t= sizeof(dtv_phandle2_target), +\t.plat\t= &dtv_phandle2_target, +\t.plat_size\t= sizeof(dtv_phandle2_target), \t.parent_idx\t= -1, }; @@ -401,21 +403,10 @@ U_BOOT_DEVICE(phandle2_target) = { static struct dtd_target dtv_phandle3_target = { \t.intval\t\t\t= 0x2, }; -U_BOOT_DEVICE(phandle3_target) = { +U_BOOT_DRVINFO(phandle3_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle3_target, -\t.platdata_size\t= sizeof(dtv_phandle3_target), -\t.parent_idx\t= -1, -}; - -/* Node /phandle-target index 4 */ -static struct dtd_target dtv_phandle_target = { -\t.intval\t\t\t= 0x0, -}; -U_BOOT_DEVICE(phandle_target) = { -\t.name\t\t= "target", -\t.platdata\t= &dtv_phandle_target, -\t.platdata_size\t= sizeof(dtv_phandle_target), +\t.plat\t= &dtv_phandle3_target, +\t.plat_size\t= sizeof(dtv_phandle3_target), \t.parent_idx\t= -1, }; @@ -427,10 +418,10 @@ static struct dtd_source dtv_phandle_source = { \t\t\t{1, {12, 13}}, \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source) = { +U_BOOT_DRVINFO(phandle_source) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source, -\t.platdata_size\t= sizeof(dtv_phandle_source), +\t.plat\t= &dtv_phandle_source, +\t.plat_size\t= sizeof(dtv_phandle_source), \t.parent_idx\t= -1, }; @@ -439,15 +430,24 @@ static struct dtd_source dtv_phandle_source2 = { \t.clocks\t\t\t= { \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source2, -\t.platdata_size\t= sizeof(dtv_phandle_source2), +\t.plat\t= &dtv_phandle_source2, +\t.plat_size\t= sizeof(dtv_phandle_source2), +\t.parent_idx\t= -1, +}; + +/* Node /phandle-target index 4 */ +static struct dtd_target dtv_phandle_target = { +\t.intval\t\t\t= 0x0, +}; +U_BOOT_DRVINFO(phandle_target) = { +\t.name\t\t= "target", +\t.plat\t= &dtv_phandle_target, +\t.plat_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_single(self): @@ -457,7 +457,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_source { \tstruct phandle_0_arg clocks[1]; }; @@ -473,49 +473,47 @@ struct dtd_target { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' -/* Node /phandle-target index 1 */ -static struct dtd_target dtv_phandle_target = { -}; -U_BOOT_DEVICE(phandle_target) = { -\t.name\t\t= "target", -\t.platdata\t= &dtv_phandle_target, -\t.platdata_size\t= sizeof(dtv_phandle_target), -\t.parent_idx\t= -1, -}; - + self._check_strings(C_HEADER + ''' /* Node /phandle-source2 index 0 */ static struct dtd_source dtv_phandle_source2 = { \t.clocks\t\t\t= { \t\t\t{1, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source2, -\t.platdata_size\t= sizeof(dtv_phandle_source2), +\t.plat\t= &dtv_phandle_source2, +\t.plat_size\t= sizeof(dtv_phandle_source2), +\t.parent_idx\t= -1, +}; + +/* Node /phandle-target index 1 */ +static struct dtd_target dtv_phandle_target = { +}; +U_BOOT_DRVINFO(phandle_target) = { +\t.name\t\t= "target", +\t.plat\t= &dtv_phandle_target, +\t.plat_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_cd_gpio(self): """Test that phandle targets are generated when unsing cd-gpios""" dtb_file = get_dtb_file('dtoc_test_phandle_cd_gpios.dts') output = tools.GetOutputFilename('output') - dtb_platdata.run_steps(['platdata'], dtb_file, False, output, True) + dtb_platdata.run_steps(['platdata'], dtb_file, False, output, [], True) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /phandle2-target index 0 */ static struct dtd_target dtv_phandle2_target = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(phandle2_target) = { +U_BOOT_DRVINFO(phandle2_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle2_target, -\t.platdata_size\t= sizeof(dtv_phandle2_target), +\t.plat\t= &dtv_phandle2_target, +\t.plat_size\t= sizeof(dtv_phandle2_target), \t.parent_idx\t= -1, }; @@ -523,21 +521,10 @@ U_BOOT_DEVICE(phandle2_target) = { static struct dtd_target dtv_phandle3_target = { \t.intval\t\t\t= 0x2, }; -U_BOOT_DEVICE(phandle3_target) = { -\t.name\t\t= "target", -\t.platdata\t= &dtv_phandle3_target, -\t.platdata_size\t= sizeof(dtv_phandle3_target), -\t.parent_idx\t= -1, -}; - -/* Node /phandle-target index 4 */ -static struct dtd_target dtv_phandle_target = { -\t.intval\t\t\t= 0x0, -}; -U_BOOT_DEVICE(phandle_target) = { +U_BOOT_DRVINFO(phandle3_target) = { \t.name\t\t= "target", -\t.platdata\t= &dtv_phandle_target, -\t.platdata_size\t= sizeof(dtv_phandle_target), +\t.plat\t= &dtv_phandle3_target, +\t.plat_size\t= sizeof(dtv_phandle3_target), \t.parent_idx\t= -1, }; @@ -549,10 +536,10 @@ static struct dtd_source dtv_phandle_source = { \t\t\t{1, {12, 13}}, \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source) = { +U_BOOT_DRVINFO(phandle_source) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source, -\t.platdata_size\t= sizeof(dtv_phandle_source), +\t.plat\t= &dtv_phandle_source, +\t.plat_size\t= sizeof(dtv_phandle_source), \t.parent_idx\t= -1, }; @@ -561,15 +548,24 @@ static struct dtd_source dtv_phandle_source2 = { \t.cd_gpios\t\t= { \t\t\t{4, {}},}, }; -U_BOOT_DEVICE(phandle_source2) = { +U_BOOT_DRVINFO(phandle_source2) = { \t.name\t\t= "source", -\t.platdata\t= &dtv_phandle_source2, -\t.platdata_size\t= sizeof(dtv_phandle_source2), +\t.plat\t= &dtv_phandle_source2, +\t.plat_size\t= sizeof(dtv_phandle_source2), +\t.parent_idx\t= -1, +}; + +/* Node /phandle-target index 4 */ +static struct dtd_target dtv_phandle_target = { +\t.intval\t\t\t= 0x0, +}; +U_BOOT_DRVINFO(phandle_target) = { +\t.name\t\t= "target", +\t.plat\t= &dtv_phandle_target, +\t.plat_size\t= sizeof(dtv_phandle_target), \t.parent_idx\t= -1, }; -void dm_populate_phandle_data(void) { -} ''', data) def test_phandle_bad(self): @@ -577,20 +573,20 @@ void dm_populate_phandle_data(void) { dtb_file = get_dtb_file('dtoc_test_phandle_bad.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Cannot parse 'clocks' in node 'phandle-source'", - str(e.exception)) + str(exc.exception)) def test_phandle_bad2(self): """Test a phandle target missing its #*-cells property""" dtb_file = get_dtb_file('dtoc_test_phandle_bad2.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Node 'phandle-target' has no cells property", - str(e.exception)) + str(exc.exception)) def test_addresses64(self): """Test output from a node with a 'reg' property with na=2, ns=2""" @@ -599,7 +595,7 @@ void dm_populate_phandle_data(void) { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -614,15 +610,15 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat\t= &dtv_test1, +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -630,10 +626,10 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat\t= &dtv_test2, +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -641,14 +637,14 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x1234567890123456, 0x9876543210987654, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", -\t.platdata\t= &dtv_test3, -\t.platdata_size\t= sizeof(dtv_test3), +\t.plat\t= &dtv_test3, +\t.plat_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses32(self): """Test output from a node with a 'reg' property with na=1, ns=1""" @@ -657,7 +653,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt32_t\t\treg[2]; }; @@ -669,15 +665,15 @@ struct dtd_test2 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat\t= &dtv_test1, +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -685,14 +681,14 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x12345678, 0x98765432, 0x2, 0x3}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat\t= &dtv_test2, +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses64_32(self): """Test output from a node with a 'reg' property with na=2, ns=1""" @@ -701,7 +697,7 @@ U_BOOT_DEVICE(test2) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -716,15 +712,15 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x123400000000, 0x5678}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat\t= &dtv_test1, +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -732,10 +728,10 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x1234567890123456, 0x98765432}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat\t= &dtv_test2, +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -743,14 +739,14 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x1234567890123456, 0x98765432, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", -\t.platdata\t= &dtv_test3, -\t.platdata_size\t= sizeof(dtv_test3), +\t.plat\t= &dtv_test3, +\t.plat_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_addresses32_64(self): """Test output from a node with a 'reg' property with na=1, ns=2""" @@ -759,7 +755,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_test1 { \tfdt64_t\t\treg[2]; }; @@ -774,15 +770,15 @@ struct dtd_test3 { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /test1 index 0 */ static struct dtd_test1 dtv_test1 = { \t.reg\t\t\t= {0x1234, 0x567800000000}, }; -U_BOOT_DEVICE(test1) = { +U_BOOT_DRVINFO(test1) = { \t.name\t\t= "test1", -\t.platdata\t= &dtv_test1, -\t.platdata_size\t= sizeof(dtv_test1), +\t.plat\t= &dtv_test1, +\t.plat_size\t= sizeof(dtv_test1), \t.parent_idx\t= -1, }; @@ -790,10 +786,10 @@ U_BOOT_DEVICE(test1) = { static struct dtd_test2 dtv_test2 = { \t.reg\t\t\t= {0x12345678, 0x9876543210987654}, }; -U_BOOT_DEVICE(test2) = { +U_BOOT_DRVINFO(test2) = { \t.name\t\t= "test2", -\t.platdata\t= &dtv_test2, -\t.platdata_size\t= sizeof(dtv_test2), +\t.plat\t= &dtv_test2, +\t.plat_size\t= sizeof(dtv_test2), \t.parent_idx\t= -1, }; @@ -801,34 +797,35 @@ U_BOOT_DEVICE(test2) = { static struct dtd_test3 dtv_test3 = { \t.reg\t\t\t= {0x12345678, 0x9876543210987654, 0x2, 0x3}, }; -U_BOOT_DEVICE(test3) = { +U_BOOT_DRVINFO(test3) = { \t.name\t\t= "test3", -\t.platdata\t= &dtv_test3, -\t.platdata_size\t= sizeof(dtv_test3), +\t.plat\t= &dtv_test3, +\t.plat_size\t= sizeof(dtv_test3), \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) def test_bad_reg(self): """Test that a reg property with an invalid type generates an error""" # Capture stderr since dtc will emit warnings for this file dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn("Node 'spl-test' reg property is not an int", - str(e.exception)) + str(exc.exception)) def test_bad_reg2(self): """Test that a reg property with an invalid cell count is detected""" # Capture stderr since dtc will emit warnings for this file dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True) output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) - self.assertIn("Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", - str(e.exception)) + self.assertIn( + "Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", + str(exc.exception)) def test_add_prop(self): """Test that a subequent node can add a new property to a struct""" @@ -837,7 +834,7 @@ U_BOOT_DEVICE(test3) = { self.run_test(['struct'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(HEADER + ''' + self._check_strings(HEADER + ''' struct dtd_sandbox_spl_test { \tfdt32_t\t\tintarray; \tfdt32_t\t\tintval; @@ -847,15 +844,15 @@ struct dtd_sandbox_spl_test { self.run_test(['platdata'], dtb_file, output) with open(output) as infile: data = infile.read() - self._CheckStrings(C_HEADER + ''' + self._check_strings(C_HEADER + ''' /* Node /spl-test index 0 */ static struct dtd_sandbox_spl_test dtv_spl_test = { \t.intval\t\t\t= 0x1, }; -U_BOOT_DEVICE(spl_test) = { +U_BOOT_DRVINFO(spl_test) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test, -\t.platdata_size\t= sizeof(dtv_spl_test), +\t.plat\t= &dtv_spl_test, +\t.plat_size\t= sizeof(dtv_spl_test), \t.parent_idx\t= -1, }; @@ -863,58 +860,70 @@ U_BOOT_DEVICE(spl_test) = { static struct dtd_sandbox_spl_test dtv_spl_test2 = { \t.intarray\t\t= 0x5, }; -U_BOOT_DEVICE(spl_test2) = { +U_BOOT_DRVINFO(spl_test2) = { \t.name\t\t= "sandbox_spl_test", -\t.platdata\t= &dtv_spl_test2, -\t.platdata_size\t= sizeof(dtv_spl_test2), +\t.plat\t= &dtv_spl_test2, +\t.plat_size\t= sizeof(dtv_spl_test2), \t.parent_idx\t= -1, }; -''' + C_EMPTY_POPULATE_PHANDLE_DATA, data) +''', data) - def testStdout(self): + def test_stdout(self): """Test output to stdout""" dtb_file = get_dtb_file('dtoc_test_simple.dts') - with test_util.capture_sys_output() as (stdout, stderr): - self.run_test(['struct'], dtb_file, '-') + with test_util.capture_sys_output() as (stdout, _): + self.run_test(['struct'], dtb_file, None) + self._check_strings(self.struct_text, stdout.getvalue()) - def testNoCommand(self): + def test_multi_to_file(self): + """Test output of multiple pieces to a single file""" + dtb_file = get_dtb_file('dtoc_test_simple.dts') + output = tools.GetOutputFilename('output') + self.run_test(['all'], dtb_file, output) + data = tools.ReadFile(output, binary=False) + self._check_strings(self.platdata_text + self.struct_text, data) + + def test_no_command(self): """Test running dtoc without a command""" - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test([], '', '') self.assertIn("Please specify a command: struct, platdata", - str(e.exception)) + str(exc.exception)) - def testBadCommand(self): + def test_bad_command(self): """Test running dtoc with an invalid command""" dtb_file = get_dtb_file('dtoc_test_simple.dts') output = tools.GetOutputFilename('output') - with self.assertRaises(ValueError) as e: + with self.assertRaises(ValueError) as exc: self.run_test(['invalid-cmd'], dtb_file, output) - self.assertIn("Unknown command 'invalid-cmd': (use: struct, platdata)", - str(e.exception)) - - def testScanDrivers(self): - """Test running dtoc with additional drivers to scan""" - dtb_file = get_dtb_file('dtoc_test_simple.dts') - output = tools.GetOutputFilename('output') - with test_util.capture_sys_output() as (stdout, stderr): - dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) - - def testUnicodeError(self): - """Test running dtoc with an invalid unicode file + self.assertIn("Unknown command 'invalid-cmd': (use: platdata, struct)", + str(exc.exception)) + + def test_output_conflict(self): + """Test a conflict between and output dirs and output file""" + with self.assertRaises(ValueError) as exc: + dtb_platdata.run_steps(['all'], None, False, 'out', ['cdir'], True) + self.assertIn("Must specify either output or output_dirs, not both", + str(exc.exception)) + + def test_output_dirs(self): + """Test outputting files to a directory""" + # Remove the directory so that files from other tests are not there + tools._RemoveOutputDir() + tools.PrepareOutputDir(None) - To be able to perform this test without adding a weird text file which - would produce issues when using checkpatch.pl or patman, generate the - file at runtime and then process it. - """ + # This should create the .dts and .dtb in the output directory dtb_file = get_dtb_file('dtoc_test_simple.dts') - output = tools.GetOutputFilename('output') - driver_fn = '/tmp/' + next(tempfile._get_candidate_names()) - with open(driver_fn, 'wb+') as df: - df.write(b'\x81') - - with test_util.capture_sys_output() as (stdout, stderr): - dtb_platdata.run_steps(['struct'], dtb_file, False, output, True, - [driver_fn]) + outdir = tools.GetOutputDir() + fnames = glob.glob(outdir + '/*') + self.assertEqual(2, len(fnames)) + + dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True) + fnames = glob.glob(outdir + '/*') + self.assertEqual(4, len(fnames)) + + leafs = set(os.path.basename(fname) for fname in fnames) + self.assertEqual( + {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'}, + leafs) diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index cfe3e04c7a..dc6943f733 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -19,7 +19,7 @@ sys.path.insert(1, os.path.join(our_path, '..')) from dtoc import fdt from dtoc import fdt_util from dtoc.fdt_util import fdt32_to_cpu -from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, BytesToValue +from fdt import Type, BytesToValue import libfdt from patman import command from patman import test_util @@ -46,7 +46,7 @@ def _GetPropertyValue(dtb, node, prop_name): # Add 12, which is sizeof(struct fdt_property), to get to start of data offset = prop.GetOffset() + 12 data = dtb.GetContents()[offset:offset + len(prop.value)] - return prop, [tools.ToChar(x) for x in data] + return prop, [chr(x) for x in data] class TestFdt(unittest.TestCase): @@ -127,7 +127,7 @@ class TestFdt(unittest.TestCase): def testBytesToValue(self): self.assertEqual(BytesToValue(b'this\0is\0'), - (TYPE_STRING, ['this', 'is'])) + (Type.STRING, ['this', 'is'])) class TestNode(unittest.TestCase): """Test operation of the Node class""" @@ -249,46 +249,46 @@ class TestProp(unittest.TestCase): def testMakeProp(self): """Test we can convert all the the types that are supported""" prop = self._ConvertProp('boolval') - self.assertEqual(fdt.TYPE_BOOL, prop.type) + self.assertEqual(Type.BOOL, prop.type) self.assertEqual(True, prop.value) prop = self._ConvertProp('intval') - self.assertEqual(fdt.TYPE_INT, prop.type) + self.assertEqual(Type.INT, prop.type) self.assertEqual(1, fdt32_to_cpu(prop.value)) prop = self._ConvertProp('intarray') - self.assertEqual(fdt.TYPE_INT, prop.type) + self.assertEqual(Type.INT, prop.type) val = [fdt32_to_cpu(val) for val in prop.value] self.assertEqual([2, 3, 4], val) prop = self._ConvertProp('byteval') - self.assertEqual(fdt.TYPE_BYTE, prop.type) + self.assertEqual(Type.BYTE, prop.type) self.assertEqual(5, ord(prop.value)) prop = self._ConvertProp('longbytearray') - self.assertEqual(fdt.TYPE_BYTE, prop.type) + self.assertEqual(Type.BYTE, prop.type) val = [ord(val) for val in prop.value] self.assertEqual([9, 10, 11, 12, 13, 14, 15, 16, 17], val) prop = self._ConvertProp('stringval') - self.assertEqual(fdt.TYPE_STRING, prop.type) + self.assertEqual(Type.STRING, prop.type) self.assertEqual('message', prop.value) prop = self._ConvertProp('stringarray') - self.assertEqual(fdt.TYPE_STRING, prop.type) + self.assertEqual(Type.STRING, prop.type) self.assertEqual(['multi-word', 'message'], prop.value) prop = self._ConvertProp('notstring') - self.assertEqual(fdt.TYPE_BYTE, prop.type) + self.assertEqual(Type.BYTE, prop.type) val = [ord(val) for val in prop.value] self.assertEqual([0x20, 0x21, 0x22, 0x10, 0], val) def testGetEmpty(self): """Tests the GetEmpty() function for the various supported types""" - self.assertEqual(True, fdt.Prop.GetEmpty(fdt.TYPE_BOOL)) - self.assertEqual(chr(0), fdt.Prop.GetEmpty(fdt.TYPE_BYTE)) - self.assertEqual(tools.GetBytes(0, 4), fdt.Prop.GetEmpty(fdt.TYPE_INT)) - self.assertEqual('', fdt.Prop.GetEmpty(fdt.TYPE_STRING)) + self.assertEqual(True, fdt.Prop.GetEmpty(Type.BOOL)) + self.assertEqual(chr(0), fdt.Prop.GetEmpty(Type.BYTE)) + self.assertEqual(tools.GetBytes(0, 4), fdt.Prop.GetEmpty(Type.INT)) + self.assertEqual('', fdt.Prop.GetEmpty(Type.STRING)) def testGetOffset(self): """Test we can get the offset of a property""" @@ -304,13 +304,13 @@ class TestProp(unittest.TestCase): # No action prop2 = node2.props['intval'] prop.Widen(prop2) - self.assertEqual(fdt.TYPE_INT, prop.type) + self.assertEqual(Type.INT, prop.type) self.assertEqual(1, fdt32_to_cpu(prop.value)) # Convert singla value to array prop2 = self.node.props['intarray'] prop.Widen(prop2) - self.assertEqual(fdt.TYPE_INT, prop.type) + self.assertEqual(Type.INT, prop.type) self.assertTrue(isinstance(prop.value, list)) # A 4-byte array looks like a single integer. When widened by a longer diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py new file mode 100644 index 0000000000..7d686530d6 --- /dev/null +++ b/tools/dtoc/test_src_scan.py @@ -0,0 +1,107 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2020 Google LLC +# + +"""Tests for the src_scan module + +This includes unit tests for scanning of the source code +""" + +import os +import shutil +import tempfile +import unittest +from unittest import mock + +from dtoc import src_scan +from patman import test_util +from patman import tools + +# This is a test so is allowed to access private things in the module it is +# testing +# pylint: disable=W0212 + +class TestSrcScan(unittest.TestCase): + """Tests for src_scan""" + @classmethod + def setUpClass(cls): + tools.PrepareOutputDir(None) + + @classmethod + def tearDownClass(cls): + tools.FinaliseOutputDir() + + def test_simple(self): + """Simple test of scanning drivers""" + scan = src_scan.Scanner(None, True, None) + scan.scan_drivers() + self.assertIn('sandbox_gpio', scan._drivers) + self.assertIn('sandbox_gpio_alias', scan._driver_aliases) + self.assertEqual('sandbox_gpio', + scan._driver_aliases['sandbox_gpio_alias']) + self.assertNotIn('sandbox_gpio_alias2', scan._driver_aliases) + + def test_additional(self): + """Test with additional drivers to scan""" + scan = src_scan.Scanner( + None, True, [None, '', 'tools/dtoc/dtoc_test_scan_drivers.cxx']) + scan.scan_drivers() + self.assertIn('sandbox_gpio_alias2', scan._driver_aliases) + self.assertEqual('sandbox_gpio', + scan._driver_aliases['sandbox_gpio_alias2']) + + def test_unicode_error(self): + """Test running dtoc with an invalid unicode file + + To be able to perform this test without adding a weird text file which + would produce issues when using checkpatch.pl or patman, generate the + file at runtime and then process it. + """ + driver_fn = '/tmp/' + next(tempfile._get_candidate_names()) + with open(driver_fn, 'wb+') as fout: + fout.write(b'\x81') + + scan = src_scan.Scanner(None, True, [driver_fn]) + with test_util.capture_sys_output() as (stdout, _): + scan.scan_drivers() + self.assertRegex(stdout.getvalue(), + r"Skipping file '.*' due to unicode error\s*") + + def test_driver(self): + """Test the Driver class""" + drv1 = src_scan.Driver('fred') + drv2 = src_scan.Driver('mary') + drv3 = src_scan.Driver('fred') + self.assertEqual("Driver(name='fred')", str(drv1)) + self.assertEqual(drv1, drv3) + self.assertNotEqual(drv1, drv2) + self.assertNotEqual(drv2, drv3) + + def test_scan_dirs(self): + """Test scanning of source directories""" + def add_file(fname): + pathname = os.path.join(indir, fname) + dirname = os.path.dirname(pathname) + os.makedirs(dirname, exist_ok=True) + tools.WriteFile(pathname, '', binary=False) + fname_list.append(pathname) + + try: + indir = tempfile.mkdtemp(prefix='dtoc.') + + fname_list = [] + add_file('fname.c') + add_file('dir/fname2.c') + + # Mock out scan_driver and check that it is called with the + # expected files + with mock.patch.object(src_scan.Scanner, "scan_driver") as mocked: + scan = src_scan.Scanner(indir, True, None) + scan.scan_drivers() + self.assertEqual(2, len(mocked.mock_calls)) + self.assertEqual(mock.call(fname_list[0]), + mocked.mock_calls[0]) + self.assertEqual(mock.call(fname_list[1]), + mocked.mock_calls[1]) + finally: + shutil.rmtree(indir) diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c new file mode 100644 index 0000000000..270943fc90 --- /dev/null +++ b/tools/mkeficapsule.c @@ -0,0 +1,446 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2018 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include <errno.h> +#include <getopt.h> +#include <malloc.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <linux/types.h> + +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include "fdt_host.h" + +typedef __u8 u8; +typedef __u16 u16; +typedef __u32 u32; +typedef __u64 u64; +typedef __s16 s16; +typedef __s32 s32; + +#define aligned_u64 __aligned_u64 + +#define SIGNATURE_NODENAME "signature" +#define OVERLAY_NODENAME "__overlay__" + +#ifndef __packed +#define __packed __attribute__((packed)) +#endif + +#include <efi.h> +#include <efi_api.h> + +static const char *tool_name = "mkeficapsule"; + +efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; +efi_guid_t efi_guid_image_type_uboot_fit = + EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID; +efi_guid_t efi_guid_image_type_uboot_raw = + EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID; + +static struct option options[] = { + {"fit", required_argument, NULL, 'f'}, + {"raw", required_argument, NULL, 'r'}, + {"index", required_argument, NULL, 'i'}, + {"instance", required_argument, NULL, 'I'}, + {"dtb", required_argument, NULL, 'D'}, + {"public key", required_argument, NULL, 'K'}, + {"overlay", no_argument, NULL, 'O'}, + {"help", no_argument, NULL, 'h'}, + {NULL, 0, NULL, 0}, +}; + +static void print_usage(void) +{ + printf("Usage: %s [options] <output file>\n" + "Options:\n" + + "\t--fit <fit image> new FIT image file\n" + "\t--raw <raw image> new raw image file\n" + "\t--index <index> update image index\n" + "\t--instance <instance> update hardware instance\n" + "\t--public-key <key file> public key esl file\n" + "\t--dtb <dtb file> dtb file\n" + "\t--overlay the dtb file is an overlay\n" + "\t--help print a help message\n", + tool_name); +} + +static int fdt_add_pub_key_data(void *sptr, void *dptr, size_t key_size, + bool overlay) +{ + int parent; + int ov_node; + int frag_node; + int ret = 0; + + if (overlay) { + /* + * The signature would be stored in the + * first fragment node of the overlay + */ + frag_node = fdt_first_subnode(dptr, 0); + if (frag_node == -FDT_ERR_NOTFOUND) { + fprintf(stderr, + "Couldn't find the fragment node: %s\n", + fdt_strerror(frag_node)); + goto done; + } + + ov_node = fdt_subnode_offset(dptr, frag_node, OVERLAY_NODENAME); + if (ov_node == -FDT_ERR_NOTFOUND) { + fprintf(stderr, + "Couldn't find the __overlay__ node: %s\n", + fdt_strerror(ov_node)); + goto done; + } + } else { + ov_node = 0; + } + + parent = fdt_subnode_offset(dptr, ov_node, SIGNATURE_NODENAME); + if (parent == -FDT_ERR_NOTFOUND) { + parent = fdt_add_subnode(dptr, ov_node, SIGNATURE_NODENAME); + if (parent < 0) { + ret = parent; + if (ret != -FDT_ERR_NOSPACE) { + fprintf(stderr, + "Couldn't create signature node: %s\n", + fdt_strerror(parent)); + } + } + } + if (ret) + goto done; + + /* Write the key to the FDT node */ + ret = fdt_setprop(dptr, parent, "capsule-key", + sptr, key_size); + +done: + if (ret) + ret = ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO; + + return ret; +} + +static int add_public_key(const char *pkey_file, const char *dtb_file, + bool overlay) +{ + int ret; + int srcfd = 0; + int destfd = 0; + void *sptr = NULL; + void *dptr = NULL; + off_t src_size; + struct stat pub_key; + struct stat dtb; + + /* Find out the size of the public key */ + srcfd = open(pkey_file, O_RDONLY); + if (srcfd == -1) { + fprintf(stderr, "%s: Can't open %s: %s\n", + __func__, pkey_file, strerror(errno)); + goto err; + } + + ret = fstat(srcfd, &pub_key); + if (ret == -1) { + fprintf(stderr, "%s: Can't stat %s: %s\n", + __func__, pkey_file, strerror(errno)); + goto err; + } + + src_size = pub_key.st_size; + + /* mmap the public key esl file */ + sptr = mmap(0, src_size, PROT_READ, MAP_SHARED, srcfd, 0); + if ((sptr == MAP_FAILED) || (errno != 0)) { + fprintf(stderr, "%s: Failed to mmap %s:%s\n", + __func__, pkey_file, strerror(errno)); + goto err; + } + + /* Open the dest FDT */ + destfd = open(dtb_file, O_RDWR); + if (destfd == -1) { + fprintf(stderr, "%s: Can't open %s: %s\n", + __func__, dtb_file, strerror(errno)); + goto err; + } + + ret = fstat(destfd, &dtb); + if (ret == -1) { + fprintf(stderr, "%s: Can't stat %s: %s\n", + __func__, dtb_file, strerror(errno)); + goto err; + } + + dtb.st_size += src_size + 0x30; + if (ftruncate(destfd, dtb.st_size)) { + fprintf(stderr, "%s: Can't expand %s: %s\n", + __func__, dtb_file, strerror(errno)); + goto err;; + } + + errno = 0; + /* mmap the dtb file */ + dptr = mmap(0, dtb.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, + destfd, 0); + if ((dptr == MAP_FAILED) || (errno != 0)) { + fprintf(stderr, "%s: Failed to mmap %s:%s\n", + __func__, dtb_file, strerror(errno)); + goto err; + } + + if (fdt_check_header(dptr)) { + fprintf(stderr, "%s: Invalid FDT header\n", __func__); + goto err; + } + + ret = fdt_open_into(dptr, dptr, dtb.st_size); + if (ret) { + fprintf(stderr, "%s: Cannot expand FDT: %s\n", + __func__, fdt_strerror(ret)); + goto err; + } + + /* Copy the esl file to the expanded FDT */ + ret = fdt_add_pub_key_data(sptr, dptr, src_size, overlay); + if (ret < 0) { + fprintf(stderr, "%s: Unable to add public key to the FDT\n", + __func__); + goto err; + } + + return 0; + +err: + if (sptr) + munmap(sptr, src_size); + + if (dptr) + munmap(dptr, dtb.st_size); + + if (srcfd >= 0) + close(srcfd); + + if (destfd >= 0) + close(destfd); + + return -1; +} + +static int create_fwbin(char *path, char *bin, efi_guid_t *guid, + unsigned long index, unsigned long instance) +{ + struct efi_capsule_header header; + struct efi_firmware_management_capsule_header capsule; + struct efi_firmware_management_capsule_image_header image; + FILE *f, *g; + struct stat bin_stat; + u8 *data; + size_t size; + u64 offset; + +#ifdef DEBUG + printf("For output: %s\n", path); + printf("\tbin: %s\n\ttype: %pUl\n" bin, guid); + printf("\tindex: %ld\n\tinstance: %ld\n", index, instance); +#endif + + g = fopen(bin, "r"); + if (!g) { + printf("cannot open %s\n", bin); + return -1; + } + if (stat(bin, &bin_stat) < 0) { + printf("cannot determine the size of %s\n", bin); + goto err_1; + } + data = malloc(bin_stat.st_size); + if (!data) { + printf("cannot allocate memory: %lx\n", bin_stat.st_size); + goto err_1; + } + f = fopen(path, "w"); + if (!f) { + printf("cannot open %s\n", path); + goto err_2; + } + header.capsule_guid = efi_guid_fm_capsule; + header.header_size = sizeof(header); + /* TODO: The current implementation ignores flags */ + header.flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET; + header.capsule_image_size = sizeof(header) + + sizeof(capsule) + sizeof(u64) + + sizeof(image) + + bin_stat.st_size; + + size = fwrite(&header, 1, sizeof(header), f); + if (size < sizeof(header)) { + printf("write failed (%lx)\n", size); + goto err_3; + } + + capsule.version = 0x00000001; + capsule.embedded_driver_count = 0; + capsule.payload_item_count = 1; + size = fwrite(&capsule, 1, sizeof(capsule), f); + if (size < (sizeof(capsule))) { + printf("write failed (%lx)\n", size); + goto err_3; + } + offset = sizeof(capsule) + sizeof(u64); + size = fwrite(&offset, 1, sizeof(offset), f); + if (size < sizeof(offset)) { + printf("write failed (%lx)\n", size); + goto err_3; + } + + image.version = 0x00000003; + memcpy(&image.update_image_type_id, guid, sizeof(*guid)); + image.update_image_index = index; + image.update_image_size = bin_stat.st_size; + image.update_vendor_code_size = 0; /* none */ + image.update_hardware_instance = instance; + image.image_capsule_support = 0; + + size = fwrite(&image, 1, sizeof(image), f); + if (size < sizeof(image)) { + printf("write failed (%lx)\n", size); + goto err_3; + } + size = fread(data, 1, bin_stat.st_size, g); + if (size < bin_stat.st_size) { + printf("read failed (%lx)\n", size); + goto err_3; + } + size = fwrite(data, 1, bin_stat.st_size, f); + if (size < bin_stat.st_size) { + printf("write failed (%lx)\n", size); + goto err_3; + } + + fclose(f); + fclose(g); + free(data); + + return 0; + +err_3: + fclose(f); +err_2: + free(data); +err_1: + fclose(g); + + return -1; +} + +/* + * Usage: + * $ mkeficapsule -f <firmware binary> <output file> + */ +int main(int argc, char **argv) +{ + char *file; + char *pkey_file; + char *dtb_file; + efi_guid_t *guid; + unsigned long index, instance; + int c, idx; + int ret; + bool overlay = false; + + file = NULL; + pkey_file = NULL; + dtb_file = NULL; + guid = NULL; + index = 0; + instance = 0; + for (;;) { + c = getopt_long(argc, argv, "f:r:i:I:v:D:K:Oh", options, &idx); + if (c == -1) + break; + + switch (c) { + case 'f': + if (file) { + printf("Image already specified\n"); + return -1; + } + file = optarg; + guid = &efi_guid_image_type_uboot_fit; + break; + case 'r': + if (file) { + printf("Image already specified\n"); + return -1; + } + file = optarg; + guid = &efi_guid_image_type_uboot_raw; + break; + case 'i': + index = strtoul(optarg, NULL, 0); + break; + case 'I': + instance = strtoul(optarg, NULL, 0); + break; + case 'K': + if (pkey_file) { + printf("Public Key already specified\n"); + return -1; + } + pkey_file = optarg; + break; + case 'D': + if (dtb_file) { + printf("DTB file already specified\n"); + return -1; + } + dtb_file = optarg; + break; + case 'O': + overlay = true; + break; + case 'h': + print_usage(); + return 0; + } + } + + /* need a fit image file or raw image file */ + if (!file && !pkey_file && !dtb_file) { + printf("%s: %d\n", __func__, __LINE__); + print_usage(); + return -1; + } + + if (pkey_file && dtb_file) { + ret = add_public_key(pkey_file, dtb_file, overlay); + if (ret == -1) { + printf("Adding public key to the dtb failed\n"); + return -1; + } else { + return 0; + } + } + + if (create_fwbin(argv[optind], file, guid, index, instance) + < 0) { + printf("Creating firmware capsule failed\n"); + return -1; + } + + return 0; +} diff --git a/tools/patman/control.py b/tools/patman/control.py index 2330682df4..ee9717cbf6 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -20,7 +20,7 @@ def setup(): """Do required setup before doing anything""" gitutil.Setup() -def prepare_patches(col, branch, count, start, end, ignore_binary): +def prepare_patches(col, branch, count, start, end, ignore_binary, signoff): """Figure out what patches to generate, then generate them The patch files are written to the current directory, e.g. 0001_xxx.patch @@ -56,7 +56,7 @@ def prepare_patches(col, branch, count, start, end, ignore_binary): to_do = count - end series = patchstream.get_metadata(branch, start, to_do) cover_fname, patch_files = gitutil.CreatePatches( - branch, start, to_do, ignore_binary, series) + branch, start, to_do, ignore_binary, series, signoff) # Fix up the patch files to our liking, and insert the cover letter patchstream.fix_patches(series, patch_files) @@ -163,7 +163,7 @@ def send(args): col = terminal.Color() series, cover_fname, patch_files = prepare_patches( col, args.branch, args.count, args.start, args.end, - args.ignore_binary) + args.ignore_binary, args.add_signoff) ok = check_patches(series, patch_files, args.check_patch, args.verbose) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 74a144dc2d..89072b1ae7 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -237,27 +237,26 @@ class TestFunctional(unittest.TestCase): if 'Cc:' not in prev: break self.assertEqual('To: u-boot@lists.denx.de', prev) - self.assertEqual('Cc: %s' % tools.FromUnicode(stefan), next(lines)) + self.assertEqual('Cc: %s' % stefan, next(lines)) self.assertEqual('Version: 3', next(lines)) self.assertEqual('Prefix:\t RFC', next(lines)) self.assertEqual('Cover: 4 lines', next(lines)) self.assertEqual(' Cc: %s' % self.fred, next(lines)) - self.assertEqual(' Cc: %s' % tools.FromUnicode(self.leb), + self.assertEqual(' Cc: %s' % self.leb, next(lines)) - self.assertEqual(' Cc: %s' % tools.FromUnicode(mel), next(lines)) + self.assertEqual(' Cc: %s' % mel, next(lines)) self.assertEqual(' Cc: %s' % rick, next(lines)) expected = ('Git command: git send-email --annotate ' '--in-reply-to="%s" --to "u-boot@lists.denx.de" ' '--cc "%s" --cc-cmd "%s send --cc-cmd %s" %s %s' % (in_reply_to, stefan, sys.argv[0], cc_file, cover_fname, ' '.join(args))) - self.assertEqual(expected, tools.ToUnicode(next(lines))) + self.assertEqual(expected, next(lines)) - self.assertEqual(('%s %s\0%s' % (args[0], rick, stefan)), - tools.ToUnicode(cc_lines[0])) + self.assertEqual(('%s %s\0%s' % (args[0], rick, stefan)), cc_lines[0]) self.assertEqual( '%s %s\0%s\0%s\0%s' % (args[1], self.fred, self.leb, rick, stefan), - tools.ToUnicode(cc_lines[1])) + cc_lines[1]) expected = ''' This is a test of how the cover @@ -476,7 +475,7 @@ complicated as possible''') with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( col, branch=None, count=-1, start=0, end=0, - ignore_binary=False) + ignore_binary=False, signoff=True) self.assertIsNone(cover_fname) self.assertEqual(2, len(patch_files)) @@ -485,7 +484,7 @@ complicated as possible''') with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( col, branch='second', count=-1, start=0, end=0, - ignore_binary=False) + ignore_binary=False, signoff=True) self.assertIsNotNone(cover_fname) self.assertEqual(3, len(patch_files)) @@ -493,7 +492,7 @@ complicated as possible''') with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( col, branch='second', count=-1, start=0, end=1, - ignore_binary=False) + ignore_binary=False, signoff=True) self.assertIsNotNone(cover_fname) self.assertEqual(2, len(patch_files)) finally: diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 31fb3b2829..bf1271ded7 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -305,7 +305,7 @@ def PruneWorktrees(git_dir): if result.return_code != 0: raise OSError('git worktree prune: %s' % result.stderr) -def CreatePatches(branch, start, count, ignore_binary, series): +def CreatePatches(branch, start, count, ignore_binary, series, signoff = True): """Create a series of patches from the top of the current branch. The patch files are written to the current directory using @@ -323,7 +323,9 @@ def CreatePatches(branch, start, count, ignore_binary, series): """ if series.get('version'): version = '%s ' % series['version'] - cmd = ['git', 'format-patch', '-M', '--signoff'] + cmd = ['git', 'format-patch', '-M' ] + if signoff: + cmd.append('--signoff') if ignore_binary: cmd.append('--no-binary') if series.get('cover'): @@ -383,7 +385,6 @@ def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True): raw += LookupEmail(item, alias, raise_on_error=raise_on_error) result = [] for item in raw: - item = tools.FromUnicode(item) if not item in result: result.append(item) if tag: @@ -494,7 +495,7 @@ send --cc-cmd cc-fname" cover p1 p2' if smtp_server: cmd.append('--smtp-server=%s' % smtp_server) if in_reply_to: - cmd.append('--in-reply-to="%s"' % tools.FromUnicode(in_reply_to)) + cmd.append('--in-reply-to="%s"' % in_reply_to) if thread: cmd.append('--thread') diff --git a/tools/patman/main.py b/tools/patman/main.py index 342fd446a1..c4e4d80d42 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -81,6 +81,8 @@ send.add_argument('--no-check', action='store_false', dest='check_patch', help="Don't check for patch compliance") send.add_argument('--no-tags', action='store_false', dest='process_tags', default=True, help="Don't process subject tags as aliases") +send.add_argument('--no-signoff', action='store_false', dest='add_signoff', + default=True, help="Don't add Signed-off-by to patches") send.add_argument('--smtp-server', type=str, help="Specify the SMTP server to 'git send-email'") diff --git a/tools/patman/series.py b/tools/patman/series.py index 1d92bdb910..a6746e87c4 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -272,7 +272,6 @@ class Series(dict): for x in set(cc) & set(settings.bounces): print(col.Color(col.YELLOW, 'Skipping "%s"' % x)) cc = set(cc) - set(settings.bounces) - cc = [tools.FromUnicode(m) for m in cc] if limit is not None: cc = cc[:limit] all_ccs += cc @@ -281,11 +280,10 @@ class Series(dict): if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) - cover_cc = [tools.FromUnicode(m) for m in cover_cc] cover_cc = list(set(cover_cc + all_ccs)) if limit is not None: cover_cc = cover_cc[:limit] - cc_list = '\0'.join([tools.ToUnicode(x) for x in sorted(cover_cc)]) + cc_list = '\0'.join([x for x in sorted(cover_cc)]) print(cover_fname, cc_list, file=fd) fd.close() diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 8c10eab264..13c1ee4f56 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -23,7 +23,12 @@ _default_settings = { "u-boot": {}, "linux": { "process_tags": "False", - } + }, + "gcc": { + "process_tags": "False", + "add_signoff": "False", + "check_patch": "False", + }, } class _ProjectConfigParser(ConfigParser.SafeConfigParser): @@ -112,7 +117,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser): val = ConfigParser.SafeConfigParser.get( self, section, option, *args, **kwargs ) - return tools.ToUnicode(val) + return val def items(self, section, *args, **kwargs): """Extend SafeConfigParser to add project_section to section. @@ -147,8 +152,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser): item_dict = dict(top_items) item_dict.update(project_items) - return {(tools.ToUnicode(item), tools.ToUnicode(val)) - for item, val in item_dict.items()} + return {(item, val) for item, val in item_dict.items()} def ReadGitAliases(fname): """Read a git alias file. This is in the form used by git: diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py index 1f7c38c4e9..a4fec1d4c1 100644 --- a/tools/patman/test_checkpatch.py +++ b/tools/patman/test_checkpatch.py @@ -411,6 +411,34 @@ index 0000000..2234c87 pm.add_line('common/main.c', 'if (CONFIG_IS_ENABLED(CONFIG_CLK))') self.checkSingleMessage(pm, 'CONFIG_IS_ENABLED_CONFIG', 'error') + def check_struct(self, auto, suffix, warning): + """Check one of the warnings for struct naming + + Args: + auto: Auto variable name, e.g. 'per_child_auto' + suffix: Suffix to expect on member, e.g. '_priv' + warning: Warning name, e.g. 'PRIV_AUTO' + """ + pm = PatchMaker() + pm.add_line('common/main.c', '.%s = sizeof(struct(fred)),' % auto) + pm.add_line('common/main.c', '.%s = sizeof(struct(mary%s)),' % + (auto, suffix)) + self.checkSingleMessage( + pm, warning, "struct 'fred' should have a %s suffix" % suffix) + + def testDmDriverAuto(self): + """Check for the correct suffix on 'struct driver' auto members""" + self.check_struct('priv_auto', '_priv', 'PRIV_AUTO') + self.check_struct('plat_auto', '_plat', 'PLAT_AUTO') + self.check_struct('per_child_auto', '_priv', 'CHILD_PRIV_AUTO') + self.check_struct('per_child_plat_auto', '_plat', 'CHILD_PLAT_AUTO') + + def testDmUclassAuto(self): + """Check for the correct suffix on 'struct uclass' auto members""" + # Some of these are omitted since they match those from struct driver + self.check_struct('per_device_auto', '_priv', 'DEVICE_PRIV_AUTO') + self.check_struct('per_device_plat_auto', '_plat', 'DEVICE_PLAT_AUTO') + if __name__ == "__main__": unittest.main() diff --git a/tools/patman/tools.py b/tools/patman/tools.py index 05b1a1d4b0..d8e01a3e60 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -94,6 +94,14 @@ def GetOutputFilename(fname): """ return os.path.join(outdir, fname) +def GetOutputDir(): + """Return the current output directory + + Returns: + str: The output directory + """ + return outdir + def _FinaliseForTest(): """Remove the output directory (for use by tests)""" global outdir @@ -415,8 +423,6 @@ def WriteFile(fname, data, binary=True): def GetBytes(byte, size): """Get a string of bytes of a given size - This handles the unfortunate different between Python 2 and Python 2. - Args: byte: Numeric byte value to use size: Size of bytes/string to return @@ -424,81 +430,7 @@ def GetBytes(byte, size): Returns: A bytes type with 'byte' repeated 'size' times """ - if sys.version_info[0] >= 3: - data = bytes([byte]) * size - else: - data = chr(byte) * size - return data - -def ToUnicode(val): - """Make sure a value is a unicode string - - This allows some amount of compatibility between Python 2 and Python3. For - the former, it returns a unicode object. - - Args: - val: string or unicode object - - Returns: - unicode version of val - """ - if sys.version_info[0] >= 3: - return val - return val if isinstance(val, unicode) else val.decode('utf-8') - -def FromUnicode(val): - """Make sure a value is a non-unicode string - - This allows some amount of compatibility between Python 2 and Python3. For - the former, it converts a unicode object to a string. - - Args: - val: string or unicode object - - Returns: - non-unicode version of val - """ - if sys.version_info[0] >= 3: - return val - return val if isinstance(val, str) else val.encode('utf-8') - -def ToByte(ch): - """Convert a character to an ASCII value - - This is useful because in Python 2 bytes is an alias for str, but in - Python 3 they are separate types. This function converts the argument to - an ASCII value in either case. - - Args: - ch: A string (Python 2) or byte (Python 3) value - - Returns: - integer ASCII value for ch - """ - return ord(ch) if type(ch) == str else ch - -def ToChar(byte): - """Convert a byte to a character - - This is useful because in Python 2 bytes is an alias for str, but in - Python 3 they are separate types. This function converts an ASCII value to - a value with the appropriate type in either case. - - Args: - byte: A byte or str value - """ - return chr(byte) if type(byte) != str else byte - -def ToChars(byte_list): - """Convert a list of bytes to a str/bytes type - - Args: - byte_list: List of ASCII values representing the string - - Returns: - string made by concatenating all the ASCII values - """ - return ''.join([chr(byte) for byte in byte_list]) + return bytes([byte]) * size def ToBytes(string): """Convert a str type into a bytes type @@ -507,12 +439,9 @@ def ToBytes(string): string: string to convert Returns: - Python 3: A bytes type - Python 2: A string type + A bytes type """ - if sys.version_info[0] >= 3: - return string.encode('utf-8') - return string + return string.encode('utf-8') def ToString(bval): """Convert a bytes type into a str type diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c new file mode 100644 index 0000000000..a5299eb6a1 --- /dev/null +++ b/tools/sunxi_egon.c @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2018 Arm Ltd. + */ + +#include "imagetool.h" +#include <image.h> + +#include <sunxi_image.h> + +/* + * NAND requires 8K padding. SD/eMMC gets away with 512 bytes, + * but let's use the larger padding to cover both. + */ +#define PAD_SIZE 8192 + +static int egon_check_params(struct image_tool_params *params) +{ + /* We just need a binary image file. */ + return !params->dflag; +} + +static int egon_verify_header(unsigned char *ptr, int image_size, + struct image_tool_params *params) +{ + const struct boot_file_head *header = (void *)ptr; + uint32_t length; + + /* First 4 bytes must be an ARM branch instruction. */ + if ((le32_to_cpu(header->b_instruction) & 0xff000000) != 0xea000000) + return EXIT_FAILURE; + + if (memcmp(header->magic, BOOT0_MAGIC, sizeof(header->magic))) + return EXIT_FAILURE; + + length = le32_to_cpu(header->length); + /* Must be at least 512 byte aligned. */ + if (length & 511) + return EXIT_FAILURE; + + /* + * Image could also contain U-Boot proper, so could be bigger. + * But it must not be shorter. + */ + if (image_size < length) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} + +static void egon_print_header(const void *buf) +{ + const struct boot_file_head *header = buf; + + printf("Allwinner eGON image, size: %d bytes\n", + le32_to_cpu(header->length)); + + if (memcmp(header->spl_signature, SPL_SIGNATURE, 3)) + return; + + printf("\tSPL header version %d.%d\n", + header->spl_signature[3] >> SPL_MINOR_BITS, + header->spl_signature[3] & ((1U << SPL_MINOR_BITS) - 1)); + if (header->spl_signature[3] >= SPL_DT_HEADER_VERSION) { + uint32_t dt_name_offs = le32_to_cpu(header->dt_name_offset); + + if (dt_name_offs > 0) + printf("\tDT name: %s\n", (char *)buf + dt_name_offs); + } +} + +static void egon_set_header(void *buf, struct stat *sbuf, int infd, + struct image_tool_params *params) +{ + struct boot_file_head *header = buf; + uint32_t *buf32 = buf; + uint32_t checksum = 0, value; + int i; + + /* Generate an ARM branch instruction to jump over the header. */ + value = 0xea000000 | (sizeof(struct boot_file_head) / 4 - 2); + header->b_instruction = cpu_to_le32(value); + + memcpy(header->magic, BOOT0_MAGIC, sizeof(header->magic)); + header->check_sum = cpu_to_le32(BROM_STAMP_VALUE); + header->length = cpu_to_le32(params->file_size); + + memcpy(header->spl_signature, SPL_SIGNATURE, 3); + header->spl_signature[3] = SPL_ENV_HEADER_VERSION; + + /* If an image name has been provided, use it as the DT name. */ + if (params->imagename && params->imagename[0]) { + if (strlen(params->imagename) > sizeof(header->string_pool) - 1) + printf("WARNING: DT name too long for SPL header!\n"); + else { + strcpy((char *)header->string_pool, params->imagename); + value = offsetof(struct boot_file_head, string_pool); + header->dt_name_offset = cpu_to_le32(value); + header->spl_signature[3] = SPL_DT_HEADER_VERSION; + } + } + + /* Calculate the checksum. Yes, it's that simple. */ + for (i = 0; i < sbuf->st_size / 4; i++) + checksum += le32_to_cpu(buf32[i]); + header->check_sum = cpu_to_le32(checksum); +} + +static int egon_check_image_type(uint8_t type) +{ + return type == IH_TYPE_SUNXI_EGON ? 0 : 1; +} + +static int egon_vrec_header(struct image_tool_params *params, + struct image_type_params *tparams) +{ + tparams->hdr = calloc(sizeof(struct boot_file_head), 1); + + /* Return padding to 8K blocks. */ + return ALIGN(params->file_size, PAD_SIZE) - params->file_size; +} + +U_BOOT_IMAGE_TYPE( + sunxi_egon, + "Allwinner eGON Boot Image support", + sizeof(struct boot_file_head), + NULL, + egon_check_params, + egon_verify_header, + egon_print_header, + egon_set_header, + NULL, + egon_check_image_type, + NULL, + egon_vrec_header +); diff --git a/tools/zynqmp_pm_cfg_obj_convert.py b/tools/zynqmp_pm_cfg_obj_convert.py index dd27f47921..0a44710e1e 100755 --- a/tools/zynqmp_pm_cfg_obj_convert.py +++ b/tools/zynqmp_pm_cfg_obj_convert.py @@ -289,7 +289,7 @@ code = in_file.read() code = re.sub('//.*?\n|/\*.*?\*/', '', code, flags=re.DOTALL) # remove everything outside the XPm_ConfigObject array definition -code = re.search('const u32 XPm_ConfigObject.*= {\n(.*)};', +code = re.search('const u32 XPm_ConfigObject.*=.*{\n(.*)};', code, flags=re.DOTALL).group(1) # Process each comma-separated array item |