dm: Add support for a 'live' device tree
Subsystems (33)
v3 cover dm: Add support for a 'live' device tree
(this is series 2 of 3 for live tree support - the final series will fully convert a real board and provide size comparisons)
So far U-Boot uses a 'flat' device tree, which means that it is decoded on the fly as needed. This uses the libfdt library and avoids needing extra memory for additional tables.
For some time there has been discussion about moving U-Boot to use a 'live' tree, where the device tree is decoded at start-up into a set of hierarchical structures with pointers.
The advantages are:
- It is somewhat faster to access (in particular scanning and looking for a parent)
- It permits the device tree to be changed at run-time (this is not recommended with the flat device tree since devices store the offset of their device tree node and updating the tree may invalidate that). Enabling this feature could be useful for overlays, for example.
- It allows nodes to be referenced by a single pointer, instead of the current device tree pointer plus offset
The disadvantages are:
- It requires more memory
- It takes (a little) time to build the live tree
- It adds more complexity under the hood, including an additional abstraction layer
This series is an attempt to introduce a useful live tree feature into U-Boot. There are many options and trade-offs. This series is the culmination of quite a bit of thought and experimentation.
The approach used in this series is:
- Before relocation the flat tree is used, to avoid extra memory usage and time. In general, there is not much access before relocation since most drivers are not started up. So there is little benefit in having a live tree
- After relocation the live tree is built. At this point the CPU should be running quickly and there is plenty of memory. All available devices will be bound so the overhead of building the live tree may be outweighed by its greater efficiency.
As a simplification, this series supports only one tree or the other. When the live tree is active, the flat tree cannot be used. That makes it easy to know the current state and avoids confusion over mixing offset and node pointers.
Some drivers will need to be used both before and after relocation. This means that they must support both the flat and the live tree. To support this, the concept of a node 'reference' is defined. A reference can hold either a node offset (for the flat tree) or a node pointer (for the live tree). This allows drivers to access values from the tree regardless of which tree is in use.
In addition, since most device tree access happens in the context of a device (struct udevice), a new 'dev_read' layer is provided to read device tree configuration associated with a device. This encapsulates the details of exactly how this information is read.
I have taken the view that code compatibility with Linux is desirable. So the of_access.c file brings in code from Linux with very little modification. As new access methods are needed we should be able to bring in more code and avoid writing it ourselves in U-Boot.
Conversion of drivers and subsystems to support the live tree (as well as flat tree) is fairly easy. Patch are included to add support to subsystems for which tests exist, to ensure that 'make tests' still passes.
Future work will enable the live device tree on a real board and include code size comparisons.
For now here is a code size comparison for firefly (within inlining of ofnode which I intend to implement):
arm: (for 1/1 boards) all +268.0 bss -24.0 data -4.0 spl/u-boot-spl:all +240.0 spl/u-boot-spl:text +240.0 text +296.0
firefly-rk3288 : all +268 bss -24 data -4 spl/u-boot-spl:all +240 spl/u-boot-spl:text +240 text +296
u-boot: add: 18/-4, grow: 2/-22 bytes: 764/-490 (274)
function old new delta
gpio_request_tail - 132 +132
ofnode_parse_phandle_with_args - 66 +66
uclass_find_device_by_ofnode - 64 +64
ofnode_pre_reloc - 64 +64
ofnode_read_string - 52 +52
fdt_support_default_count_cells - 52 +52
ofnode_read_u32 - 48 +48
gpio_request_by_name 32 72 +40
ofnode_read_size - 34 +34
uclass_get_device_by_ofnode - 28 +28
ofnode_read_u32_array - 28 +28
ofnode_read_bool - 26 +26
ofnode_read_prop - 24 +24
ofnode_get_addr_size - 24 +24
ofnode_read_u32_default - 22 +22
ofnode_find_subnode - 18 +18
ofnode_next_subnode - 14 +14
ofnode_first_subnode - 14 +14
ofnode_get_name - 12 +12
dm_init_and_scan 42 44 +2
uclass_get_device_by_phandle 106 104 -2
spi_child_post_bind 32 30 -2
i2c_child_post_bind 32 30 -2
spi_post_probe 36 32 -4
spi_flash_scan 520 516 -4
serial_init 212 208 -4
i2c_post_probe 48 44 -4
clk_fixed_rate_ofdata_to_platdata 36 32 -4
act8846_bind 48 44 -4
simple_bus_post_bind 60 52 -8
lists_bind_fdt 240 232 -8
i2c_chip_ofdata_to_platdata 64 56 -8
clk_get_by_index 108 100 -8
usb_child_post_bind 92 80 -12
regmap_init_mem 228 216 -12
fixed_regulator_ofdata_to_platdata 108 96 -12
pmic_bind_children 158 144 -14
spi_slave_ofdata_to_platdata 256 240 -16
pinconfig_post_bind 136 116 -20
led_gpio_bind 108 88 -20
regulator_post_bind 148 124 -24
gpio_request_by_name_nodev 28 - -28
fdtdec_get_uint 30 - -30
regulator_pre_probe 220 184 -36
of_bus_default_count_cells 52 - -52
_gpio_request_by_name_nodev 152 - -152
spl-u-boot-spl: add: 8/-1, grow: 1/-5 bytes: 300/-56 (244)
function old new delta
ofnode_parse_phandle_with_args - 66 +66
uclass_find_device_by_ofnode - 64 +64
ofnode_read_u32 - 48 +48
ofnode_read_size - 34 +34
uclass_get_device_by_ofnode - 28 +28
ofnode_read_prop - 24 +24
ofnode_read_u32_default - 22 +22
ofnode_get_name - 12 +12
dm_init_and_scan 42 44 +2
dm_scan_fdt_node 96 94 -2
clk_fixed_rate_ofdata_to_platdata 36 32 -4
lists_bind_fdt 224 216 -8
clk_get_by_index 108 100 -8
regmap_init_mem 220 208 -12
device_bind 22 - -22
(no errors to report)
Changes in v3:
- Adjust header includes in ofnode.h to make it stand alone
- Fix up the fdtaddr.h header guard to avoid conflicts
- Clear the watchdog state also
- Add new patch to move pmic header out of config file
Changes in v2:
- Rewrite based on testing and refining the v1 series
- Convert various subsystems to enable sandbox tests to pass
Simon Glass (72):
dm: core: Set return value first in lists_bind_fdt() Update WARN_ON() to return a value
dm: core: Add livetree definitions
dm: core: Add livetree access functions
dm: Add a function to create a 'live' device tree
dm: Build a live tree after relocation
dm: core: Rename of_device_is_compatible()
dm: core: Add operations on device tree references
dm: core: Add livetree address functions
fdt: Update fdt_get_base_address() to use const
dm: core: Add address operations on device tree references
dm: core: Add a place to put extra device-tree reading functions
dm: core: Add device-based 'read' functions to access DT
dm: core: Implement live tree 'read' functions
dm: core: Allow binding a device from a live tree
dm: core: Update lists_bind_fdt() to use ofnode
dm: core: Update device_bind_driver_to_node() to use ofnode
dm: core: Scan the live tree when setting up driver model
dm: core: Add a way to find a device by ofnode
dm: regmap: Add support for livetree
dm: simple-bus: Add support for livetree
dm: core: Update uclass_find_device_by_phandle() for livetree
sandbox: Add a way to reset sandbox state for tests
dm: test: Move test running code into a separate function
dm: test: Show the test filename when running
dm: test: Add support for running tests with livetree
dm: core: Run tests with both livetree and flat tree
dm: gpio: Refactor to prepare for live tree support
dm: gpio: Drop blank line in gpio_xlate_offs_flags() comment
dm: gpio: sandbox: Use dev_read...() functions to access DT
dm: gpio: Add live tree support
cros_ec: Fix debug() statement in ec_command_inptr()
cros_ec: Convert to support live tree
sandbox: Add a new sandbox_flattree board
test: Update 'make test' to run more tests
fdt: Rename a few functions in fdt_support
dm: Add more livetree helpers and definitions
string: Add strchrnul()
string: Add strcspn()
dm: i2c: Convert uclass to livetree
samsung: Move pmic header out of config file
dm: pmic: Convert uclass to livetree
sandbox: pmic: Convert pmic emulator to support livetree
dm: regulator: Convert regulator uclass to support livetree
dm: regulator: Update fixed regulator to support livetree.
dm: mmc: Convert uclass to livetree
dm: adc: Convert uclass to livetree
dm: usb: Convert uclass to livetree
sandbox: usb: Convert emulators to livetree
clk: Modify xlate() method for livetree
dm: clk: Update uclass to support livetree
dm: clk: fixed: Update to support livetree
dm: test: Separate out the bus DT offset test
dm: test: Disable the fdt_offset test with livetree
dm: phy: Update tests to use ut_asserteq()
dm: mailbox: Update uclass to support livetree
dm: phy: Update uclass to support livetree
sandbox: phy: Update driver for livetree
dm: power-domain: Update uclass to support livetree
dm: reset: Update uclass to support livetree
dm: pci: Update uclass to support livetree
dm: Update the I2C eeprom driver for livetree
cros_ec: Update the cros_ec keyboard driver to livetree
dm: spi: Convert uclass to livetree
dm: sandbox: i2c: Drop fdtdec.h header
dm: sandbox: i2c_rtc: Drop fdtdec.h header
dm: spi-flash: Convert uclass to livetree
dm: sandbox: spi: Convert driver to support livetree
dm: sandbox: sysreset: Convert driver to livetree
dm: test: Fix nit with position of backslash
dm: gpio: power: Convert pm8916 drivers to livetree
sandbox: Move to use live tree
arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 4 +- arch/arm/mach-tegra/tegra186/nvtboot_mem.c | 4 +- arch/sandbox/cpu/state.c | 15 +- arch/sandbox/include/asm/state.h | 7 + board/qualcomm/dragonboard410c/dragonboard410c.c | 12 +- board/samsung/common/board.c | 4 +- board/samsung/common/exynos5-dt.c | 2 +- board/samsung/common/misc.c | 1 + board/sandbox/MAINTAINERS | 7 + common/board_r.c | 12 + common/fdt_support.c | 28 +- configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 179 ++++++ drivers/adc/adc-uclass.c | 14 +- drivers/clk/at91/pmc.c | 4 +- drivers/clk/at91/pmc.h | 2 +- drivers/clk/clk-uclass.c | 14 +- drivers/clk/clk_fixed_rate.c | 5 +- drivers/clk/clk_stm32f7.c | 3 +- drivers/core/Kconfig | 4 + drivers/core/Makefile | 5 + drivers/core/device.c | 20 +- drivers/core/lists.c | 29 +- drivers/core/of_access.c | 735 +++++++++++++++++++++++ drivers/core/of_addr.c | 359 +++++++++++ drivers/core/of_extra.c | 37 ++ drivers/core/ofnode.c | 579 ++++++++++++++++++ drivers/core/read.c | 140 +++++ drivers/core/regmap.c | 37 +- drivers/core/root.c | 60 +- drivers/core/simple-bus.c | 3 +- drivers/core/uclass.c | 42 +- drivers/cpu/cpu-uclass.c | 6 +- drivers/firmware/psci.c | 4 +- drivers/gpio/74x164_gpio.c | 2 +- drivers/gpio/gpio-uclass.c | 82 +-- drivers/gpio/pca953x_gpio.c | 2 +- drivers/gpio/pm8916_gpio.c | 8 +- drivers/gpio/sandbox.c | 12 +- drivers/gpio/sunxi_gpio.c | 2 +- drivers/gpio/tegra186_gpio.c | 2 +- drivers/gpio/tegra_gpio.c | 2 +- drivers/i2c/i2c-uclass.c | 28 +- drivers/i2c/muxes/i2c-mux-uclass.c | 11 +- drivers/i2c/mxc_i2c.c | 12 +- drivers/i2c/sandbox_i2c.c | 1 - drivers/input/cros_ec_keyb.c | 24 +- drivers/input/key_matrix.c | 19 +- drivers/input/tegra-kbc.c | 3 +- drivers/led/led_bcm6328.c | 2 +- drivers/led/led_bcm6358.c | 2 +- drivers/led/led_gpio.c | 13 +- drivers/mailbox/mailbox-uclass.c | 20 +- drivers/mailbox/tegra-hsp.c | 2 +- drivers/misc/cros_ec.c | 36 +- drivers/misc/cros_ec_sandbox.c | 23 +- drivers/misc/i2c_eeprom_emul.c | 7 +- drivers/misc/tegra186_bpmp.c | 6 +- drivers/misc/tegra_car.c | 4 +- drivers/mmc/fsl_esdhc.c | 6 +- drivers/mmc/mmc-uclass.c | 3 +- drivers/mmc/s5p_sdhci.c | 8 +- drivers/mmc/xenon_sdhci.c | 2 +- drivers/mtd/altera_qspi.c | 2 +- drivers/mtd/cfi_flash.c | 2 +- drivers/mtd/nand/sunxi_nand.c | 2 +- drivers/mtd/nand/tegra_nand.c | 4 +- drivers/mtd/pic32_flash.c | 2 +- drivers/mtd/spi/sandbox.c | 6 +- drivers/mtd/spi/spi_flash.c | 7 +- drivers/net/altera_tse.c | 2 +- drivers/net/cpsw-common.c | 4 +- drivers/net/keystone_net.c | 6 +- drivers/net/mvneta.c | 2 +- drivers/net/pic32_eth.c | 3 +- drivers/pci/pci-uclass.c | 26 +- drivers/phy/marvell/comphy_core.c | 4 +- drivers/phy/phy-uclass.c | 21 +- drivers/phy/sandbox-phy.c | 3 +- drivers/pinctrl/pinctrl-uclass.c | 15 +- drivers/power/domain/power-domain-uclass.c | 19 +- drivers/power/pmic/act8846.c | 8 +- drivers/power/pmic/i2c_pmic_emul.c | 6 +- drivers/power/pmic/lp873x.c | 12 +- drivers/power/pmic/max77686.c | 8 +- drivers/power/pmic/palmas.c | 16 +- drivers/power/pmic/pfuze100.c | 8 +- drivers/power/pmic/pm8916.c | 2 +- drivers/power/pmic/pmic-uclass.c | 22 +- drivers/power/pmic/rk8xx.c | 8 +- drivers/power/pmic/s5m8767.c | 7 +- drivers/power/pmic/sandbox.c | 2 +- drivers/power/pmic/tps65090.c | 8 +- drivers/power/regulator/fixed.c | 17 +- drivers/power/regulator/regulator-uclass.c | 39 +- drivers/reset/reset-uclass.c | 21 +- drivers/rtc/i2c_rtc_emul.c | 1 - drivers/serial/serial-uclass.c | 3 +- drivers/sound/max98095.c | 2 + drivers/sound/wm8994.c | 2 +- drivers/spi/pic32_spi.c | 2 +- drivers/spi/spi-uclass.c | 31 +- drivers/sysreset/sysreset_sandbox.c | 2 +- drivers/timer/timer-uclass.c | 3 +- drivers/usb/emul/sandbox_flash.c | 4 +- drivers/usb/emul/sandbox_hub.c | 3 +- drivers/usb/host/ehci-marvell.c | 2 +- drivers/usb/host/ehci-tegra.c | 7 +- drivers/usb/host/ehci-vf.c | 5 +- drivers/usb/host/usb-uclass.c | 8 +- drivers/usb/host/xhci-rockchip.c | 2 +- drivers/usb/musb-new/ti-musb.c | 2 +- dts/Kconfig | 11 + include/asm-generic/global_data.h | 3 + include/asm-generic/gpio.h | 17 +- include/clk-uclass.h | 5 +- include/configs/trats2.h | 1 - include/cros_ec.h | 8 +- include/dm.h | 2 + include/dm/device-internal.h | 10 +- include/dm/device.h | 4 +- include/dm/fdtaddr.h | 4 +- include/dm/lists.h | 9 +- include/dm/of.h | 142 +++++ include/dm/of_access.h | 347 +++++++++++ include/dm/of_addr.h | 64 ++ include/dm/of_extra.h | 46 ++ include/dm/ofnode.h | 488 ++++++++++++++- include/dm/read.h | 439 ++++++++++++++ include/dm/root.h | 3 +- include/dm/test.h | 2 + include/dm/uclass-internal.h | 18 + include/dm/uclass.h | 17 + include/fdt_support.h | 6 +- include/fdtdec.h | 34 -- include/generic-phy.h | 3 +- include/i2c.h | 3 +- include/key_matrix.h | 3 +- include/linux/compat.h | 8 +- include/linux/string.h | 28 + include/mailbox-uclass.h | 2 +- include/of_live.h | 24 + include/power-domain-uclass.h | 2 +- include/power/pmic.h | 2 +- include/reset-uclass.h | 4 +- include/spi.h | 2 +- include/test/test.h | 4 + include/test/ut.h | 2 +- lib/Makefile | 1 + lib/fdtdec.c | 33 +- lib/of_live.c | 333 ++++++++++ lib/string.c | 32 + test/dm/bus.c | 16 +- test/dm/phy.c | 15 +- test/dm/test-fdt.c | 3 +- test/dm/test-main.c | 105 +++- test/run | 8 +- 157 files changed, 4761 insertions(+), 667 deletions(-) create mode 100644 configs/sandbox_flattree_defconfig create mode 100644 drivers/core/of_access.c create mode 100644 drivers/core/of_addr.c create mode 100644 drivers/core/of_extra.c create mode 100644 drivers/core/ofnode.c create mode 100644 drivers/core/read.c create mode 100644 include/dm/of.h create mode 100644 include/dm/of_access.h create mode 100644 include/dm/of_addr.h create mode 100644 include/dm/of_extra.h create mode 100644 include/dm/read.h create mode 100644 include/of_live.h create mode 100644 lib/of_live.c
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 1/72 dm: core: Set return value first in lists_bind_fdt()
Adjust the order to make it clear that *devp is set to NULL by default.
---
Changes in v3: None
Changes in v2: None
drivers/core/lists.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/core/lists.c +2 -2
@@ -140,10 +140,10 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,int result =0 ;int ret =0 ; - name =fdt_get_name (blob, offset,NULL ); -dm_dbg ("bind node %s\n" , name);if (devp) *devp =NULL ; + name =fdt_get_name (blob, offset,NULL ); +dm_dbg ("bind node %s\n" , name); compat_list =fdt_getprop (blob, offset,"compatible" , &compat_length);if (!compat_list) {
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 1/72 dm: core: Set return value first in lists_bind_fdt()
Adjust the order to make it clear that *devp is set to NULL by default.
---
Changes in v3: None
Changes in v2: None
drivers/core/lists.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 2/72 Update WARN_ON() to return a value
In reply to Simon GlassIn linux v4.9 this returns a value. This saves checking the warning condition twice in some code.
Update the U-Boot version to do this also.
---
Changes in v3: None
Changes in v2: None
include/linux/compat.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
include/linux/compat.h +6 -2
@@ -106,8 +106,12 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep)#define BUG_ON (condition) do { if (condition) BUG(); } while(0)#endif /* BUG */ -#define WARN_ON (x) if (x) {printf("WARNING in %s line %d\n" \ - , __FILE__, __LINE__); } +#define WARN_ON (condition) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + printf("WARNING in %s line %d\n", __FILE__, __LINE__);; \ + unlikely(__ret_warn_on); \ +})#define PAGE_SIZE 4096
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 2/72 Update WARN_ON() to return a value
In linux v4.9 this returns a value. This saves checking the warning condition twice in some code.
Update the U-Boot version to do this also.
---
Changes in v3: None
Changes in v2: None
include/linux/compat.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 3/72 dm: core: Add livetree definitions
In reply to Simon GlassAdd a Kconfig option to enable a live device tree, built at run time from the flat tree. Also add structure definitions and a root node.
---
Changes in v3: None
Changes in v2: None
dts/Kconfig | 11 ++++ include/asm-generic/global_data.h | 3 ++ include/dm/of.h | 106 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 include/dm/of.h
dts/Kconfig +11 -0
@@ -32,6 +32,17 @@ config SPL_OF_CONTROL which is not enough to support device tree. Enable this option to allow such boards to be supported by U-Boot SPL. +config OF_LIVE + bool "Enable use of a live tree" + depends on OF_CONTROL + help + Normally U-Boot uses a flat device tree which saves space and + avoids the need to unpack the tree before use. However a flat + tree does not support modifcation from within U-Boot since it + can invalidate driver-model device tree offsets. This option + enables a live tree which is available after relocation, + and can be adjusted as needed. + choice prompt "Provider of DTB for DT control" depends on OF_CONTROL
include/asm-generic/global_data.h +3 -0
@@ -72,6 +72,9 @@ typedef struct global_data {const void *fdt_blob;/* Our device tree, NULL if none */ void *new_fdt;/* Relocated FDT */ unsigned long fdt_size;/* Space reserved for relocated FDT */ +#ifdef CONFIG_OF_LIVE +struct device_node *of_root; +#endif struct jt_funcs *jt;/* jump table */ char env_buf[32 ];/* buffer for getenv() before reloc. */ #ifdef CONFIG_TRACE
include/dm/of.h new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 3/72 dm: core: Add livetree definitions
Add a Kconfig option to enable a live device tree, built at run time from the flat tree. Also add structure definitions and a root node.
---
Changes in v3: None
Changes in v2: None
dts/Kconfig | 11 ++++ include/asm-generic/global_data.h | 3 ++ include/dm/of.h | 106 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 include/dm/of.h
Applied to u-boot-dm
PATCH v3 4/72 dm: core: Add livetree access functions
In reply to Simon GlassAdd a basic assortment of functions to access the live device tree. These come from Linux v4.9 and are modified for U-Boot to the minimum extent possible. While these functions are now very stable in Linux, it will be possible to merge in fixes if needed.
---
Changes in v3: None
Changes in v2: None
drivers/core/Makefile | 1 + drivers/core/of_access.c | 735 +++++++++++++++++++++++++++++++++++++++++++++++ include/dm/of_access.h | 347 ++++++++++++++++++++++ 3 files changed, 1083 insertions(+) create mode 100644 drivers/core/of_access.c create mode 100644 include/dm/of_access.h
drivers/core/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP) += regmap.o obj-$(CONFIG_$(SPL_)SYSCON) += syscon-uclass.o +obj-$(CONFIG_OF_LIVE) += of_access.o
drivers/core/of_access.c new file +735 -0
735 lines not on this page · raw message
include/dm/of_access.h new file +347 -0
347 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 4/72 dm: core: Add livetree access functions
Add a basic assortment of functions to access the live device tree. These come from Linux v4.9 and are modified for U-Boot to the minimum extent possible. While these functions are now very stable in Linux, it will be possible to merge in fixes if needed.
---
Changes in v3: None
Changes in v2: None
drivers/core/Makefile | 1 + drivers/core/of_access.c | 735 +++++++++++++++++++++++++++++++++++++++++++++++ include/dm/of_access.h | 347 ++++++++++++++++++++++ 3 files changed, 1083 insertions(+) create mode 100644 drivers/core/of_access.c create mode 100644 include/dm/of_access.h
Applied to u-boot-dm
PATCH v3 5/72 dm: Add a function to create a 'live' device tree
In reply to Simon GlassThis function converts the flat device tree into a hierarchical one with C structures and pointers. This is easier to access.
---
Changes in v3: None
Changes in v2: None
include/of_live.h | 24 ++++ lib/Makefile | 1 + lib/of_live.c | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 358 insertions(+) create mode 100644 include/of_live.h create mode 100644 lib/of_live.c
include/of_live.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (c) 2017 Google, Inc +* Written by Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +* +* Support for a 'live' (as opposed to flat) device tree +*/ + +#ifndef _OF_LIVE_H +#define _OF_LIVE_H + +struct device_node ; + +/** +* of_live_build() - build a live (hierarchical) tree from a flat DT +* +* @fdt_blob: Input tree to convert +* @rootp: Returns live tree that was created +* @return 0 if OK, -ve on error +*/ +int of_live_build (const void *fdt_blob,struct device_node **rootp); + +#endif
lib/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_ZLIB) += zlib/ obj-$(CONFIG_BZIP2) += bzip2/ obj-$(CONFIG_TIZEN) += tizen/ obj-$(CONFIG_FIT) += libfdt/ +obj-$(CONFIG_OF_LIVE) += of_live.o obj-$(CONFIG_CMD_DHRYSTONE) += dhry/ obj-$(CONFIG_AES) += aes.o
lib/of_live.c new file +333 -0
333 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 5/72 dm: Add a function to create a 'live' device tree
This function converts the flat device tree into a hierarchical one with C structures and pointers. This is easier to access.
---
Changes in v3: None
Changes in v2: None
include/of_live.h | 24 ++++ lib/Makefile | 1 + lib/of_live.c | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 358 insertions(+) create mode 100644 include/of_live.h create mode 100644 lib/of_live.c
Applied to u-boot-dm
PATCH v3 6/72 dm: Build a live tree after relocation
In reply to Simon GlassIf enabled, build a live device tree after relocation. This can then be used by driver model.
---
Changes in v3: None
Changes in v2: None
common/board_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
common/board_r.c +12 -0
@@ -42,6 +42,7 @@#endif #include <mmc.h> #include <nand.h> +#include <of_live.h> #include <onenand_uboot.h> #include <scsi.h> #include <serial.h>
@@ -294,6 +295,14 @@ static int initr_noncached(void) }#endif +#ifdef CONFIG_OF_LIVE +static int initr_of_live (void ) +{ +return of_live_build (gd->fdt_blob, + (struct device_node **)&gd->of_root); +} +#endif +#ifdef CONFIG_DM static int initr_dm (void ) {
@@ -724,6 +733,9 @@ static init_fnc_t init_sequence_r[] = { initr_noncached, #endif bootstage_relocate, +#ifdef CONFIG_OF_LIVE + initr_of_live, +#endif #ifdef CONFIG_DM initr_dm,#endif
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 6/72 dm: Build a live tree after relocation
If enabled, build a live device tree after relocation. This can then be used by driver model.
---
Changes in v3: None
Changes in v2: None
common/board_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Applied to u-boot-dm
PATCH v3 7/72 dm: core: Rename of_device_is_compatible()
In reply to Simon GlassThe of_ prefix conflicts with the livetree version of this function. Rename it to avoid problems when we add livetree support.
---
Changes in v3: None
Changes in v2: None
drivers/core/device.c | 2 +- drivers/firmware/psci.c | 4 ++-- drivers/mmc/xenon_sdhci.c | 2 +- drivers/net/cpsw-common.c | 4 ++-- drivers/net/mvneta.c | 2 +- drivers/phy/marvell/comphy_core.c | 4 ++-- drivers/usb/host/ehci-marvell.c | 2 +- drivers/usb/host/xhci-rockchip.c | 2 +- include/dm/device.h | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-)
drivers/core/device.c +1 -1
@@ -701,7 +701,7 @@ int device_set_name(struct udevice *dev, const char *name)return 0 ; } -bool of_device_is_compatible (struct udevice *dev,const char *compat) +bool device_is_compatible (struct udevice *dev,const char *compat) {const void *fdt = gd->fdt_blob;
drivers/firmware/psci.c +2 -2
@@ -40,8 +40,8 @@ static unsigned long __invoke_psci_fn_smc(unsigned long function_id,static int psci_bind (struct udevice *dev) {/* No SYSTEM_RESET support for PSCI 0.1 */ -if (of_device_is_compatible (dev,"arm,psci-0.2" ) || -of_device_is_compatible (dev,"arm,psci-1.0" )) { +if (device_is_compatible (dev,"arm,psci-0.2" ) || +device_is_compatible (dev,"arm,psci-1.0" )) {int ret;/* bind psci-sysreset optionally */
drivers/mmc/xenon_sdhci.c +1 -1
@@ -454,7 +454,7 @@ static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev) host->name = dev->name; host->ioaddr = (void *)devfdt_get_addr (dev); -if (of_device_is_compatible (dev,"marvell,armada-3700-sdhci" )) +if (device_is_compatible (dev,"marvell,armada-3700-sdhci" )) priv->pad_ctrl_reg = (void *)devfdt_get_addr_index (dev,1 ); name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "marvell,pad-type",
drivers/net/cpsw-common.c +2 -2
@@ -104,10 +104,10 @@ int ti_cm_get_macid(struct udevice *dev, int slave, u8 *mac_addr)if (of_machine_is_compatible ("ti,am33xx" ))return cpsw_am33xx_cm_get_macid (dev,0x630 , slave, mac_addr); -if (of_device_is_compatible (dev,"ti,am3517-emac" )) +if (device_is_compatible (dev,"ti,am3517-emac" ))return davinci_emac_3517_get_macid (dev,0x110 , slave, mac_addr); -if (of_device_is_compatible (dev,"ti,dm816-emac" )) +if (device_is_compatible (dev,"ti,dm816-emac" ))return cpsw_am33xx_cm_get_macid (dev,0x30 , slave, mac_addr);if (of_machine_is_compatible ("ti,am43" ))
drivers/net/mvneta.c +1 -1
@@ -1695,7 +1695,7 @@ static int mvneta_probe(struct udevice *dev) pp->base = (void __iomem *)pdata->iobase;/* Configure MBUS address windows */ -if (of_device_is_compatible (dev,"marvell,armada-3700-neta" )) +if (device_is_compatible (dev,"marvell,armada-3700-neta" ))mvneta_bypass_mbus_windows (pp);else mvneta_conf_mbus_windows (pp);
drivers/phy/marvell/comphy_core.c +2 -2
@@ -135,10 +135,10 @@ static int comphy_probe(struct udevice *dev)return -EINVAL ; } -if (of_device_is_compatible (dev,"marvell,comphy-armada-3700" )) +if (device_is_compatible (dev,"marvell,comphy-armada-3700" )) chip_cfg->ptr_comphy_chip_init = comphy_a3700_init; -if (of_device_is_compatible (dev,"marvell,comphy-cp110" )) +if (device_is_compatible (dev,"marvell,comphy-cp110" )) chip_cfg->ptr_comphy_chip_init = comphy_cp110_init;/*
drivers/usb/host/ehci-marvell.c +1 -1
@@ -121,7 +121,7 @@ static int ehci_mvebu_probe(struct udevice *dev)* Also, the address decoder doesn't need to get setup with this * SoC, so don't call usb_brg_adrdec_setup(). */ -if (of_device_is_compatible (dev,"marvell,armada3700-ehci" )) +if (device_is_compatible (dev,"marvell,armada3700-ehci" )) marvell_ehci_ops.powerup_fixup = marvell_ehci_powerup_fixup;else usb_brg_adrdec_setup ((void *)priv->hcd_base);
drivers/usb/host/xhci-rockchip.c +1 -1
@@ -55,7 +55,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)/* Get the base address for usbphy from the device node */ for (device_find_first_child (dev, &child); child;device_find_next_child (&child)) { -if (!of_device_is_compatible (child,"rockchip,rk3399-usb3-phy" )) +if (!device_is_compatible (child,"rockchip,rk3399-usb3-phy" ))continue ; plat->phy_base =devfdt_get_addr (child);break ;
include/dm/device.h +2 -2
@@ -563,7 +563,7 @@ int device_set_name(struct udevice *dev, const char *name);void device_set_name_alloced (struct udevice *dev);/** -* of_device_is_compatible() - check if the device is compatible with the compat +* device_is_compatible() - check if the device is compatible with the compat * * This allows to check whether the device is comaptible with the compat. *
@@ -572,7 +572,7 @@ void device_set_name_alloced(struct udevice *dev);* device * @return true if OK, false if the compatible is not found */ -bool of_device_is_compatible (struct udevice *dev,const char *compat); +bool device_is_compatible (struct udevice *dev,const char *compat);/** * of_machine_is_compatible() - check if the machine is compatible with
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 7/72 dm: core: Rename of_device_is_compatible()
The of_ prefix conflicts with the livetree version of this function. Rename it to avoid problems when we add livetree support.
---
Changes in v3: None
Changes in v2: None
drivers/core/device.c | 2 +- drivers/firmware/psci.c | 4 ++-- drivers/mmc/xenon_sdhci.c | 2 +- drivers/net/cpsw-common.c | 4 ++-- drivers/net/mvneta.c | 2 +- drivers/phy/marvell/comphy_core.c | 4 ++-- drivers/usb/host/ehci-marvell.c | 2 +- drivers/usb/host/xhci-rockchip.c | 2 +- include/dm/device.h | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-)
Applied to u-boot-dm
PATCH v3 8/72 dm: core: Add operations on device tree references
In reply to Simon GlassSince U-Boot supports both a live tree and a flat tree, we need an easy way to access the tree without worrying about which is currently active. To support this, U-Boot has the concept of an ofnode, which can refer either to a live tree node or a flat tree node.
For the live tree, the reference contains a pointer to the node (struct device_node *) or NULL if the node is invalid. For the flat tree, the reference contains the node offset or -1 if the node is invalid.
Add a basic set of operations using ofnodes. These are implemented by using either libfdt functions (in the case of a flat DT reference) or the live-tree of_...() functions.
Note that it is not possible to have both live and flat references active at the same time. As soon as the live tree is available, everything in U-Boot should switch to using that. This avoids confusion and allows us to assume that the type of a reference is simply based on whether we have a live tree yet, or not.
---
Changes in v3:
- Adjust header includes in ofnode.h to make it stand alone
Changes in v2: None
drivers/core/Makefile | 1 + drivers/core/ofnode.c | 552 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 467 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 1017 insertions(+), 3 deletions(-) create mode 100644 drivers/core/ofnode.c
drivers/core/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP) += regmap.o obj-$(CONFIG_$(SPL_)SYSCON) += syscon-uclass.o obj-$(CONFIG_OF_LIVE) += of_access.o +obj-$(CONFIG_OF_CONTROL) += ofnode.o
drivers/core/ofnode.c new file +552 -0
552 lines not on this page · raw message
include/dm/ofnode.h +464 -3
512 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 8/72 dm: core: Add operations on device tree references
Since U-Boot supports both a live tree and a flat tree, we need an easy way to access the tree without worrying about which is currently active. To support this, U-Boot has the concept of an ofnode, which can refer either to a live tree node or a flat tree node.
For the live tree, the reference contains a pointer to the node (struct device_node *) or NULL if the node is invalid. For the flat tree, the reference contains the node offset or -1 if the node is invalid.
Add a basic set of operations using ofnodes. These are implemented by using either libfdt functions (in the case of a flat DT reference) or the live-tree of_...() functions.
Note that it is not possible to have both live and flat references active at the same time. As soon as the live tree is available, everything in U-Boot should switch to using that. This avoids confusion and allows us to assume that the type of a reference is simply based on whether we have a live tree yet, or not.
---
Changes in v3:
- Adjust header includes in ofnode.h to make it stand alone
Changes in v2: None
drivers/core/Makefile | 1 + drivers/core/ofnode.c | 552 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 467 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 1017 insertions(+), 3 deletions(-) create mode 100644 drivers/core/ofnode.c
Applied to u-boot-dm
PATCH v3 9/72 dm: core: Add livetree address functions
In reply to Simon GlassAdd functions to access addresses in the device tree. These are brought in from Linux 4.10.
Also fix up the header guard for fdtaddr.h to avoid confusion.
---
Changes in v3:
- Fix up the fdtaddr.h header guard to avoid conflicts
Changes in v2: None
drivers/core/Makefile | 2 +- drivers/core/of_addr.c | 359 +++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/fdtaddr.h | 4 +- include/dm/of_addr.h | 64 +++++++++ 4 files changed, 426 insertions(+), 3 deletions(-) create mode 100644 drivers/core/of_addr.c create mode 100644 include/dm/of_addr.h
drivers/core/Makefile +1 -1
@@ -11,5 +11,5 @@ obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP) += regmap.o obj-$(CONFIG_$(SPL_)SYSCON) += syscon-uclass.o -obj-$(CONFIG_OF_LIVE) += of_access.o +obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o obj-$(CONFIG_OF_CONTROL) += ofnode.o
drivers/core/of_addr.c new file +359 -0
359 lines not on this page · raw message
include/dm/fdtaddr.h +2 -2
@@ -8,8 +8,8 @@* SPDX-License-Identifier: GPL-2.0+ */ -#ifndef _DM_ADDR_H -#define _DM_ADDR_H +#ifndef _DM_FDTADDR_H +#define _DM_FDTADDR_H#include <fdtdec.h>
include/dm/of_addr.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 9/72 dm: core: Add livetree address functions
Add functions to access addresses in the device tree. These are brought in from Linux 4.10.
Also fix up the header guard for fdtaddr.h to avoid confusion.
---
Changes in v3:
- Fix up the fdtaddr.h header guard to avoid conflicts
Changes in v2: None
drivers/core/Makefile | 2 +- drivers/core/of_addr.c | 359 +++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/fdtaddr.h | 4 +- include/dm/of_addr.h | 64 +++++++++ 4 files changed, 426 insertions(+), 3 deletions(-) create mode 100644 drivers/core/of_addr.c create mode 100644 include/dm/of_addr.h
Applied to u-boot-dm
PATCH v3 10/72 fdt: Update fdt_get_base_address() to use const
In reply to Simon GlassThis function does not change the device tree so adjust it to use const for this parameter.
---
Changes in v3: None
Changes in v2: None
common/fdt_support.c | 2 +- include/fdt_support.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
common/fdt_support.c +1 -1
@@ -1539,7 +1539,7 @@ int fdt_verify_alias_address(void *fdt, int anode, const char *alias, u64 addr)/* * Returns the base address of an SOC or PCI node */ -u64 fdt_get_base_address (void *fdt,int node) +u64 fdt_get_base_address (const void *fdt,int node) {int size;u32 naddr;
include/fdt_support.h +1 -1
@@ -207,7 +207,7 @@ int fdt_add_edid(void *blob, const char *compat, unsigned char *buf);int fdt_verify_alias_address (void *fdt,int anode,const char *alias,u64 addr); -u64 fdt_get_base_address (void *fdt,int node); +u64 fdt_get_base_address (const void *fdt,int node);int fdt_read_range (void *fdt,int node,int n,uint64_t *child_addr,uint64_t *addr,uint64_t *len);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 10/72 fdt: Update fdt_get_base_address() to use const
This function does not change the device tree so adjust it to use const for this parameter.
---
Changes in v3: None
Changes in v2: None
common/fdt_support.c | 2 +- include/fdt_support.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 11/72 dm: core: Add address operations on device tree references
In reply to Simon GlassAdd functions to add addresses in the device tree using ofnode references.
---
Changes in v3: None
Changes in v2: None
drivers/core/ofnode.c | 27 +++++++++++++++++++++++++++ include/dm/ofnode.h | 23 ++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-)
drivers/core/ofnode.c +27 -0
@@ -11,6 +11,7 @@#include <fdt_support.h> #include <libfdt.h> #include <dm/of_access.h> +#include <dm/of_addr.h> #include <dm/ofnode.h> #include <linux/err.h>
@@ -195,6 +196,32 @@ int ofnode_read_size(ofnode node, const char *propname)return -EINVAL ; } +fdt_addr_t ofnode_get_addr_index (ofnode node,int index) +{ +if (ofnode_is_np (node)) { +const __be32 *prop_val; +uint flags; +u64 size; + + prop_val =of_get_address ( + (struct device_node *)ofnode_to_np (node), index, + &size, &flags); +if (!prop_val) +return FDT_ADDR_T_NONE ; +return be32_to_cpup (prop_val); + }else { +return fdt_get_base_address (gd->fdt_blob, +ofnode_to_offset (node)); + } + +return FDT_ADDR_T_NONE ; +} + +fdt_addr_t ofnode_get_addr (ofnode node) +{ +return ofnode_get_addr_index (node,0 ); +} +int ofnode_stringlist_search (ofnode node,const char *property,const char *string) {
include/dm/ofnode.h +22 -1
@@ -245,7 +245,7 @@ int ofnode_read_s32_default(ofnode node, const char *propname, s32 def);const char *ofnode_read_string (ofnode node,const char *propname);/** -* ofnode_read_u32_array - Find and read an array of 32 bit integers +* ofnode_read_u32_array() - Find and read an array of 32 bit integers * * @node: valid node reference to read property from * @propname: name of the property to read
@@ -317,6 +317,27 @@ const char *ofnode_get_name(ofnode node);int ofnode_read_size (ofnode node,const char *propname);/** +* ofnode_get_addr_index() - get an address from a node +* +* This reads the register address from a node +* +* @node: node to read from +* @index: Index of address to read (0 for first) +* @return address, or FDT_ADDR_T_NONE if not present or invalid +*/ +phys_addr_t ofnode_get_addr_index (ofnode node,int index); + +/** +* ofnode_get_addr() - get an address from a node +* +* This reads the register address from a node +* +* @node: node to read from +* @return address, or FDT_ADDR_T_NONE if not present or invalid +*/ +phys_addr_t ofnode_get_addr (ofnode node); + +/** * ofnode_stringlist_search() - find a string in a string list and return index * * Note that it is possible for this function to succeed on property values
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 11/72 dm: core: Add address operations on device tree references
Add functions to add addresses in the device tree using ofnode references.
---
Changes in v3: None
Changes in v2: None
drivers/core/ofnode.c | 27 +++++++++++++++++++++++++++ include/dm/ofnode.h | 23 ++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 12/72 dm: core: Add a place to put extra device-tree reading functions
In reply to Simon GlassSome functions deal with structured data rather than simple data types. It makes sense to have these in their own file. For now this just has a function to read a flashmap entry. Move the data types also.
---
Changes in v3: None
Changes in v2: None
drivers/core/Makefile | 2 +- drivers/core/of_extra.c | 37 +++++++++++++++++++++++++++++++++++++ include/cros_ec.h | 1 + include/dm/of_extra.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/fdtdec.h | 23 +---------------------- lib/fdtdec.c | 1 + 6 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 drivers/core/of_extra.c create mode 100644 include/dm/of_extra.h
drivers/core/Makefile +1 -1
@@ -12,4 +12,4 @@ obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP) += regmap.o obj-$(CONFIG_$(SPL_)SYSCON) += syscon-uclass.o obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o -obj-$(CONFIG_OF_CONTROL) += ofnode.o +obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o
drivers/core/of_extra.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (c) 2017 Google, Inc +* Written by Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <libfdt.h> +#include <dm/of_access.h> +#include <dm/of_extra.h> +#include <dm/ofnode.h> + +int of_read_fmap_entry (ofnode node,const char *name, +struct fmap_entry *entry) +{ +const char *prop; +u32 reg[2 ]; + +if (ofnode_read_u32_array (node,"reg" , reg,2 )) { +debug ("Node '%s' has bad/missing 'reg' property\n" , name); +return -FDT_ERR_NOTFOUND ; + } + entry->offset = reg[0 ]; + entry->length = reg[1 ]; + entry->used =ofnode_read_s32_default (node,"used" , entry->length); + prop =ofnode_read_string (node,"compress" ); + entry->compress_algo = prop && !strcmp (prop,"lzo" ) ? +FMAP_COMPRESS_LZO :FMAP_COMPRESS_NONE ; + prop =ofnode_read_string (node,"hash" ); +if (prop) + entry->hash_size =strlen (prop); + entry->hash_algo = prop ?FMAP_HASH_SHA256 :FMAP_HASH_NONE ; + entry->hash = (uint8_t *)prop; + +return 0 ; +}
include/cros_ec.h +1 -0
@@ -14,6 +14,7 @@#include <fdtdec.h> #include <cros_ec_message.h> #include <asm/gpio.h> +#include <dm/of_extra.h> /* Our configuration information */ struct cros_ec_dev {
include/dm/of_extra.h new file +46 -0
46 lines not on this page · raw message
include/fdtdec.h +1 -22
@@ -815,28 +815,7 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,int fdtdec_decode_region (const void *blob,int node,const char *prop_name,fdt_addr_t *basep,fdt_size_t *sizep); -enum fmap_compress_t { -FMAP_COMPRESS_NONE , -FMAP_COMPRESS_LZO , -}; - -enum fmap_hash_t { -FMAP_HASH_NONE , -FMAP_HASH_SHA1 , -FMAP_HASH_SHA256 , -}; - -/* A flash map entry, containing an offset and length */ -struct fmap_entry { -uint32_t offset; -uint32_t length; -uint32_t used;/* Number of bytes used in region */ -enum fmap_compress_t compress_algo;/* Compression type */ -enum fmap_hash_t hash_algo;/* Hash algorithm */ -const uint8_t *hash;/* Hash value */ -int hash_size;/* Hash size */ -}; - +struct fmap_entry ;/** * Read a flash entry from the fdt *
lib/fdtdec.c +1 -0
@@ -12,6 +12,7 @@#include <fdt_support.h> #include <fdtdec.h> #include <asm/sections.h> +#include <dm/of_extra.h> #include <linux/ctype.h> DECLARE_GLOBAL_DATA_PTR ;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 12/72 dm: core: Add a place to put extra device-tree reading functions
Some functions deal with structured data rather than simple data types. It makes sense to have these in their own file. For now this just has a function to read a flashmap entry. Move the data types also.
---
Changes in v3: None
Changes in v2: None
drivers/core/Makefile | 2 +- drivers/core/of_extra.c | 37 +++++++++++++++++++++++++++++++++++++ include/cros_ec.h | 1 + include/dm/of_extra.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/fdtdec.h | 23 +---------------------- lib/fdtdec.c | 1 + 6 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 drivers/core/of_extra.c create mode 100644 include/dm/of_extra.h
Applied to u-boot-dm
PATCH v3 13/72 dm: core: Add device-based 'read' functions to access DT
In reply to Simon GlassIt is common to read a device-tree property from the node associated with a device. Add convenience functions to do this so that drivers do not need to deal with accessing the ofnode from the device.
These functions all start with 'dev_read_' to provide consistent naming for all functions which read information from a device's device tree node.
These are inlined when using the flat DT to save code size. The live tree implementation is added in a later commit.
---
Changes in v3: None
Changes in v2: None
drivers/core/Kconfig | 4 + include/dm/read.h | 383 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 387 insertions(+) create mode 100644 include/dm/read.h
drivers/core/Kconfig +4 -0
@@ -215,4 +215,8 @@ config OF_ISA_BUS mistranslation of device addresses, so ensure that this is enabled if your board does include an ISA bus. +config DM_DEV_READ_INLINE + bool + default y if !OF_LIVE + endmenu
include/dm/read.h new file +383 -0
383 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 13/72 dm: core: Add device-based 'read' functions to access DT
It is common to read a device-tree property from the node associated with a device. Add convenience functions to do this so that drivers do not need to deal with accessing the ofnode from the device.
These functions all start with 'dev_read_' to provide consistent naming for all functions which read information from a device's device tree node.
These are inlined when using the flat DT to save code size. The live tree implementation is added in a later commit.
---
Changes in v3: None
Changes in v2: None
drivers/core/Kconfig | 4 + include/dm/read.h | 383 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 387 insertions(+) create mode 100644 include/dm/read.h
Applied to u-boot-dm
PATCH v3 14/72 dm: core: Implement live tree 'read' functions
In reply to Simon GlassWhen the live tree is supported some functions need to change a little. Add an implementation which is used when not inlining these functions.
---
Changes in v3: None
Changes in v2: None
drivers/core/Makefile | 3 + drivers/core/read.c | 140 +++++++++++++++++++++++++++++ include/dm/read.h | 240 +++++++++++++++++++++++++++++++------------------- 3 files changed, 291 insertions(+), 92 deletions(-) create mode 100644 drivers/core/read.c
drivers/core/Makefile +3 -0
@@ -12,4 +12,7 @@ obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP) += regmap.o obj-$(CONFIG_$(SPL_)SYSCON) += syscon-uclass.o obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o +ifndef CONFIG_DM_DEV_READ_INLINE +obj-$(CONFIG_OF_CONTROL) += read.o +endif obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o
drivers/core/read.c new file +140 -0
140 lines not on this page · raw message
include/dm/read.h +148 -92
360 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 14/72 dm: core: Implement live tree 'read' functions
When the live tree is supported some functions need to change a little. Add an implementation which is used when not inlining these functions.
---
Changes in v3: None
Changes in v2: None
drivers/core/Makefile | 3 + drivers/core/read.c | 140 +++++++++++++++++++++++++++++ include/dm/read.h | 240 +++++++++++++++++++++++++++++++------------------- 3 files changed, 291 insertions(+), 92 deletions(-) create mode 100644 drivers/core/read.c
Applied to u-boot-dm
PATCH v3 15/72 dm: core: Allow binding a device from a live tree
In reply to Simon GlassWhen a live tree is being used we need to record the node that was used to create the device. Update device_bind_with_driver_data() to support this.
---
Changes in v3: None
Changes in v2: None
drivers/core/device.c | 18 ++++++++---------- drivers/core/lists.c | 2 +- include/dm/device-internal.h | 10 ++++++---- 3 files changed, 15 insertions(+), 15 deletions(-)
drivers/core/device.c +8 -10
@@ -19,6 +19,7 @@#include <dm/lists.h> #include <dm/pinctrl.h> #include <dm/platdata.h> +#include <dm/read.h> #include <dm/uclass.h> #include <dm/uclass-internal.h> #include <dm/util.h>
@@ -77,10 +78,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,*/ if (uc->uc_drv->flags &DM_UC_FLAG_SEQ_ALIAS ) {if (uc->uc_drv->name &&ofnode_valid (node)) { -fdtdec_get_alias_seq (gd->fdt_blob, - uc->uc_drv->name, -ofnode_to_offset (node), - &dev->req_seq); +dev_read_alias_seq (dev, &dev->req_seq); } } }
@@ -216,11 +214,11 @@ fail_alloc1:int device_bind_with_driver_data (struct udevice *parent,const struct driver *drv,const char *name, -ulong driver_data,int of_offset, +ulong driver_data,ofnode node,struct udevice **devp) { -return device_bind_common (parent, drv, name,NULL , driver_data, -offset_to_ofnode (of_offset),0 , devp); +return device_bind_common (parent, drv, name,NULL , driver_data, node, +0 , devp); } int device_bind(struct udevice *parent, const struct driver *drv,
@@ -247,8 +245,8 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, platdata_size = info->platdata_size;#endif return device_bind_common (parent, drv, info->name, - (void *)info->platdata,0 ,offset_to_ofnode (-1 ), - platdata_size, devp); + (void *)info->platdata,0 ,ofnode_null (), platdata_size, + devp); }static void *alloc_priv (int size,uint flags)
@@ -385,7 +383,7 @@ int device_probe(struct udevice *dev) goto fail; } -if (drv->ofdata_to_platdata &&dev_of_offset (dev) >=0 ) { +if (drv->ofdata_to_platdata &&dev_has_of_node (dev)) { ret = drv->ofdata_to_platdata (dev);if (ret) goto fail;
drivers/core/lists.c +1 -1
@@ -177,7 +177,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,dm_dbg (" - found match at '%s'\n" , entry->name); ret =device_bind_with_driver_data (parent, entry, name, - id->data, offset, &dev); + id->data,offset_to_ofnode (offset), &dev);if (ret == -ENODEV ) {dm_dbg ("Driver '%s' refuses to bind\n" , entry->name);continue ;
include/dm/device-internal.h +6 -4
@@ -11,6 +11,9 @@#ifndef _DM_DEVICE_INTERNAL_H#define _DM_DEVICE_INTERNAL_H +#include <dm/ofnode.h> + +struct device_node ;struct udevice ;/**
@@ -52,16 +55,15 @@ int device_bind(struct udevice *parent, const struct driver *drv,* @drv: Device's driver * @name: Name of device (e.g. device tree node name) * @driver_data: The driver_data field from the driver's match table. -* @of_offset: Offset of device tree node for this device. This is -1 for -* devices which don't use device tree. +* @node: Device tree node for this device. This is invalid for devices which +* don't use device tree. * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ int device_bind_with_driver_data (struct udevice *parent,const struct driver *drv,const char *name, -ulong driver_data,int of_offset, +ulong driver_data,ofnode node,struct udevice **devp); -/** * device_bind_by_name: Create a device and bind it to a driver *
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 15/72 dm: core: Allow binding a device from a live tree
When a live tree is being used we need to record the node that was used to create the device. Update device_bind_with_driver_data() to support this.
---
Changes in v3: None
Changes in v2: None
drivers/core/device.c | 18 ++++++++---------- drivers/core/lists.c | 2 +- include/dm/device-internal.h | 10 ++++++---- 3 files changed, 15 insertions(+), 15 deletions(-)
Applied to u-boot-dm
PATCH v3 16/72 dm: core: Update lists_bind_fdt() to use ofnode
In reply to Simon GlassAdjust this function to use an ofnode instead of an offset, so it can be used with livetree. This involves updating all callers.
---
Changes in v3: None
Changes in v2: None
drivers/core/lists.c | 12 ++++++------ drivers/core/root.c | 2 +- drivers/serial/serial-uclass.c | 3 ++- drivers/timer/timer-uclass.c | 3 ++- include/dm/lists.h | 7 +++---- 5 files changed, 14 insertions(+), 13 deletions(-)
drivers/core/lists.c +6 -6
@@ -126,8 +126,7 @@ static int driver_check_compatible(const struct udevice_id *of_match,return -ENOENT ; } -int lists_bind_fdt (struct udevice *parent,const void *blob,int offset, -struct udevice **devp) +int lists_bind_fdt (struct udevice *parent,ofnode node,struct udevice **devp) { struct driver *driver = ll_entry_start(struct driver, driver); const int n_ents = ll_entry_count(struct driver, driver);
@@ -142,17 +141,18 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,if (devp) *devp =NULL ; - name =fdt_get_name (blob, offset,NULL ); + name =ofnode_get_name (node);dm_dbg ("bind node %s\n" , name); - compat_list =fdt_getprop (blob, offset,"compatible" , &compat_length); + compat_list = (const char *)ofnode_read_prop (node,"compatible" , + &compat_length);if (!compat_list) {if (compat_length == -FDT_ERR_NOTFOUND ) {dm_dbg ("Device '%s' has no compatible string\n" , name);return 0 ; } -dm_warn ("Device tree error at offset %d\n" , offset); +dm_warn ("Device tree error at node '%s'\n" , name);return compat_length; }
@@ -177,7 +177,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,dm_dbg (" - found match at '%s'\n" , entry->name); ret =device_bind_with_driver_data (parent, entry, name, - id->data,offset_to_ofnode (offset), &dev); + id->data, node, &dev);if (ret == -ENODEV ) {dm_dbg ("Driver '%s' refuses to bind\n" , entry->name);continue ;
drivers/core/root.c +1 -1
@@ -235,7 +235,7 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,dm_dbg (" - ignoring disabled device\n" );continue ; } - err =lists_bind_fdt (parent, blob, offset,NULL ); + err =lists_bind_fdt (parent,offset_to_ofnode (offset),NULL );if (err && !ret) { ret = err; debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL),
drivers/serial/serial-uclass.c +2 -1
@@ -74,7 +74,8 @@ static void serial_find_console_or_panic(void)* bind it anyway. */ if (node >0 && - !lists_bind_fdt (gd->dm_root, blob, node, &dev)) { + !lists_bind_fdt (gd->dm_root,offset_to_ofnode (node), + &dev)) {if (!device_probe (dev)) { gd->cur_serial_dev = dev;return ;
drivers/timer/timer-uclass.c +2 -1
@@ -103,7 +103,8 @@ int notrace dm_timer_init(void)* relocation, bind it anyway. */ if (node >0 && - !lists_bind_fdt (gd->dm_root, blob, node, &dev)) { + !lists_bind_fdt (gd->dm_root,offset_to_ofnode (node), + &dev)) { ret =device_probe (dev);if (ret)return ret;
include/dm/lists.h +3 -4
@@ -10,6 +10,7 @@#ifndef _DM_LISTS_H_#define _DM_LISTS_H_ +#include <dm/ofnode.h> #include <dm/uclass-id.h> /**
@@ -51,14 +52,12 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);* @parent as its parent. * * @parent: parent device (root) -* @blob: device tree blob -* @offset: offset of this device tree node +* @node: device tree node to bind * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if device was bound, -EINVAL if the device tree is invalid, * other -ve value on error */ -int lists_bind_fdt (struct udevice *parent,const void *blob,int offset, -struct udevice **devp); +int lists_bind_fdt (struct udevice *parent,ofnode node,struct udevice **devp);/** * device_bind_driver() - bind a device to a driver
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 16/72 dm: core: Update lists_bind_fdt() to use ofnode
Adjust this function to use an ofnode instead of an offset, so it can be used with livetree. This involves updating all callers.
---
Changes in v3: None
Changes in v2: None
drivers/core/lists.c | 12 ++++++------ drivers/core/root.c | 2 +- drivers/serial/serial-uclass.c | 3 ++- drivers/timer/timer-uclass.c | 3 ++- include/dm/lists.h | 7 +++---- 5 files changed, 14 insertions(+), 13 deletions(-)
Applied to u-boot-dm
PATCH v3 17/72 dm: core: Update device_bind_driver_to_node() to use ofnode
In reply to Simon GlassAdjust this function to us an ofnode instead of an offset, so it can be used with livetree. This involves updating all callers.
---
Changes in v3: None
Changes in v2: None
drivers/clk/at91/pmc.c | 2 +- drivers/core/lists.c | 15 ++++++--------- drivers/cpu/cpu-uclass.c | 6 +++--- drivers/i2c/muxes/i2c-mux-uclass.c | 11 ++++------- drivers/led/led_bcm6328.c | 2 +- drivers/led/led_bcm6358.c | 2 +- drivers/led/led_gpio.c | 13 +++++-------- drivers/misc/tegra186_bpmp.c | 6 +++--- drivers/misc/tegra_car.c | 4 ++-- drivers/net/keystone_net.c | 6 +++--- drivers/pinctrl/pinctrl-uclass.c | 15 ++++++--------- drivers/usb/musb-new/ti-musb.c | 2 +- include/dm.h | 2 ++ include/dm/lists.h | 2 +- 14 files changed, 39 insertions(+), 49 deletions(-)
drivers/clk/at91/pmc.c +1 -1
@@ -79,7 +79,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)if (!name)return -EINVAL ; ret =device_bind_driver_to_node (dev, drv_name, name, - offset,NULL ); +offset_to_ofnode (offset),NULL );if (ret)return ret; }
drivers/core/lists.c +6 -9
@@ -74,11 +74,12 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only)int device_bind_driver (struct udevice *parent,const char *drv_name,const char *dev_name,struct udevice **devp) { -return device_bind_driver_to_node (parent, drv_name, dev_name,-1 , devp); +return device_bind_driver_to_node (parent, drv_name, dev_name, +ofnode_null (), devp); }int device_bind_driver_to_node (struct udevice *parent,const char *drv_name, -const char *dev_name,int node, +const char *dev_name,ofnode node,struct udevice **devp) {struct driver *drv;
@@ -89,14 +90,10 @@ int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,debug ("Cannot find driver '%s'\n" , drv_name);return -ENOENT ; } - ret =device_bind (parent, drv, dev_name,NULL , node, devp); -if (ret) { -debug ("Cannot create device named '%s' (err=%d)\n" , - dev_name, ret); -return ret; - } + ret =device_bind_with_driver_data (parent, drv, dev_name,0 /* data */ , + node, devp); -return 0 ; +return ret; }#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )
drivers/cpu/cpu-uclass.c +3 -3
@@ -63,11 +63,11 @@ U_BOOT_DRIVER(cpu_bus) = {static int uclass_cpu_init (struct uclass *uc) {struct udevice *dev; -int node; +ofnode node;int ret; - node =fdt_path_offset (gd->fdt_blob,"/cpus" ); -if (node <0 ) + node =ofnode_path ("/cpus" ); +if (!ofnode_valid (node))return 0 ; ret = device_bind_driver_to_node(dm_root(), "cpu_bus", "cpus", node,
drivers/i2c/muxes/i2c-mux-uclass.c +4 -7
@@ -51,24 +51,21 @@ static int i2c_mux_child_post_bind(struct udevice *dev)/* Find the I2C buses selected by this mux */ static int i2c_mux_post_bind (struct udevice *mux) { -const void *blob = gd->fdt_blob; +ofnode node;int ret; -int offset;debug ("%s: %s\n" , __func__, mux->name);/* * There is no compatible string in the sub-nodes, so we must manually * bind these */ -for (offset =fdt_first_subnode (blob,dev_of_offset (mux)); - offset >0 ; - offset =fdt_next_subnode (blob, offset)) { +dev_for_each_subnode (node, mux) {struct udevice *dev;const char *name; - name =fdt_get_name (blob, offset,NULL ); + name =ofnode_get_name (node); ret =device_bind_driver_to_node (mux,"i2c_mux_bus_drv" , name, - offset, &dev); + node, &dev);debug (" - bind ret=%d, %s\n" , ret, dev ? dev->name :NULL );if (ret)return ret;
drivers/led/led_bcm6328.c +1 -1
@@ -236,7 +236,7 @@ static int bcm6328_led_bind(struct udevice *parent) ret =device_bind_driver_to_node (parent,"bcm6328-led" ,fdt_get_name (blob, node,NULL ), - node, &dev); +offset_to_ofnode (node), &dev);if (ret)return ret;
drivers/led/led_bcm6358.c +1 -1
@@ -201,7 +201,7 @@ static int bcm6358_led_bind(struct udevice *parent) ret =device_bind_driver_to_node (parent,"bcm6358-led" ,fdt_get_name (blob, node,NULL ), - node, &dev); +offset_to_ofnode (node), &dev);if (ret)return ret;
drivers/led/led_gpio.c +5 -8
@@ -85,25 +85,22 @@ static int led_gpio_remove(struct udevice *dev)static int led_gpio_bind (struct udevice *parent) { -const void *blob = gd->fdt_blob;struct udevice *dev; -int node; +ofnode node;int ret; -for (node =fdt_first_subnode (blob,dev_of_offset (parent)); - node >0 ; - node =fdt_next_subnode (blob, node)) { +dev_for_each_subnode (node, parent) {struct led_uc_plat *uc_plat;const char *label; - label =fdt_getprop (blob, node,"label" ,NULL ); + label =ofnode_read_string (node,"label" );if (!label) {debug ("%s: node %s has no label\n" , __func__, -fdt_get_name (blob, node,NULL )); +ofnode_get_name (node));return -EINVAL ; } ret =device_bind_driver_to_node (parent,"gpio_led" , -fdt_get_name (blob, node,NULL ), +ofnode_get_name (node), node, &dev);if (ret)return ret;
drivers/misc/tegra186_bpmp.c +3 -3
@@ -112,19 +112,19 @@ static int tegra186_bpmp_bind(struct udevice *dev)debug ("%s(dev=%p)\n" , __func__, dev); ret =device_bind_driver_to_node (dev,"tegra186_clk" ,"tegra186_clk" , -dev_of_offset (dev), &child); +dev_ofnode (dev), &child);if (ret)return ret; ret =device_bind_driver_to_node (dev,"tegra186_reset" , -"tegra186_reset" ,dev_of_offset (dev), +"tegra186_reset" ,dev_ofnode (dev), &child);if (ret)return ret; ret =device_bind_driver_to_node (dev,"tegra186_power_domain" ,"tegra186_power_domain" , -dev_of_offset (dev), &child); +dev_ofnode (dev), &child);if (ret)return ret;
drivers/misc/tegra_car.c +2 -2
@@ -22,12 +22,12 @@ static int tegra_car_bpmp_bind(struct udevice *dev)debug ("%s(dev=%p)\n" , __func__, dev); ret =device_bind_driver_to_node (dev,"tegra_car_clk" ,"tegra_car_clk" , -dev_of_offset (dev), &child); +dev_ofnode (dev), &child);if (ret)return ret; ret =device_bind_driver_to_node (dev,"tegra_car_reset" , -"tegra_car_reset" ,dev_of_offset (dev), +"tegra_car_reset" ,dev_ofnode (dev), &child);if (ret)return ret;
drivers/net/keystone_net.c +3 -3
@@ -1008,8 +1008,8 @@ static int ks2_eth_bind_slaves(struct udevice *dev, int gbe, int *gbe_0) slave_name =malloc (20 );snprintf (slave_name,20 ,"netcp at slave-%d" , slave_no); ret =device_bind_driver_to_node (dev,"eth_ks2_sl" , - slave_name, slave, - &sl_dev); + slave_name,offset_to_ofnode (slave), + &sl_dev);if (ret) {error ("ks2_net - not able to bind slave interfaces\n" );return ret;
@@ -1029,7 +1029,7 @@ static int ks2_eth_bind_slaves(struct udevice *dev, int gbe, int *gbe_0) slave_name =malloc (20 );snprintf (slave_name,20 ,"netcp at slave-%d" , slave_no); ret =device_bind_driver_to_node (dev,"eth_ks2_sl" , slave_name, - slave, &sl_dev); +offset_to_ofnode (slave), &sl_dev);if (ret) {error ("ks2_net - not able to bind slave interfaces\n" );return ret;
drivers/pinctrl/pinctrl-uclass.c +6 -9
@@ -121,34 +121,31 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)*/ static int pinconfig_post_bind (struct udevice *dev) { -const void *fdt = gd->fdt_blob; -int offset =dev_of_offset (dev);bool pre_reloc_only = !(gd->flags &GD_FLG_RELOC );const char *name; +ofnode node;int ret; -for (offset =fdt_first_subnode (fdt, offset); - offset >0 ; - offset =fdt_next_subnode (fdt, offset)) { +dev_for_each_subnode (node, dev) {if (pre_reloc_only && - !dm_fdt_pre_reloc (fdt, offset)) + !ofnode_pre_reloc (node))continue ;/* * If this node has "compatible" property, this is not * a pin configuration node, but a normal device. skip. */ -fdt_get_property (fdt, offset,"compatible" , &ret); +ofnode_read_prop (node,"compatible" , &ret);if (ret >=0 )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,"pinconfig" , name, - offset,NULL ); + node,NULL );if (ret)return ret; }
drivers/usb/musb-new/ti-musb.c +1 -1
@@ -227,7 +227,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)case USB_DR_MODE_HOST :/* Bind MUSB host */ ret =device_bind_driver_to_node (parent,"ti-musb-host" , - name, node, &dev); + name,offset_to_ofnode (node), &dev);if (ret) {error ("musb - not able to bind usb host node\n" );return ret;
include/dm.h +2 -0
@@ -10,6 +10,8 @@#include <dm/ofnode.h> #include <dm/device.h> #include <dm/fdtaddr.h> +#include <dm/ofnode.h> +#include <dm/read.h> #include <dm/platdata.h> #include <dm/uclass.h>
include/dm/lists.h +1 -1
@@ -85,7 +85,7 @@ int device_bind_driver(struct udevice *parent, const char *drv_name,* @devp: If non-NULL, returns the newly bound device */ int device_bind_driver_to_node (struct udevice *parent,const char *drv_name, -const char *dev_name,int node, +const char *dev_name,ofnode node,struct udevice **devp);#endif
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 17/72 dm: core: Update device_bind_driver_to_node() to use ofnode
Adjust this function to us an ofnode instead of an offset, so it can be used with livetree. This involves updating all callers.
---
Changes in v3: None
Changes in v2: None
drivers/clk/at91/pmc.c | 2 +- drivers/core/lists.c | 15 ++++++--------- drivers/cpu/cpu-uclass.c | 6 +++--- drivers/i2c/muxes/i2c-mux-uclass.c | 11 ++++------- drivers/led/led_bcm6328.c | 2 +- drivers/led/led_bcm6358.c | 2 +- drivers/led/led_gpio.c | 13 +++++-------- drivers/misc/tegra186_bpmp.c | 6 +++--- drivers/misc/tegra_car.c | 4 ++-- drivers/net/keystone_net.c | 6 +++--- drivers/pinctrl/pinctrl-uclass.c | 15 ++++++--------- drivers/usb/musb-new/ti-musb.c | 2 +- include/dm.h | 2 ++ include/dm/lists.h | 2 +- 14 files changed, 39 insertions(+), 49 deletions(-)
Applied to u-boot-dm
PATCH v3 18/72 dm: core: Scan the live tree when setting up driver model
In reply to Simon GlassWhen starting up driver model with a live tree we need to scan the tree for devices. Add code to handle this.
---
Changes in v3: None
Changes in v2: None
drivers/core/root.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---- include/dm/root.h | 3 ++- test/dm/test-main.c | 4 ++-- 3 files changed, 58 insertions(+), 7 deletions(-)
drivers/core/root.c +54 -4
@@ -15,7 +15,10 @@#include <dm/device.h> #include <dm/device-internal.h> #include <dm/lists.h> +#include <dm/of.h> +#include <dm/of_access.h> #include <dm/platdata.h> +#include <dm/read.h> #include <dm/root.h> #include <dm/uclass.h> #include <dm/util.h>
@@ -147,7 +150,7 @@ void fix_devices(void)#endif -int dm_init (void ) +int dm_init (bool of_live) {int ret;
@@ -167,7 +170,12 @@ int dm_init(void)if (ret)return ret;#if CONFIG_IS_ENABLED (OF_CONTROL ) -DM_ROOT_NON_CONST ->node =offset_to_ofnode (0 ); +# if CONFIG_IS_ENABLED (OF_LIVE ) +if (of_live) +DM_ROOT_NON_CONST ->node =np_to_ofnode (gd->of_root); + else +#endif +DM_ROOT_NON_CONST ->node =offset_to_ofnode (0 );#endif ret =device_probe (DM_ROOT_NON_CONST );if (ret)
@@ -206,6 +214,36 @@ int dm_scan_platdata(bool pre_reloc_only)return ret; } +#if CONFIG_IS_ENABLED (OF_LIVE ) +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 (pre_reloc_only && + !of_find_property (np,"u-boot,dm-pre-reloc" ,NULL )) +continue ; +if (!of_device_is_available (np)) { +dm_dbg (" - ignoring disabled device\n" ); +continue ; + } + err =lists_bind_fdt (parent,np_to_ofnode (np),NULL ); +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; +} +#endif /* CONFIG_IS_ENABLED(OF_LIVE) */ +#if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )/** * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node
@@ -251,15 +289,27 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,int dm_scan_fdt_dev (struct udevice *dev) { -if (dev_of_offset (dev) ==-1 ) +if (!dev_of_valid (dev))return 0 ; +#if CONFIG_IS_ENABLED (OF_LIVE ) +if (of_live_active ()) +return dm_scan_fdt_live (dev,dev_np (dev), + gd->flags &GD_FLG_RELOC ? false : true); + else +#endif return dm_scan_fdt_node (dev, gd->fdt_blob,dev_of_offset (dev), gd->flags &GD_FLG_RELOC ? false : true); }int dm_scan_fdt (const void *blob,bool pre_reloc_only) { +#if CONFIG_IS_ENABLED (OF_LIVE ) +if (of_live_active ()) +return dm_scan_fdt_live (gd->dm_root, gd->of_root, + pre_reloc_only); + else +#endif return dm_scan_fdt_node (gd->dm_root, blob,0 , pre_reloc_only); }#endif
@@ -273,7 +323,7 @@ int dm_init_and_scan(bool pre_reloc_only) {int ret; - ret =dm_init (); + ret =dm_init (IS_ENABLED (CONFIG_OF_LIVE ));if (ret) {debug ("dm_init() failed: %d\n" , ret);return ret;
include/dm/root.h +2 -1
@@ -87,9 +87,10 @@ int dm_init_and_scan(bool pre_reloc_only);* This function will initialize roots of driver tree and class tree. * This needs to be called before anything uses the DM * +* @of_live: Enable live device tree * @return 0 if OK, -ve on error */ -int dm_init (void ); +int dm_init (bool of_live);/** * dm_uninit - Uninitialise Driver Model structures
test/dm/test-main.c +2 -2
@@ -30,7 +30,7 @@ static int dm_test_init(struct unit_test_state *uts) gd->dm_root =NULL ;memset (dm_testdrv_op_count,'\0' ,sizeof (dm_testdrv_op_count)); -ut_assertok (dm_init ()); +ut_assertok (dm_init (false)); dms->root =dm_root ();return 0 ;
@@ -137,7 +137,7 @@ static int dm_test_main(const char *test_name)printf ("Failures: %d\n" , uts->fail_count); gd->dm_root =NULL ; -ut_assertok (dm_init ()); +ut_assertok (dm_init (false));dm_scan_platdata (false);dm_scan_fdt (gd->fdt_blob, false);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 18/72 dm: core: Scan the live tree when setting up driver model
When starting up driver model with a live tree we need to scan the tree for devices. Add code to handle this.
---
Changes in v3: None
Changes in v2: None
drivers/core/root.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---- include/dm/root.h | 3 ++- test/dm/test-main.c | 4 ++-- 3 files changed, 58 insertions(+), 7 deletions(-)
Applied to u-boot-dm
PATCH v3 19/72 dm: core: Add a way to find a device by ofnode
In reply to Simon GlassAdd a function which looks up a device by its node (either in live tree or flat tree).
---
Changes in v3: None
Changes in v2: None
drivers/core/uclass.c | 37 +++++++++++++++++++++++++++++++++++++ include/dm/uclass-internal.h | 18 ++++++++++++++++++ include/dm/uclass.h | 17 +++++++++++++++++ 3 files changed, 72 insertions(+)
drivers/core/uclass.c +37 -0
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <malloc.h> #include <dm/device.h>
@@ -287,6 +288,30 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node,return -ENODEV ; } +int uclass_find_device_by_ofnode (enum uclass_id id,ofnode node, +struct udevice **devp) +{ +struct uclass *uc; +struct udevice *dev; +int ret; + + *devp =NULL ; +if (!ofnode_valid (node)) +return -ENODEV ; + ret =uclass_get (id, &uc); +if (ret) +return ret; + +list_for_each_entry (dev, &uc->dev_head, uclass_node) { +if (ofnode_equal (dev_ofnode (dev), node)) { + *devp = dev; +return 0 ; + } + } + +return -ENODEV ; +} +#if CONFIG_IS_ENABLED (OF_CONTROL ) static int uclass_find_device_by_phandle(enum uclass_id id, struct udevice *parent,
@@ -407,6 +432,18 @@ int uclass_get_device_by_of_offset(enum uclass_id id, int node,return uclass_get_device_tail (dev, ret, devp); } +int uclass_get_device_by_ofnode (enum uclass_id id,ofnode node, +struct udevice **devp) +{ +struct udevice *dev; +int ret; + + *devp =NULL ; + ret =uclass_find_device_by_ofnode (id, node, &dev); + +return uclass_get_device_tail (dev, ret, devp); +} +#if CONFIG_IS_ENABLED (OF_CONTROL )int uclass_get_device_by_phandle (enum uclass_id id,struct udevice *parent,const char *name,struct udevice **devp)
include/dm/uclass-internal.h +18 -0
@@ -10,6 +10,8 @@#ifndef _DM_UCLASS_INTERNAL_H#define _DM_UCLASS_INTERNAL_H +#include <dm/ofnode.h> +/** * uclass_get_device_tail() - handle the end of a get_device call *
@@ -115,6 +117,22 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node, struct udevice **devp);/** +* uclass_find_device_by_of_node() - Find a uclass device by device tree node +* +* This searches the devices in the uclass for one attached to the given +* device tree node. +* +* The device is NOT probed, it is merely returned. +* +* @id: ID to look up +* @node: Device tree offset to search for (if NULL then -ENODEV is returned) +* @devp: Returns pointer to device (there is only one for each node) +* @return 0 if OK, -ve on error +*/ +int uclass_find_device_by_ofnode (enum uclass_id id,ofnode node, +struct udevice **devp); + +/** * uclass_bind_device() - Associate device with a uclass * * Connect the device into uclass's list of devices.
include/dm/uclass.h +17 -0
@@ -10,6 +10,7 @@#ifndef _DM_UCLASS_H#define _DM_UCLASS_H +#include <dm/ofnode.h> #include <dm/uclass-id.h> #include <linker_lists.h> #include <linux/list.h>
@@ -186,6 +187,22 @@ int uclass_get_device_by_of_offset(enum uclass_id id, int node, struct udevice **devp);/** +* uclass_get_device_by_ofnode() - Get a uclass device by device tree node +* +* This searches the devices in the uclass for one attached to the given +* device tree node. +* +* The device is probed to activate it ready for use. +* +* @id: ID to look up +* @np: Device tree node to search for (if NULL then -ENODEV is returned) +* @devp: Returns pointer to device (there is only one for each node) +* @return 0 if OK, -ve on error +*/ +int uclass_get_device_by_ofnode (enum uclass_id id,ofnode node, +struct udevice **devp); + +/** * uclass_get_device_by_phandle() - Get a uclass device by phandle * * This searches the devices in the uclass for one with the given phandle.
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 19/72 dm: core: Add a way to find a device by ofnode
Add a function which looks up a device by its node (either in live tree or flat tree).
---
Changes in v3: None
Changes in v2: None
drivers/core/uclass.c | 37 +++++++++++++++++++++++++++++++++++++ include/dm/uclass-internal.h | 18 ++++++++++++++++++ include/dm/uclass.h | 17 +++++++++++++++++ 3 files changed, 72 insertions(+)
Applied to u-boot-dm
PATCH v3 20/72 dm: regmap: Add support for livetree
In reply to Simon GlassModify regmap to support livetree.
---
Changes in v3: None
Changes in v2: None
drivers/core/regmap.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/core/regmap.c +22 -15
@@ -12,8 +12,9 @@#include <malloc.h> #include <mapmem.h> #include <regmap.h> -#include <asm/io.h> +#include <dm/of_addr.h> +#include <linux/ioport.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -62,25 +63,25 @@ int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count,#else int regmap_init_mem (struct udevice *dev,struct regmap **mapp) { -const void *blob = gd->fdt_blob;struct regmap_range *range; -const fdt32_t *cell;struct regmap *map;int count;int addr_len, size_len, both_len; -int parent;int len;int index; +ofnode node =dev_ofnode (dev); +struct resource r; - parent =dev_of_offset (dev->parent); - addr_len =fdt_address_cells (blob, parent); - size_len =fdt_size_cells (blob, parent); + addr_len =dev_read_addr_cells (dev->parent); + size_len =dev_read_size_cells (dev->parent); both_len = addr_len + size_len; - cell =fdt_getprop (blob,dev_of_offset (dev),"reg" , &len); - len /=sizeof (*cell); + len =dev_read_size (dev,"reg" ); +if (len <0 ) +return len; + len /=sizeof (fdt32_t); count = len / both_len; -if (!cell || !count) +if (!count)return -EINVAL ; map =regmap_alloc_count (count);
@@ -88,12 +89,18 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)return -ENOMEM ;for (range = map->range, index =0 ; count >0 ; - count--, cell += both_len, range++, index++) { + count--, range++, index++) {fdt_size_t sz; - range->start =fdtdec_get_addr_size_fixed (blob, -dev_of_offset (dev),"reg" , index, addr_len, - size_len, &sz, true); - range->size = sz; +if (of_live_active ()) { +of_address_to_resource (ofnode_to_np (node), index, &r); + range->start = r.start; + range->size = r.end - r.start +1 ; + }else { + range->start =fdtdec_get_addr_size_fixed (gd->fdt_blob, +dev_of_offset (dev),"reg" , index, + addr_len, size_len, &sz, true); + range->size = sz; + } } map->base = map->range[0 ].start;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 20/72 dm: regmap: Add support for livetree
Modify regmap to support livetree.
---
Changes in v3: None
Changes in v2: None
drivers/core/regmap.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
Applied to u-boot-dm
PATCH v3 21/72 dm: simple-bus: Add support for livetree
In reply to Simon GlassModify simple-bus to support livetree.
---
Changes in v3: None
Changes in v2: None
drivers/core/simple-bus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/core/simple-bus.c +1 -2
@@ -33,8 +33,7 @@ static int simple_bus_post_bind(struct udevice *dev)u32 cell[3 ];int ret; - ret =fdtdec_get_int_array (gd->fdt_blob,dev_of_offset (dev),"ranges" , - cell,ARRAY_SIZE (cell)); + ret =dev_read_u32_array (dev,"ranges" , cell,ARRAY_SIZE (cell));if (!ret) {struct simple_bus_plat *plat =dev_get_uclass_platdata (dev);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 21/72 dm: simple-bus: Add support for livetree
Modify simple-bus to support livetree.
---
Changes in v3: None
Changes in v2: None
drivers/core/simple-bus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 22/72 dm: core: Update uclass_find_device_by_phandle() for livetree
In reply to Simon GlassAdjust this function to work with livetree.
---
Changes in v3: None
Changes in v2: None
drivers/core/uclass.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/core/uclass.c +2 -3
@@ -324,8 +324,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id,int ret; *devp =NULL ; - find_phandle =fdtdec_get_int (gd->fdt_blob,dev_of_offset (parent), name, --1 ); + find_phandle =dev_read_u32_default (parent, name,-1 );if (find_phandle <=0 )return -ENOENT ; ret =uclass_get (id, &uc);
@@ -335,7 +334,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id,list_for_each_entry (dev, &uc->dev_head, uclass_node) {uint phandle; - phandle =fdt_get_phandle (gd->fdt_blob,dev_of_offset (dev)); + phandle =dev_read_phandle (dev);if (phandle == find_phandle) { *devp = dev;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 22/72 dm: core: Update uclass_find_device_by_phandle() for livetree
Adjust this function to work with livetree.
---
Changes in v3: None
Changes in v2: None
drivers/core/uclass.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Applied to u-boot-dm
PATCH v3 23/72 sandbox: Add a way to reset sandbox state for tests
In reply to Simon GlassRunning a new test should reset the sandbox state to avoid tests interferring with each other. Move the existing state-reset code into a function so it can be used from tests.
Also update the code to reset the SPI devices and adjust the test code to call it.
---
Changes in v3:
- Clear the watchdog state also
Changes in v2: None
arch/sandbox/cpu/state.c | 15 +++++++++++---- arch/sandbox/include/asm/state.h | 7 +++++++ test/dm/test-main.c | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)
arch/sandbox/cpu/state.c +11 -4
@@ -351,6 +351,16 @@ bool state_get_skip_delays(void)return state->skip_delays; } +void state_reset_for_test (struct sandbox_state *state) +{ +/* No reset yet, so mark it as such. Always allow power reset */ + state->last_sysreset =SYSRESET_COUNT ; + state->sysreset_allowed[SYSRESET_POWER ] = true; + +memset (&state->wdt,'\0' ,sizeof (state->wdt)); +memset (state->spi,'\0' ,sizeof (state->spi)); +} +int state_init (void ) { state = &main_state;
@@ -359,10 +369,7 @@ int state_init(void) state->ram_buf =os_malloc (state->ram_size);assert (state->ram_buf); -/* No reset yet, so mark it as such. Always allow power reset */ - state->last_sysreset =SYSRESET_COUNT ; - state->sysreset_allowed[SYSRESET_POWER ] = true; - +state_reset_for_test (state);/* * Example of how to use GPIOs: *
arch/sandbox/include/asm/state.h +7 -0
@@ -214,6 +214,13 @@ void state_set_skip_delays(bool skip_delays);bool state_get_skip_delays (void );/** +* state_reset_for_test() - Reset ready to re-run tests +* +* This clears out any test state ready for another test run. +*/ +void state_reset_for_test (struct sandbox_state *state); + +/** * Initialize the test system state */ int state_init (void );
test/dm/test-main.c +1 -0
@@ -29,6 +29,7 @@ static int dm_test_init(struct unit_test_state *uts)memset (dms,'\0' ,sizeof (*dms)); gd->dm_root =NULL ;memset (dm_testdrv_op_count,'\0' ,sizeof (dm_testdrv_op_count)); +state_reset_for_test (state_get_current ());ut_assertok (dm_init (false)); dms->root =dm_root ();
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 23/72 sandbox: Add a way to reset sandbox state for tests
Running a new test should reset the sandbox state to avoid tests interferring with each other. Move the existing state-reset code into a function so it can be used from tests.
Also update the code to reset the SPI devices and adjust the test code to call it.
---
Changes in v3:
- Clear the watchdog state also
Changes in v2: None
arch/sandbox/cpu/state.c | 15 +++++++++++---- arch/sandbox/include/asm/state.h | 7 +++++++ test/dm/test-main.c | 1 + 3 files changed, 19 insertions(+), 4 deletions(-)
Applied to u-boot-dm
PATCH v3 24/72 dm: test: Move test running code into a separate function
In reply to Simon GlassWe want to run the same test on flat and live trees. In preparation for this, create a new function which handles running a test.
---
Changes in v3: None
Changes in v2: None
test/dm/test-main.c | 56 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 24 deletions(-)
test/dm/test-main.c +32 -24
@@ -72,12 +72,42 @@ static int dm_test_destroy(struct unit_test_state *uts)return 0 ; } +static int dm_do_test (struct unit_test_state *uts,struct unit_test *test) +{ +struct sandbox_state *state =state_get_current (); + +printf ("Test: %s\n" , test->name); +ut_assertok (dm_test_init (uts)); + + uts->start =mallinfo (); +if (test->flags &DM_TESTF_SCAN_PDATA ) +ut_assertok (dm_scan_platdata (false)); +if (test->flags &DM_TESTF_PROBE_TEST ) +ut_assertok (do_autoprobe (uts)); +if (test->flags &DM_TESTF_SCAN_FDT ) +ut_assertok (dm_scan_fdt (gd->fdt_blob, false)); + +/* +* Silence the console and rely on console reocrding to get +* our output. +*/ +console_record_reset (); +if (!state->show_test_output) + gd->flags |=GD_FLG_SILENT ; + test->func (uts); + gd->flags &= ~GD_FLG_SILENT ; +state_set_skip_delays (false); + +ut_assertok (dm_test_destroy (uts)); + +return 0 ; +} +static int dm_test_main (const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test);struct unit_test_state *uts = &global_dm_test_state; -struct sandbox_state *state =state_get_current (); uts->priv = &_global_priv_dm_test_state;struct unit_test *test;int run_count;
@@ -106,30 +136,8 @@ static int dm_test_main(const char *test_name) name +=8 ;if (test_name &&strcmp (test_name, name))continue ; -printf ("Test: %s\n" , test->name); +ut_assertok (dm_do_test (uts, test)); run_count++; -ut_assertok (dm_test_init (uts)); - - uts->start =mallinfo (); -if (test->flags &DM_TESTF_SCAN_PDATA ) -ut_assertok (dm_scan_platdata (false)); -if (test->flags &DM_TESTF_PROBE_TEST ) -ut_assertok (do_autoprobe (uts)); -if (test->flags &DM_TESTF_SCAN_FDT ) -ut_assertok (dm_scan_fdt (gd->fdt_blob, false)); - -/* -* Silence the console and rely on console reocrding to get -* our output. -*/ -console_record_reset (); -if (!state->show_test_output) - gd->flags |=GD_FLG_SILENT ; - test->func (uts); - gd->flags &= ~GD_FLG_SILENT ; -state_set_skip_delays (false); - -ut_assertok (dm_test_destroy (uts)); }if (test_name && !run_count)
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 24/72 dm: test: Move test running code into a separate function
We want to run the same test on flat and live trees. In preparation for this, create a new function which handles running a test.
---
Changes in v3: None
Changes in v2: None
test/dm/test-main.c | 56 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 24 deletions(-)
Applied to u-boot-dm
PATCH v3 25/72 dm: test: Show the test filename when running
In reply to Simon GlassShow the filename of the test being run. Skip the path and show just the base name.
---
Changes in v3: None
Changes in v2: None
include/test/test.h | 2 ++ test/dm/test-main.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
include/test/test.h +2 -0
@@ -30,6 +30,7 @@ struct unit_test_state {* @flags: Flags indicated pre-conditions for test */ struct unit_test { +const char *file;const char *name;int (*func)(struct unit_test_state *state);int flags;
@@ -38,6 +39,7 @@ struct unit_test {/* Declare a new unit test */ #define UNIT_TEST (_name, _flags, _suite) \ ll_entry_declare(struct unit_test, _name, _suite) = { \ + .file = __FILE__, \ .name = #_name, \ .flags = _flags, \ .func = _name, \
test/dm/test-main.c +2 -1
@@ -75,8 +75,9 @@ static int dm_test_destroy(struct unit_test_state *uts)static int dm_do_test (struct unit_test_state *uts,struct unit_test *test) {struct sandbox_state *state =state_get_current (); +const char *fname =strrchr (test->file,'/' ) +1 ; -printf ("Test: %s\n" , test->name); +printf ("Test: %s: %s\n" , test->name, fname);ut_assertok (dm_test_init (uts)); uts->start =mallinfo ();
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 25/72 dm: test: Show the test filename when running
Show the filename of the test being run. Skip the path and show just the base name.
---
Changes in v3: None
Changes in v2: None
include/test/test.h | 2 ++ test/dm/test-main.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 26/72 dm: test: Add support for running tests with livetree
In reply to Simon GlassIt is useful to run the driver model tests with both livetree and flat tree in case something is different between the two. Add this feature to the test runner.
---
Changes in v3: None
Changes in v2: None
test/dm/test-main.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
test/dm/test-main.c +16 -7
@@ -22,7 +22,7 @@ struct unit_test_state global_dm_test_state;static struct dm_test_state _global_priv_dm_test_state;/* Get ready for testing */ -static int dm_test_init (struct unit_test_state *uts) +static int dm_test_init (struct unit_test_state *uts,bool of_live) {struct dm_test_state *dms = uts->priv;
@@ -31,7 +31,11 @@ static int dm_test_init(struct unit_test_state *uts)memset (dm_testdrv_op_count,'\0' ,sizeof (dm_testdrv_op_count));state_reset_for_test (state_get_current ()); -ut_assertok (dm_init (false)); +#ifdef CONFIG_OF_LIVE +/* Determine whether to make the live tree available */ + gd->of_root = of_live ? uts->of_root :NULL ; +#endif +ut_assertok (dm_init (of_live)); dms->root =dm_root ();return 0 ;
@@ -72,13 +76,15 @@ static int dm_test_destroy(struct unit_test_state *uts)return 0 ; } -static int dm_do_test (struct unit_test_state *uts,struct unit_test *test) +static int dm_do_test (struct unit_test_state *uts,struct unit_test *test, +bool of_live) {struct sandbox_state *state =state_get_current ();const char *fname =strrchr (test->file,'/' ) +1 ; -printf ("Test: %s: %s\n" , test->name, fname); -ut_assertok (dm_test_init (uts)); +printf ("Test: %s: %s%s\n" , test->name, fname, + !of_live ?" (flat tree)" :"" ); +ut_assertok (dm_test_init (uts, of_live)); uts->start =mallinfo ();if (test->flags &DM_TESTF_SCAN_PDATA )
@@ -109,10 +115,10 @@ static int dm_test_main(const char *test_name) struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test);struct unit_test_state *uts = &global_dm_test_state; - uts->priv = &_global_priv_dm_test_state;struct unit_test *test;int run_count; + uts->priv = &_global_priv_dm_test_state; uts->fail_count =0 ;/*
@@ -129,6 +135,9 @@ static int dm_test_main(const char *test_name)printf ("Running %d driver model tests\n" , n_ents); run_count =0 ; +#ifdef CONFIG_OF_LIVE + uts->of_root = gd->of_root; +#endif for (test = tests; test < tests + n_ents; test++) {const char *name = test->name;
@@ -137,7 +146,7 @@ static int dm_test_main(const char *test_name) name +=8 ;if (test_name &&strcmp (test_name, name))continue ; -ut_assertok (dm_do_test (uts, test)); +ut_assertok (dm_do_test (uts, test, false)); run_count++; }
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 26/72 dm: test: Add support for running tests with livetree
It is useful to run the driver model tests with both livetree and flat tree in case something is different between the two. Add this feature to the test runner.
---
Changes in v3: None
Changes in v2: None
test/dm/test-main.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
Applied to u-boot-dm
PATCH v3 27/72 dm: core: Run tests with both livetree and flat tree
In reply to Simon GlassSome tests require either livetree or flat tree. Add flags to allow the tests to specify this. Adjust the test runner to run with livetree (if supported) and then flat tree.
Some video tests are quite slow and running on flat tree adds little extra test value, so run these on livetree only.
---
Changes in v3: None
Changes in v2: None
include/dm/test.h | 2 ++ include/test/test.h | 2 ++ test/dm/test-main.c | 38 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-)
include/dm/test.h +2 -0
@@ -150,6 +150,8 @@ enum {DM_TESTF_SCAN_PDATA =1 <<0 ,/* test needs platform data */ DM_TESTF_PROBE_TEST =1 <<1 ,/* probe test uclass */ DM_TESTF_SCAN_FDT =1 <<2 ,/* scan device tree */ +DM_TESTF_FLAT_TREE =1 <<3 ,/* test needs flat DT */ + DM_TESTF_LIVE_TREE = 1 << 4, /* needs live device tree */ };/* Declare a new driver model test */
include/test/test.h +2 -0
@@ -15,11 +15,13 @@* @fail_count: Number of tests that failed * @start: Store the starting mallinfo when doing leak test * @priv: A pointer to some other info some suites want to track +* @of_root: Record of the livetree root node (used for setting up tests) */ struct unit_test_state {int fail_count;struct mallinfo start;void *priv; +struct device_node *of_root; };/**
test/dm/test-main.c +36 -2
@@ -110,6 +110,21 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,return 0 ; } +/** +* dm_test_run_on_flattree() - Check if we should run a test with flat DT +* +* This skips long/slow tests where there is not much value in running a flat +* DT test in addition to a live DT test. +* +* @return true to run the given test on the flat device tree +*/ +static bool dm_test_run_on_flattree (struct unit_test *test) +{ +const char *fname =strrchr (test->file,'/' ) +1 ; + +return !strstr (fname,"video" ) ||strstr (test->name,"video_base" ); +} +static int dm_test_main (const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test);
@@ -140,14 +155,33 @@ static int dm_test_main(const char *test_name)#endif for (test = tests; test < tests + n_ents; test++) {const char *name = test->name; +int runs;/* All tests have this prefix */ if (!strncmp (name,"dm_test_" ,8 )) name +=8 ;if (test_name &&strcmp (test_name, name))continue ; -ut_assertok (dm_do_test (uts, test, false)); - run_count++; + +/* Run with the live tree if possible */ + runs =0 ; +if (IS_ENABLED (CONFIG_OF_LIVE )) { +if (!(test->flags &DM_TESTF_FLAT_TREE )) { +ut_assertok (dm_do_test (uts, test, true)); + runs++; + } + } + +/* +* Run with the flat tree if we couldn't run it with live tree, +* or it is a core test. +*/ +if (!(test->flags &DM_TESTF_LIVE_TREE ) && + (!runs ||dm_test_run_on_flattree (test))) { +ut_assertok (dm_do_test (uts, test, false)); + runs++; + } + run_count += runs; }if (test_name && !run_count)
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 27/72 dm: core: Run tests with both livetree and flat tree
Some tests require either livetree or flat tree. Add flags to allow the tests to specify this. Adjust the test runner to run with livetree (if supported) and then flat tree.
Some video tests are quite slow and running on flat tree adds little extra test value, so run these on livetree only.
---
Changes in v3: None
Changes in v2: None
include/dm/test.h | 2 ++ include/test/test.h | 2 ++ test/dm/test-main.c | 38 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 28/72 dm: gpio: Refactor to prepare for live tree support
In reply to Simon GlassMove the main part of the GPIO request function into a separate function so that it can be used by the live tree function when added. Update the xlate method to use a node reference.
Update all GPIO drivers to handle the modified xlate() method.
---
Changes in v3: None
Changes in v2: None
drivers/gpio/74x164_gpio.c | 2 +- drivers/gpio/gpio-uclass.c | 51 ++++++++++++++++++++++++++------------------ drivers/gpio/pca953x_gpio.c | 2 +- drivers/gpio/sandbox.c | 3 ++- drivers/gpio/sunxi_gpio.c | 2 +- drivers/gpio/tegra186_gpio.c | 2 +- drivers/gpio/tegra_gpio.c | 2 +- include/asm-generic/gpio.h | 6 ++++-- 8 files changed, 41 insertions(+), 29 deletions(-)
drivers/gpio/74x164_gpio.c +1 -1
@@ -106,7 +106,7 @@ static int gen_74x164_get_function(struct udevice *dev, unsigned offset) }static int gen_74x164_xlate (struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) { desc->offset = args->args[0 ]; desc->flags = args->args[1 ] &GPIO_ACTIVE_LOW ?GPIOD_ACTIVE_LOW :0 ;
drivers/gpio/gpio-uclass.c +30 -21
93 lines not on this page · raw message
drivers/gpio/pca953x_gpio.c +1 -1
@@ -228,7 +228,7 @@ static int pca953x_get_function(struct udevice *dev, unsigned offset) }static int pca953x_xlate (struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) { desc->offset = args->args[0 ]; desc->flags = args->args[1 ] &GPIO_ACTIVE_LOW ?GPIOD_ACTIVE_LOW :0 ;
drivers/gpio/sandbox.c +2 -1
@@ -8,6 +8,7 @@#include <fdtdec.h> #include <malloc.h> #include <asm/gpio.h> +#include <dm/of.h> #include <dt-bindings/gpio/gpio.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -165,7 +166,7 @@ static int sb_gpio_get_function(struct udevice *dev, unsigned offset) }static int sb_gpio_xlate (struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) { desc->offset = args->args[0 ];if (args->args_count <2 )
drivers/gpio/sunxi_gpio.c +1 -1
@@ -217,7 +217,7 @@ static int sunxi_gpio_get_function(struct udevice *dev, unsigned offset) }static int sunxi_gpio_xlate (struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {int ret;
drivers/gpio/tegra186_gpio.c +1 -1
@@ -139,7 +139,7 @@ static int tegra186_gpio_get_function(struct udevice *dev, unsigned offset) }static int tegra186_gpio_xlate (struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {int gpio, port, ret;
drivers/gpio/tegra_gpio.c +1 -1
@@ -236,7 +236,7 @@ static int tegra_gpio_get_function(struct udevice *dev, unsigned offset) }static int tegra_gpio_xlate (struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {int gpio, port, ret;
include/asm-generic/gpio.h +4 -2
@@ -7,6 +7,8 @@#ifndef _ASM_GENERIC_GPIO_H_#define _ASM_GENERIC_GPIO_H_ +struct ofnode_phandle_args ; +/* * Generic GPIO API for U-Boot *
@@ -214,7 +216,7 @@ struct fdtdec_phandle_args;* */ int gpio_xlate_offs_flags (struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args); +struct ofnode_phandle_args *args);/** * struct struct dm_gpio_ops - Driver model GPIO operations
@@ -286,7 +288,7 @@ struct dm_gpio_ops {* @return 0 if OK, -ve on error */ int (*xlate)(struct udevice *dev,struct gpio_desc *desc, -struct fdtdec_phandle_args *args); +struct ofnode_phandle_args *args); };/**
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 28/72 dm: gpio: Refactor to prepare for live tree support
Move the main part of the GPIO request function into a separate function so that it can be used by the live tree function when added. Update the xlate method to use a node reference.
Update all GPIO drivers to handle the modified xlate() method.
---
Changes in v3: None
Changes in v2: None
drivers/gpio/74x164_gpio.c | 2 +- drivers/gpio/gpio-uclass.c | 51 ++++++++++++++++++++++++++------------------ drivers/gpio/pca953x_gpio.c | 2 +- drivers/gpio/sandbox.c | 3 ++- drivers/gpio/sunxi_gpio.c | 2 +- drivers/gpio/tegra186_gpio.c | 2 +- drivers/gpio/tegra_gpio.c | 2 +- include/asm-generic/gpio.h | 6 ++++-- 8 files changed, 41 insertions(+), 29 deletions(-)
Applied to u-boot-dm
PATCH v3 29/72 dm: gpio: Drop blank line in gpio_xlate_offs_flags() comment
In reply to Simon GlassThis is not needed. Drop it.
---
Changes in v3: None
Changes in v2: None
include/asm-generic/gpio.h | 1 - 1 file changed, 1 deletion(-)
include/asm-generic/gpio.h +0 -1
@@ -213,7 +213,6 @@ struct fdtdec_phandle_args;* * This routine sets the offset field to args[0] and the flags field to * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1]. -* */ int gpio_xlate_offs_flags (struct udevice *dev,struct gpio_desc *desc,struct ofnode_phandle_args *args);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 29/72 dm: gpio: Drop blank line in gpio_xlate_offs_flags() comment
This is not needed. Drop it.
---
Changes in v3: None
Changes in v2: None
include/asm-generic/gpio.h | 1 - 1 file changed, 1 deletion(-)
Applied to u-boot-dm
PATCH v3 30/72 dm: gpio: sandbox: Use dev_read...() functions to access DT
In reply to Simon GlassUse the new dev_read...() functions to access the device tree, so that a live tree can be used.
---
Changes in v3: None
Changes in v2: None
drivers/gpio/sandbox.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpio/sandbox.c +3 -6
@@ -198,10 +198,8 @@ static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev) {struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); - uc_priv->gpio_count =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"num-gpios" ,0 ); - uc_priv->bank_name =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), -"gpio-bank-name" ,NULL ); + uc_priv->gpio_count =dev_read_u32_default (dev,"num-gpios" ,0 ); + uc_priv->bank_name =dev_read_string (dev,"gpio-bank-name" );return 0 ; }
@@ -210,10 +208,9 @@ static int gpio_sandbox_probe(struct udevice *dev) {struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); -if (dev_of_offset (dev) ==-1 ) { +if (!dev_of_valid (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);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 30/72 dm: gpio: sandbox: Use dev_read...() functions to access DT
Use the new dev_read...() functions to access the device tree, so that a live tree can be used.
---
Changes in v3: None
Changes in v2: None
drivers/gpio/sandbox.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Applied to u-boot-dm
PATCH v3 31/72 dm: gpio: Add live tree support
In reply to Simon GlassAdd support for requesting GPIOs with a live device tree.
This involves adjusting the function signature for the legacy function gpio_request_by_name_nodev(), so fix up all callers.
---
Changes in v3: None
Changes in v2: None
board/qualcomm/dragonboard410c/dragonboard410c.c | 12 +++--- board/samsung/common/board.c | 4 +- board/samsung/common/exynos5-dt.c | 2 +- drivers/gpio/gpio-uclass.c | 51 +++++++++++------------- drivers/i2c/mxc_i2c.c | 12 +++--- drivers/mmc/fsl_esdhc.c | 6 +-- drivers/mmc/s5p_sdhci.c | 8 ++-- drivers/mtd/nand/sunxi_nand.c | 2 +- drivers/mtd/nand/tegra_nand.c | 4 +- drivers/net/pic32_eth.c | 3 +- drivers/sound/max98095.c | 2 + drivers/sound/wm8994.c | 2 +- drivers/spi/pic32_spi.c | 2 +- drivers/usb/host/ehci-tegra.c | 7 ++-- drivers/usb/host/ehci-vf.c | 5 ++- include/asm-generic/gpio.h | 10 ++--- 16 files changed, 65 insertions(+), 67 deletions(-)
board/qualcomm/dragonboard410c/dragonboard410c.c +6 -6
@@ -53,8 +53,8 @@ int board_prepare_usb(enum usb_init_type type)printf ("Failed to find usb_hub_reset_pm dt node.\n" );return node; } - ret =gpio_request_by_name_nodev (gd->fdt_blob, node,"gpios" ,0 , - &hub_reset,0 ); + ret =gpio_request_by_name_nodev (offset_to_ofnode (node), +"gpios" ,0 , &hub_reset,0 );if (ret <0 ) {printf ("Failed to request usb_hub_reset_pm gpio.\n" );return ret;
@@ -69,8 +69,8 @@ int board_prepare_usb(enum usb_init_type type)printf ("Failed to find usb_sw_sel_pm dt node.\n" );return 0 ; } - ret =gpio_request_by_name_nodev (gd->fdt_blob, node,"gpios" ,0 , - &usb_sel,0 ); + ret =gpio_request_by_name_nodev (offset_to_ofnode (node), +"gpios" ,0 , &usb_sel,0 );if (ret <0 ) {printf ("Failed to request usb_sw_sel_pm gpio.\n" );return ret;
@@ -121,8 +121,8 @@ int misc_init_r(void)return 0 ; } -if (gpio_request_by_name_nodev (gd->fdt_blob, node,"gpios" ,0 , &resin, -0 )) { +if (gpio_request_by_name_nodev (offset_to_ofnode (node),"gpios" ,0 , + &resin,0 )) {printf ("Failed to request key_vol_down button.\n" );return 0 ; }
board/samsung/common/board.c +2 -2
@@ -351,8 +351,8 @@ void reset_misc(void)if (node <0 )return ; -gpio_request_by_name_nodev (gd->fdt_blob, node,"reset-gpio" ,0 , &gpio, -GPIOD_IS_OUT ); +gpio_request_by_name_nodev (offset_to_ofnode (node),"reset-gpio" ,0 , + &gpio,GPIOD_IS_OUT );if (dm_gpio_is_valid (&gpio)) {/*
board/samsung/common/exynos5-dt.c +1 -1
@@ -45,7 +45,7 @@ static void board_enable_audio_codec(void)if (node <=0 )return ; - ret =gpio_request_by_name_nodev (gd->fdt_blob, node, + ret =gpio_request_by_name_nodev (offset_to_ofnode (node),"codec-enable-gpio" ,0 , &en_gpio,GPIOD_IS_OUT |GPIOD_IS_OUT_ACTIVE );if (ret == -FDT_ERR_NOTFOUND )
drivers/gpio/gpio-uclass.c +23 -28
84 lines not on this page · raw message
drivers/i2c/mxc_i2c.c +6 -6
@@ -773,12 +773,12 @@ static int mxc_i2c_probe(struct udevice *bus)if (ret <0 ) {debug ("i2c bus %d@0x%2lx, no gpio pinctrl state.\n" , bus->seq, i2c_bus->base); }else { - ret =gpio_request_by_name_nodev (fdt, node,"scl-gpios" , -0 , &i2c_bus->scl_gpio, -GPIOD_IS_OUT ); - ret2 =gpio_request_by_name_nodev (fdt, node,"sda-gpios" , -0 , &i2c_bus->sda_gpio, -GPIOD_IS_OUT ); + ret =gpio_request_by_name_nodev (offset_to_ofnode (node), +"scl-gpios" ,0 , &i2c_bus->scl_gpio, +GPIOD_IS_OUT ); + ret2 =gpio_request_by_name_nodev (offset_to_ofnode (node), +"sda-gpios" ,0 , &i2c_bus->sda_gpio, +GPIOD_IS_OUT );if (!dm_gpio_is_valid (&i2c_bus->sda_gpio) | !dm_gpio_is_valid (&i2c_bus->scl_gpio) | ret | ret2) {
drivers/mmc/fsl_esdhc.c +3 -3
@@ -983,15 +983,15 @@ static int fsl_esdhc_probe(struct udevice *dev) }else { priv->non_removable =0 ;#ifdef CONFIG_DM_GPIO -gpio_request_by_name_nodev (fdt, node,"cd-gpios" ,0 , - &priv->cd_gpio,GPIOD_IS_IN ); +gpio_request_by_name_nodev (offset_to_ofnode (node),"cd-gpios" , +0 , &priv->cd_gpio,GPIOD_IS_IN );#endif } priv->wp_enable =1 ;#ifdef CONFIG_DM_GPIO - ret =gpio_request_by_name_nodev (fdt, node,"wp-gpios" ,0 , + ret =gpio_request_by_name_nodev (offset_to_ofnode (node),"wp-gpios" ,0 , &priv->wp_gpio,GPIOD_IS_IN );if (ret) priv->wp_enable =0 ;
drivers/mmc/s5p_sdhci.c +4 -4
@@ -184,10 +184,10 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host) } host->ioaddr = (void *)base; -gpio_request_by_name_nodev (blob, node,"pwr-gpios" ,0 , &host->pwr_gpio, -GPIOD_IS_OUT ); -gpio_request_by_name_nodev (blob, node,"cd-gpios" ,0 , &host->cd_gpio, -GPIOD_IS_IN ); +gpio_request_by_name_nodev (offset_to_ofnode (node),"pwr-gpios" ,0 , + &host->pwr_gpio,GPIOD_IS_OUT ); +gpio_request_by_name_nodev (offset_to_ofnode (node),"cd-gpios" ,0 , + &host->cd_gpio,GPIOD_IS_IN );return 0 ; }
drivers/mtd/nand/sunxi_nand.c +1 -1
@@ -1663,7 +1663,7 @@ static int sunxi_nand_chip_init(int node, struct sunxi_nfc *nfc, int devnum) chip->sels[i].rb.type =RB_NATIVE ; chip->sels[i].rb.info.nativeid = tmp; }else { - ret =gpio_request_by_name_nodev (blob, node, + ret =gpio_request_by_name_nodev (offset_to_ofnode (node),"rb-gpios" , i, &chip->sels[i].rb.info.gpio,GPIOD_IS_IN );
drivers/mtd/nand/tegra_nand.c +2 -2
@@ -894,8 +894,8 @@ static int fdt_decode_nand(const void *blob, int node, struct fdt_nand *config) config->reg = (struct nand_ctlr *)fdtdec_get_addr (blob, node,"reg" ); config->enabled =fdtdec_get_is_enabled (blob, node); config->width =fdtdec_get_int (blob, node,"nvidia,nand-width" ,8 ); - err =gpio_request_by_name_nodev (blob, node,"nvidia,wp-gpios" ,0 , - &config->wp_gpio,GPIOD_IS_OUT ); + err =gpio_request_by_name_nodev (offset_to_ofnode (node), +"nvidia,wp-gpios" ,0 , &config->wp_gpio,GPIOD_IS_OUT );if (err)return err; err = fdtdec_get_int_array(blob, node, "nvidia,timing",
drivers/net/pic32_eth.c +1 -2
@@ -561,8 +561,7 @@ static int pic32_eth_probe(struct udevice *dev) phy_addr =fdtdec_get_int (gd->fdt_blob, offset,"reg" ,-1 );/* phy reset gpio */ -gpio_request_by_name_nodev (gd->fdt_blob,dev_of_offset (dev), -"reset-gpios" ,0 , +gpio_request_by_name_nodev (dev_ofnode (dev),"reset-gpios" ,0 , &priv->rst_gpio,GPIOD_IS_OUT ); priv->phyif = pdata->phy_interface;
drivers/sound/max98095.c +2 -0
@@ -9,6 +9,8 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +#include <common.h> #include <asm/arch/clk.h> #include <asm/arch/cpu.h> #include <asm/arch/power.h>
drivers/sound/wm8994.c +1 -1
@@ -4,11 +4,11 @@* * SPDX-License-Identifier: GPL-2.0+ */ +#include <common.h> #include <asm/arch/clk.h> #include <asm/arch/cpu.h> #include <asm/gpio.h> #include <asm/io.h> -#include <common.h> #include <div64.h> #include <fdtdec.h> #include <i2c.h>
drivers/spi/pic32_spi.c +1 -1
@@ -414,7 +414,7 @@ static int pic32_spi_probe(struct udevice *bus)* of the ongoing transfer. To avoid this sort of error we will drive * /CS manually by toggling cs-gpio pins. */ - ret =gpio_request_by_name_nodev (gd->fdt_blob, node,"cs-gpios" ,0 , + ret =gpio_request_by_name_nodev (offset_to_ofnode (node),"cs-gpios" ,0 , &priv->cs_gpio,GPIOD_IS_OUT );if (ret) {printf ("pic32-spi: error, cs-gpios not found\n" );
drivers/usb/host/ehci-tegra.c +4 -3
@@ -728,9 +728,10 @@ static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config)debug ("%s: Missing/invalid peripheral ID\n" , __func__);return -EINVAL ; } -gpio_request_by_name_nodev (blob, node,"nvidia,vbus-gpio" ,0 , - &config->vbus_gpio,GPIOD_IS_OUT ); -gpio_request_by_name_nodev (blob, node,"nvidia,phy-reset-gpio" ,0 , +gpio_request_by_name_nodev (offset_to_ofnode (node),"nvidia,vbus-gpio" , +0 , &config->vbus_gpio,GPIOD_IS_OUT ); +gpio_request_by_name_nodev (offset_to_ofnode (node), +"nvidia,phy-reset-gpio" ,0 , &config->phy_reset_gpio,GPIOD_IS_OUT ); debug("enabled=%d, legacy_mode=%d, utmi=%d, ulpi=%d, periph_id=%d, " "vbus=%d, phy_reset=%d, dr_mode=%d\n",
drivers/usb/host/ehci-vf.c +3 -2
@@ -252,8 +252,9 @@ static int vf_usb_ofdata_to_platdata(struct udevice *dev) }if (priv->dr_mode ==DR_MODE_OTG ) { -gpio_request_by_name_nodev (dt_blob, node,"fsl,cdet-gpio" ,0 , - &priv->cdet_gpio,GPIOD_IS_IN ); +gpio_request_by_name_nodev (offset_to_ofnode (node), +"fsl,cdet-gpio" ,0 , &priv->cdet_gpio, +GPIOD_IS_IN );if (dm_gpio_is_valid (&priv->cdet_gpio)) {if (dm_gpio_get_value (&priv->cdet_gpio)) priv->init_type =USB_INIT_DEVICE ;
include/asm-generic/gpio.h +5 -5
@@ -7,6 +7,8 @@#ifndef _ASM_GENERIC_GPIO_H_#define _ASM_GENERIC_GPIO_H_ +#include <dm/ofnode.h> +struct ofnode_phandle_args ;/*
@@ -488,9 +490,8 @@ int gpio_get_list_count(struct udevice *dev, const char *list_name);* This is a version of gpio_request_list_by_name() that does not use a * device. Avoid it unless the caller is not yet using driver model */ -int gpio_request_by_name_nodev (const void *blob,int node, -const char *list_name, -int index,struct gpio_desc *desc,int flags); +int gpio_request_by_name_nodev (ofnode node,const char *list_name,int index, +struct gpio_desc *desc,int flags);/** * gpio_request_list_by_name_nodev() - request GPIOs without a device
@@ -498,8 +499,7 @@ int gpio_request_by_name_nodev(const void *blob, int node,* This is a version of gpio_request_list_by_name() that does not use a * device. Avoid it unless the caller is not yet using driver model */ -int gpio_request_list_by_name_nodev (const void *blob,int node, -const char *list_name, +int gpio_request_list_by_name_nodev (ofnode node,const char *list_name,struct gpio_desc *desc_list,int max_count,int flags);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 31/72 dm: gpio: Add live tree support
Add support for requesting GPIOs with a live device tree.
This involves adjusting the function signature for the legacy function gpio_request_by_name_nodev(), so fix up all callers.
---
Changes in v3: None
Changes in v2: None
board/qualcomm/dragonboard410c/dragonboard410c.c | 12 +++--- board/samsung/common/board.c | 4 +- board/samsung/common/exynos5-dt.c | 2 +- drivers/gpio/gpio-uclass.c | 51 +++++++++++------------- drivers/i2c/mxc_i2c.c | 12 +++--- drivers/mmc/fsl_esdhc.c | 6 +-- drivers/mmc/s5p_sdhci.c | 8 ++-- drivers/mtd/nand/sunxi_nand.c | 2 +- drivers/mtd/nand/tegra_nand.c | 4 +- drivers/net/pic32_eth.c | 3 +- drivers/sound/max98095.c | 2 + drivers/sound/wm8994.c | 2 +- drivers/spi/pic32_spi.c | 2 +- drivers/usb/host/ehci-tegra.c | 7 ++-- drivers/usb/host/ehci-vf.c | 5 ++- include/asm-generic/gpio.h | 10 ++--- 16 files changed, 65 insertions(+), 67 deletions(-)
Applied to u-boot-dm
PATCH v3 32/72 cros_ec: Fix debug() statement in ec_command_inptr()
In reply to Simon GlassThis prints out the wrong pointers. Fix it.
---
Changes in v3: None
Changes in v2: None
drivers/misc/cros_ec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/cros_ec.c +1 -2
@@ -304,8 +304,7 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd, NULL, 0, &din, din_len); } -debug ("%s: len=%d, dinp=%p, *dinp=%p\n" , __func__, len, dinp, - dinp ? *dinp :NULL ); +debug ("%s: len=%d, din=%p\n" , __func__, len, din);if (dinp) {/* If we have any data to return, it must be 64bit-aligned */ assert (len <=0 || !((uintptr_t )din &7 ));
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 32/72 cros_ec: Fix debug() statement in ec_command_inptr()
This prints out the wrong pointers. Fix it.
---
Changes in v3: None
Changes in v2: None
drivers/misc/cros_ec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 33/72 cros_ec: Convert to support live tree
In reply to Simon GlassConvert this driver to support the live device tree and remove the old fdtdec support.
The keyboard is not yet converted.
---
Changes in v3: None
Changes in v2: None
drivers/misc/cros_ec.c | 33 ++++++++++++++------------------- drivers/misc/cros_ec_sandbox.c | 23 +++++++++++------------ include/cros_ec.h | 7 ++----- include/fdtdec.h | 13 ------------- lib/fdtdec.c | 32 -------------------------------- 5 files changed, 27 insertions(+), 81 deletions(-)
drivers/misc/cros_ec.c +14 -19
@@ -26,6 +26,7 @@#include <asm/io.h> #include <asm-generic/gpio.h> #include <dm/device-internal.h> +#include <dm/of_extra.h> #include <dm/uclass-internal.h> #ifdef DEBUG_TRACE
@@ -996,15 +997,12 @@ int cros_ec_get_ldo(struct udevice *dev, uint8_t index, uint8_t *state)int cros_ec_register (struct udevice *dev) {struct cros_ec_dev *cdev =dev_get_uclass_priv (dev); -const void *blob = gd->fdt_blob; -int node =dev_of_offset (dev);char id[MSG_BYTES ]; cdev->dev = dev;gpio_request_by_name (dev,"ec-interrupt" ,0 , &cdev->ec_int,GPIOD_IS_IN ); - cdev->optimise_flash_write =fdtdec_get_bool (blob, node, -"optimise-flash-write" ); + cdev->optimise_flash_write =dev_read_bool (dev,"optimise-flash-write" );if (cros_ec_check_version (cdev)) {debug ("%s: Could not detect CROS-EC version\n" , __func__);
@@ -1023,28 +1021,26 @@ int cros_ec_register(struct udevice *dev)return 0 ; } -int cros_ec_decode_ec_flash (const void *blob,int node, -struct fdt_cros_ec *config) +int cros_ec_decode_ec_flash (struct udevice *dev,struct fdt_cros_ec *config) { -int flash_node; +ofnode flash_node, node; - flash_node =fdt_subnode_offset (blob, node,"flash" ); -if (flash_node <0 ) { + flash_node =dev_read_subnode (dev,"flash" ); +if (!ofnode_valid (flash_node)) {debug ("Failed to find flash node\n" );return -1 ; } -if (fdtdec_read_fmap_entry (blob, flash_node,"flash" , - &config->flash)) { -debug ("Failed to decode flash node in chrome-ec'\n" ); +if (of_read_fmap_entry (flash_node,"flash" , &config->flash)) { +debug ("Failed to decode flash node in chrome-ec\n" );return -1 ; } - config->flash_erase_value =fdtdec_get_int (blob, flash_node, -"erase-value" ,-1 ); -for (node =fdt_first_subnode (blob, flash_node); node >=0 ; - node =fdt_next_subnode (blob, node)) { -const char *name =fdt_get_name (blob, node,NULL ); + config->flash_erase_value =ofnode_read_s32_default (flash_node, +"erase-value" ,-1 ); +for (node =ofnode_first_subnode (flash_node);ofnode_valid (node); + node =ofnode_next_subnode (node)) { +const char *name =ofnode_get_name (node);enum ec_flash_region region;if (0 ==strcmp (name,"ro" )) {
@@ -1058,8 +1054,7 @@ int cros_ec_decode_ec_flash(const void *blob, int node,return -1 ; } -if (fdtdec_read_fmap_entry (blob, node,"reg" , - &config->region[region])) { +if (of_read_fmap_entry (node,"reg" , &config->region[region])) {debug ("Failed to decode flash region in chrome-ec'\n" );return -1 ; }
drivers/misc/cros_ec_sandbox.c +11 -12
@@ -188,18 +188,16 @@ static int get_image_used(struct ec_state *ec, struct fmap_entry *entry)* RR=Row CC=Column KKKK=Key Code * * @param ec Current emulated EC state -* @param blob Device tree blob containing keyscan information * @param node Keyboard node of device tree containing keyscan information * @return 0 if ok, -1 on error */ -static int keyscan_read_fdt_matrix (struct ec_state *ec,const void *blob, -int node) +static int keyscan_read_fdt_matrix (struct ec_state *ec,ofnode node) {const u32 *cell;int upto;int len; - cell =fdt_getprop (blob, node,"linux,keymap" , &len); + cell =ofnode_read_prop (node,"linux,keymap" , &len); ec->matrix_count = len /4 ; ec->matrix =calloc (ec->matrix_count,sizeof (*ec->matrix));if (!ec->matrix) {
@@ -516,28 +514,29 @@ int cros_ec_probe(struct udevice *dev) {struct ec_state *ec = dev->priv;struct cros_ec_dev *cdev = dev->uclass_priv; -const void *blob = gd->fdt_blob;struct udevice *keyb_dev; -int node; +ofnode node;int err;memcpy (ec, &s_state,sizeof (*ec)); - err =cros_ec_decode_ec_flash (blob,dev_of_offset (dev), &ec->ec_config); -if (err) + err =cros_ec_decode_ec_flash (dev, &ec->ec_config); +if (err) { +debug ("%s: Cannot device EC flash\n" , __func__);return err; + } - node =-1 ; + node =ofnode_null ();for (device_find_first_child (dev, &keyb_dev); keyb_dev;device_find_next_child (&keyb_dev)) {if (device_get_uclass_id (keyb_dev) ==UCLASS_KEYBOARD ) { - node =dev_of_offset (keyb_dev); + node =dev_ofnode (keyb_dev);break ; } } -if (node <0 ) { +if (!ofnode_valid (node)) {debug ("%s: No cros_ec keyboard found\n" , __func__); - }else if (keyscan_read_fdt_matrix (ec, blob, node)) { + }else if (keyscan_read_fdt_matrix (ec, node)) {debug ("%s: Could not read key matrix\n" , __func__);return -1 ; }
include/cros_ec.h +2 -5
@@ -11,7 +11,6 @@#include <linux/compiler.h> #include <ec_commands.h> -#include <fdtdec.h> #include <cros_ec_message.h> #include <asm/gpio.h> #include <dm/of_extra.h>
@@ -378,12 +377,10 @@ int cros_ec_get_error(void);/** * Returns information from the FDT about the Chrome EC flash * -* @param blob FDT blob to use -* @param node Node offset to read from +* @param dev Device to read from * @param config Structure to use to return information */ -int cros_ec_decode_ec_flash (const void *blob,int node, -struct fdt_cros_ec *config); +int cros_ec_decode_ec_flash (struct udevice *dev,struct fdt_cros_ec *config);/** * Check the current keyboard state, in case recovery mode is requested.
include/fdtdec.h +0 -13
@@ -815,19 +815,6 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,int fdtdec_decode_region (const void *blob,int node,const char *prop_name,fdt_addr_t *basep,fdt_size_t *sizep); -struct fmap_entry ; -/** -* Read a flash entry from the fdt -* -* @param blob FDT blob -* @param node Offset of node to read -* @param name Name of node being read -* @param entry Place to put offset and size of this node -* @return 0 if ok, -ve on error -*/ -int fdtdec_read_fmap_entry (const void *blob,int node,const char *name, -struct fmap_entry *entry); -/** * Obtain an indexed resource from a device property. *
lib/fdtdec.c +0 -32
@@ -941,38 +941,6 @@ int fdtdec_decode_region(const void *blob, int node, const char *prop_name,return 0 ; } -/** -* Read a flash entry from the fdt -* -* @param blob FDT blob -* @param node Offset of node to read -* @param name Name of node being read -* @param entry Place to put offset and size of this node -* @return 0 if ok, -ve on error -*/ -int fdtdec_read_fmap_entry (const void *blob,int node,const char *name, -struct fmap_entry *entry) -{ -const char *prop; -u32 reg[2 ]; - -if (fdtdec_get_int_array (blob, node,"reg" , reg,2 )) { -debug ("Node '%s' has bad/missing 'reg' property\n" , name); -return -FDT_ERR_NOTFOUND ; - } - entry->offset = reg[0 ]; - entry->length = reg[1 ]; - entry->used =fdtdec_get_int (blob, node,"used" , entry->length); - prop =fdt_getprop (blob, node,"compress" ,NULL ); - entry->compress_algo = prop && !strcmp (prop,"lzo" ) ? -FMAP_COMPRESS_LZO :FMAP_COMPRESS_NONE ; - prop =fdt_getprop (blob, node,"hash" , &entry->hash_size); - entry->hash_algo = prop ?FMAP_HASH_SHA256 :FMAP_HASH_NONE ; - entry->hash = (uint8_t *)prop; - -return 0 ; -} -u64 fdtdec_get_number (const fdt32_t *ptr,unsigned int cells) {u64 number =0 ;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 33/72 cros_ec: Convert to support live tree
Convert this driver to support the live device tree and remove the old fdtdec support.
The keyboard is not yet converted.
---
Changes in v3: None
Changes in v2: None
drivers/misc/cros_ec.c | 33 ++++++++++++++------------------- drivers/misc/cros_ec_sandbox.c | 23 +++++++++++------------ include/cros_ec.h | 7 ++----- include/fdtdec.h | 13 ------------- lib/fdtdec.c | 32 -------------------------------- 5 files changed, 27 insertions(+), 81 deletions(-)
Applied to u-boot-dm
PATCH v3 34/72 sandbox: Add a new sandbox_flattree board
In reply to Simon GlassAdd a sandbox board to test the non-livetree build (i.e. with CONFIG_OF_FLAT disabled). This increases our build and test coverage.
---
Changes in v3: None
Changes in v2: None
board/sandbox/MAINTAINERS | 7 ++ configs/sandbox_flattree_defconfig | 179 +++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 configs/sandbox_flattree_defconfig
board/sandbox/MAINTAINERS +7 -0
@@ -18,3 +18,10 @@ S: Maintained F: board/sandbox/ F: include/configs/sandbox_spl.h F: configs/sandbox_spl_defconfig + +SANDBOX FLAT TREE BOARD +M: Simon Glass <[email protected]> +S: Maintained +F: board/sandbox/ +F: include/configs/sandbox.h +F: configs/sandbox_flattree_defconfig
configs/sandbox_flattree_defconfig new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 34/72 sandbox: Add a new sandbox_flattree board
Add a sandbox board to test the non-livetree build (i.e. with CONFIG_OF_FLAT disabled). This increases our build and test coverage.
---
Changes in v3: None
Changes in v2: None
board/sandbox/MAINTAINERS | 7 ++ configs/sandbox_flattree_defconfig | 179 +++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 configs/sandbox_flattree_defconfig
Applied to u-boot-dm
PATCH v3 35/72 test: Update 'make test' to run more tests
In reply to Simon GlassThe standard sandbox board cannot run the of-platdata test since it needs SPL. Also, we should test the flat tree version of sandbox.
Add these tests to the default test script.
---
Changes in v3: None
Changes in v2: None
test/run | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
test/run +7 -1
@@ -1,4 +1,10 @@ #!/bin/sh -# Run all tests +# Run all tests that the standard sandbox build can support ./test/py/test.py --bd sandbox --build + +# Run tests which require sandbox_spl +./test/py/test.py --bd sandbox_spl --build -k test/py/tests/test_ofplatdata.py + +# Run tests for the flat DT version of sandbox +./test/py/test.py --bd sandbox_flattree --build
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 35/72 test: Update 'make test' to run more tests
The standard sandbox board cannot run the of-platdata test since it needs SPL. Also, we should test the flat tree version of sandbox.
Add these tests to the default test script.
---
Changes in v3: None
Changes in v2: None
test/run | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 36/72 fdt: Rename a few functions in fdt_support
In reply to Simon GlassThese two functions have an of_ prefix which conflicts with naming used in of_addr. Rename them:
fdt_read_number
fdt_support_bus_default_count_cells
---
Changes in v3: None
Changes in v2: None
arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 4 ++-- arch/arm/mach-tegra/tegra186/nvtboot_mem.c | 4 ++-- common/fdt_support.c | 26 +++++++++++++------------- drivers/core/ofnode.c | 4 ++-- drivers/mtd/altera_qspi.c | 2 +- drivers/mtd/cfi_flash.c | 2 +- drivers/mtd/pic32_flash.c | 2 +- drivers/net/altera_tse.c | 2 +- include/fdt_support.h | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +2 -2
@@ -79,13 +79,13 @@ remove_psci_node:puts ("couldn't find /cpus node\n" );return ; } -of_bus_default_count_cells (blob, off, &addr_cells,NULL ); +fdt_support_default_count_cells (blob, off, &addr_cells,NULL ); off =fdt_node_offset_by_prop_value (blob,-1 ,"device_type" ,"cpu" ,4 );while (off != -FDT_ERR_NOTFOUND ) { reg = (fdt32_t *)fdt_getprop (blob, off,"reg" ,0 );if (reg) { - core_id =of_read_number (reg, addr_cells); + core_id =fdt_read_number (reg, addr_cells);if (core_id ==0 || (is_core_online (core_id))) { val = spin_tbl_addr; val += id_to_core(core_id) *
arch/arm/mach-tegra/tegra186/nvtboot_mem.c +2 -2
@@ -60,9 +60,9 @@ int dram_init(void) gd->ram_size =0 ;for (i =0 ; i < len; i++) { - ram_banks[i].start =of_read_number (prop, na); + ram_banks[i].start =fdt_read_number (prop, na); prop += na; - ram_banks[i].size =of_read_number (prop, ns); + ram_banks[i].size =fdt_read_number (prop, ns); prop += ns; gd->ram_size += ram_banks[i].size; }
common/fdt_support.c +13 -13
@@ -1008,7 +1008,7 @@ struct of_bus { };/* Default translator (generic bus) */ -void of_bus_default_count_cells (const void *blob,int parentoffset, +void fdt_support_default_count_cells (const void *blob,int parentoffset,int *addrc,int *sizec) {const fdt32_t *prop;
@@ -1030,9 +1030,9 @@ static u64 of_bus_default_map(fdt32_t *addr, const fdt32_t *range, {u64 cp, s, da; - cp =of_read_number (range, na); - s =of_read_number (range + na + pna, ns); - da =of_read_number (addr, na); + cp =fdt_read_number (range, na); + s =fdt_read_number (range + na + pna, ns); + da =fdt_read_number (addr, na);debug ("OF: default map, cp=%" PRIu64", s=%" PRIu64", da=%" PRIu64"\n" , cp, s, da);
@@ -1044,7 +1044,7 @@ static u64 of_bus_default_map(fdt32_t *addr, const fdt32_t *range,static int of_bus_default_translate (fdt32_t *addr,u64 offset,int na) { -u64 a =of_read_number (addr, na); +u64 a =fdt_read_number (addr, na);memset (addr,0 , na *4 ); a += offset;if (na >1 )
@@ -1086,9 +1086,9 @@ static u64 of_bus_isa_map(fdt32_t *addr, const fdt32_t *range,if ((addr[0 ] ^ range[0 ]) &cpu_to_be32 (1 ))return OF_BAD_ADDR ; - cp =of_read_number (range +1 , na -1 ); - s =of_read_number (range + na + pna, ns); - da =of_read_number (addr +1 , na -1 ); + cp =fdt_read_number (range +1 , na -1 ); + s =fdt_read_number (range + na + pna, ns); + da =fdt_read_number (addr +1 , na -1 );debug ("OF: ISA map, cp=%" PRIu64", s=%" PRIu64", da=%" PRIu64"\n" , cp, s, da);
@@ -1122,7 +1122,7 @@ static struct of_bus of_busses[] = { { .name = "default", .addresses = "reg", - .count_cells = of_bus_default_count_cells, + .count_cells = fdt_support_default_count_cells, .map = of_bus_default_map, .translate = of_bus_default_translate, },
@@ -1173,7 +1173,7 @@ static int of_translate_one(const void *blob, int parent, struct of_bus *bus,*/ ranges =fdt_getprop (blob, parent, rprop, &rlen);if (ranges ==NULL || rlen ==0 ) { - offset =of_read_number (addr, na); + offset =fdt_read_number (addr, na);memset (addr,0 , pna *4 );debug ("OF: no ranges, 1:1 translation\n" ); goto finish;
@@ -1253,7 +1253,7 @@ static u64 __of_translate_address(const void *blob, int node_offset,/* If root, we have finished */ if (parent <0 ) {debug ("OF: reached root node\n" ); - result =of_read_number (addr, na); + result =fdt_read_number (addr, na);break ; }
@@ -1666,8 +1666,8 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,fdt32_t cells[4 ];int i, addrc, sizec, ret; -of_bus_default_count_cells (fdt,fdt_parent_offset (fdt, node), - &addrc, &sizec); +fdt_support_default_count_cells (fdt,fdt_parent_offset (fdt, node), + &addrc, &sizec); i =0 ;if (addrc ==2 ) cells[i++] =cpu_to_fdt32 (base_address >>32 );
drivers/core/ofnode.c +2 -2
@@ -457,8 +457,8 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property, na =of_n_addr_cells (np); ns =of_n_addr_cells (np); - *sizep =of_read_number (prop + na, ns); -return of_read_number (prop, na); + *sizep =fdt_read_number (prop + na, ns); +return fdt_read_number (prop, na); }else { return fdtdec_get_addr_size(gd->fdt_blob, ofnode_to_offset(node), property,
drivers/mtd/altera_qspi.c +1 -1
@@ -362,7 +362,7 @@ static int altera_qspi_ofdata_to_platdata(struct udevice *dev)* match with reg-names. */ parent =fdt_parent_offset (blob, node); -of_bus_default_count_cells (blob, parent, &addrc, &sizec); +fdt_support_default_count_cells (blob, parent, &addrc, &sizec); list =fdt_getprop (blob, node,"reg-names" , &len);if (!list)return -ENOENT ;
drivers/mtd/cfi_flash.c +1 -1
@@ -2448,7 +2448,7 @@ static int cfi_flash_probe(struct udevice *dev)int len, idx; parent =fdt_parent_offset (blob, node); -of_bus_default_count_cells (blob, parent, &addrc, &sizec); +fdt_support_default_count_cells (blob, parent, &addrc, &sizec);/* decode regs, there may be multiple reg tuples. */ cell =fdt_getprop (blob, node,"reg" , &len);if (!cell)
drivers/mtd/pic32_flash.c +1 -1
@@ -384,7 +384,7 @@ static int pic32_flash_probe(struct udevice *dev)* match with reg-names. */ parent =fdt_parent_offset (blob, node); -of_bus_default_count_cells (blob, parent, &addrc, &sizec); +fdt_support_default_count_cells (blob, parent, &addrc, &sizec); list =fdt_getprop (blob, node,"reg-names" , &len);if (!list)return -ENOENT ;
drivers/net/altera_tse.c +1 -1
@@ -595,7 +595,7 @@ static int altera_tse_probe(struct udevice *dev)* match with reg-names. */ parent =fdt_parent_offset (blob, node); -of_bus_default_count_cells (blob, parent, &addrc, &sizec); +fdt_support_default_count_cells (blob, parent, &addrc, &sizec); list =fdt_getprop (blob, node,"reg-names" , &len);if (!list)return -ENOENT ;
include/fdt_support.h +2 -2
@@ -248,7 +248,7 @@ static inline int fdt_status_fail_by_alias(void *fdt, const char *alias) }/* Helper to read a big number; size is in cells (not bytes) */ -static inline u64 of_read_number (const fdt32_t *cell,int size) +static inline u64 fdt_read_number (const fdt32_t *cell,int size) {u64 r =0 ;while (size--)
@@ -256,7 +256,7 @@ static inline u64 of_read_number(const fdt32_t *cell, int size)return r; } -void of_bus_default_count_cells (const void *blob,int parentoffset, +void fdt_support_default_count_cells (const void *blob,int parentoffset,int *addrc,int *sizec);int ft_verify_fdt (void *fdt);int arch_fixup_memory_node (void *blob);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 36/72 fdt: Rename a few functions in fdt_support
These two functions have an of_ prefix which conflicts with naming used in of_addr. Rename them:
fdt_read_number
fdt_support_bus_default_count_cells
---
Changes in v3: None
Changes in v2: None
arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 4 ++-- arch/arm/mach-tegra/tegra186/nvtboot_mem.c | 4 ++-- common/fdt_support.c | 26 +++++++++++++------------- drivers/core/ofnode.c | 4 ++-- drivers/mtd/altera_qspi.c | 2 +- drivers/mtd/cfi_flash.c | 2 +- drivers/mtd/pic32_flash.c | 2 +- drivers/net/altera_tse.c | 2 +- include/fdt_support.h | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-)
Applied to u-boot-dm
PATCH v3 37/72 dm: Add more livetree helpers and definitions
In reply to Simon GlassAdd some definitions and helpers for livetree in the main of.h header file. These include:
- reading multi-cell integers
- default number of address/size cells
- functions for comparing names
---
Changes in v3: None
Changes in v2: None
drivers/core/ofnode.c | 4 ++-- include/dm/of.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-)
drivers/core/ofnode.c +2 -2
@@ -457,8 +457,8 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property, na =of_n_addr_cells (np); ns =of_n_addr_cells (np); - *sizep =fdt_read_number (prop + na, ns); -return fdt_read_number (prop, na); + *sizep =of_read_number (prop + na, ns); +return of_read_number (prop, na); }else { return fdtdec_get_addr_size(gd->fdt_blob, ofnode_to_offset(node), property,
include/dm/of.h +36 -0
@@ -103,4 +103,40 @@ static inline bool of_live_active(void) }#endif +#define OF_BAD_ADDR ((u64)-1) + +static inline const char *of_node_full_name (const struct device_node *np) +{ +return np ? np->full_name :"<no-node>" ; +} + +/* Default #address and #size cells */ +#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT ) +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#endif + +/* Default string compare functions */ +#if !defined(of_compat_cmp) +#define of_compat_cmp (s1, s2, l) strcasecmp((s1), (s2)) +#define of_prop_cmp (s1, s2) strcmp((s1), (s2)) +#define of_node_cmp (s1, s2) strcasecmp((s1), (s2)) +#endif + +/* Helper to read a big number; size is in cells (not bytes) */ +static inline u64 of_read_number (const __be32 *cell,int size) +{ +u64 r =0 ; +while (size--) + r = (r <<32 ) |be32_to_cpu (*(cell++)); +return r; +} + +/* Like of_read_number, but we want an unsigned long result */ +static inline unsigned long of_read_ulong (const __be32 *cell,int size) +{ +/* toss away upper bits if unsigned long is smaller than u64 */ +return of_read_number (cell, size); +} +#endif
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 37/72 dm: Add more livetree helpers and definitions
Add some definitions and helpers for livetree in the main of.h header file. These include:
- reading multi-cell integers
- default number of address/size cells
- functions for comparing names
---
Changes in v3: None
Changes in v2: None
drivers/core/ofnode.c | 4 ++-- include/dm/of.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 38/72 string: Add strchrnul()
In reply to Simon GlassThis functions works like strchr() but returns the end of the string if the character is not found. Add an implementation of this.
---
Changes in v3: None
Changes in v2: None
include/linux/string.h | 13 +++++++++++++ lib/string.c | 8 ++++++++ 2 files changed, 21 insertions(+)
include/linux/string.h +13 -0
@@ -50,6 +50,19 @@ extern int strncasecmp(const char *s1, const char *s2, __kernel_size_t len);#ifndef __HAVE_ARCH_STRCHRextern char *strchr (const char *,int );#endif + +/** +* strchrnul() - return position of a character in the string, or end of string +* +* The strchrnul() function is like strchr() except that if c is not found +* in s, then it returns a pointer to the nul byte at the end of s, rather than +* NULL +* @s: string to search +* @c: character to search for +* @return position of @c in @s, or end of @s if not found +*/ +const char *strchrnul (const char *s,int c); +#ifndef __HAVE_ARCH_STRRCHRextern char *strrchr (const char *,int );#endif
lib/string.c +8 -0
@@ -230,6 +230,14 @@ char * strchr(const char * s, int c) }#endif +const char *strchrnul (const char *s,int c) +{ +for (; *s != (char )c; ++s) +if (*s =='\0' ) +break ; +return s; +} +#ifndef __HAVE_ARCH_STRRCHR/** * strrchr - Find the last occurrence of a character in a string
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 38/72 string: Add strchrnul()
This functions works like strchr() but returns the end of the string if the character is not found. Add an implementation of this.
---
Changes in v3: None
Changes in v2: None
include/linux/string.h | 13 +++++++++++++ lib/string.c | 8 ++++++++ 2 files changed, 21 insertions(+)
Applied to u-boot-dm
PATCH v3 39/72 string: Add strcspn()
In reply to Simon GlassAdd an implementation of strcspn() which returns the number of initial characters that do not match any in a rejection list.
---
Changes in v3: None
Changes in v2: None
include/linux/string.h | 15 +++++++++++++++ lib/string.c | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
include/linux/string.h +15 -0
@@ -76,6 +76,21 @@ extern __kernel_size_t strlen(const char *);#ifndef __HAVE_ARCH_STRNLENextern __kernel_size_t strnlen (const char *,__kernel_size_t );#endif + +#ifndef __HAVE_ARCH_STRCSPN +/** +* strcspn() - find span of string without given characters +* +* Calculates the length of the initial segment of @s which consists entirely +* of bsytes not in reject. +* +* @s: string to search +* @reject: strings which cause the search to halt +* @return number of characters at the start of @s which are not in @reject +*/ +size_t strcspn (const char *s,const char *reject); +#endif +#ifndef __HAVE_ARCH_STRDUPextern char *strdup (const char *);#endif
lib/string.c +24 -0
@@ -286,6 +286,30 @@ size_t strnlen(const char * s, size_t count) }#endif +#ifndef __HAVE_ARCH_STRCSPN +/** +* strcspn - Calculate the length of the initial substring of @s which does +* not contain letters in @reject +* @s: The string to be searched +* @reject: The string to avoid +*/ +size_t strcspn (const char *s,const char *reject) +{ +const char *p; +const char *r; +size_t count =0 ; + +for (p = s; *p !='\0' ; ++p) { +for (r = reject; *r !='\0' ; ++r) { +if (*p == *r) +return count; + } + ++count; + } +return count; +} +#endif +#ifndef __HAVE_ARCH_STRDUPchar *strdup (const char *s) {
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 39/72 string: Add strcspn()
Add an implementation of strcspn() which returns the number of initial characters that do not match any in a rejection list.
---
Changes in v3: None
Changes in v2: None
include/linux/string.h | 15 +++++++++++++++ lib/string.c | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+)
Applied to u-boot-dm
PATCH v3 40/72 dm: i2c: Convert uclass to livetree
In reply to Simon GlassUpdate the i2c uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/i2c/i2c-uclass.c | 28 +++++++++++++--------------- include/i2c.h | 3 +-- 2 files changed, 14 insertions(+), 17 deletions(-)
drivers/i2c/i2c-uclass.c +13 -15
@@ -7,7 +7,6 @@#include <common.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> #include <i2c.h> #include <malloc.h> #include <dm/device-internal.h>
@@ -467,18 +466,20 @@ int i2c_deblock(struct udevice *bus) }#if CONFIG_IS_ENABLED (OF_CONTROL ) -int i2c_chip_ofdata_to_platdata (const void *blob,int node, -struct dm_i2c_chip *chip) +int i2c_chip_ofdata_to_platdata (struct udevice *dev,struct dm_i2c_chip *chip) { - chip->offset_len =fdtdec_get_int (gd->fdt_blob, node, -"u-boot,i2c-offset-len" ,1 ); +int addr; + + chip->offset_len =dev_read_u32_default (dev,"u-boot,i2c-offset-len" , +1 ); chip->flags =0 ; - chip->chip_addr =fdtdec_get_int (gd->fdt_blob, node,"reg" ,-1 ); -if (chip->chip_addr ==-1 ) { -debug ("%s: I2C Node '%s' has no 'reg' property\n" , __func__, -fdt_get_name (blob, node,NULL )); + addr =dev_read_u32_default (dev,"reg" ,-1 ); +if (addr ==-1 ) { +debug ("%s: I2C Node '%s' has no 'reg' property %s\n" , __func__, +dev_read_name (dev), dev->name);return -EINVAL ; } + chip->chip_addr = addr;return 0 ; }
@@ -489,8 +490,7 @@ static int i2c_post_probe(struct udevice *dev)#if CONFIG_IS_ENABLED (OF_CONTROL )struct dm_i2c_bus *i2c =dev_get_uclass_priv (dev); - i2c->speed_hz =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"clock-frequency" ,100000 ); + i2c->speed_hz =dev_read_u32_default (dev,"clock-frequency" ,100000 );return dm_i2c_set_bus_speed (dev, i2c->speed_hz);#else
@@ -503,11 +503,9 @@ static int i2c_child_post_bind(struct udevice *dev)#if CONFIG_IS_ENABLED (OF_CONTROL )struct dm_i2c_chip *plat =dev_get_parent_platdata (dev); -if (dev_of_offset (dev) ==-1 ) +if (!dev_of_valid (dev))return 0 ; - -return i2c_chip_ofdata_to_platdata (gd->fdt_blob,dev_of_offset (dev), - plat); +return i2c_chip_ofdata_to_platdata (dev, plat);#else return 0 ;#endif
include/i2c.h +1 -2
@@ -525,8 +525,7 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,* @node: Node offset to read from * @spi: Place to put the decoded information */ -int i2c_chip_ofdata_to_platdata (const void *blob,int node, -struct dm_i2c_chip *chip); +int i2c_chip_ofdata_to_platdata (struct udevice *dev,struct dm_i2c_chip *chip);/** * i2c_dump_msgs() - Dump a list of I2C messages
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 40/72 dm: i2c: Convert uclass to livetree
Update the i2c uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/i2c/i2c-uclass.c | 28 +++++++++++++--------------- include/i2c.h | 3 +-- 2 files changed, 14 insertions(+), 17 deletions(-)
Applied to u-boot-dm
PATCH v3 41/72 samsung: Move pmic header out of config file
In reply to Simon GlassWe should not be including a PMIC header file in the board config. Move it to a C file.
---
Changes in v3:
- Add new patch to move pmic header out of config file
Changes in v2: None
board/samsung/common/misc.c | 1 + include/configs/trats2.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
board/samsung/common/misc.c +1 -0
@@ -18,6 +18,7 @@#include <asm/gpio.h> #include <linux/input.h> #include <dm.h> +#include <power/max77686_pmic.h> #include <power/pmic.h> #include <mmc.h>
include/configs/trats2.h +0 -1
@@ -169,7 +169,6 @@/* Download menu - definitions for check keys */ #ifndef __ASSEMBLY__ -#include <power/max77686_pmic.h> #define KEY_PWR_PMIC_NAME "MAX77686_PMIC"#define KEY_PWR_STATUS_REG MAX77686_REG_PMIC_STATUS1
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 41/72 samsung: Move pmic header out of config file
We should not be including a PMIC header file in the board config. Move it to a C file.
---
Changes in v3:
- Add new patch to move pmic header out of config file
Changes in v2: None
board/samsung/common/misc.c | 1 + include/configs/trats2.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 42/72 dm: pmic: Convert uclass to livetree
In reply to Simon GlassUpdate the pmic uclass and all pmics to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/pmic/act8846.c | 8 +++----- drivers/power/pmic/lp873x.c | 12 +++++------- drivers/power/pmic/max77686.c | 8 +++----- drivers/power/pmic/palmas.c | 16 +++++++--------- drivers/power/pmic/pfuze100.c | 8 +++----- drivers/power/pmic/pmic-uclass.c | 22 ++++++++++------------ drivers/power/pmic/rk8xx.c | 8 +++----- drivers/power/pmic/s5m8767.c | 7 +++---- drivers/power/pmic/sandbox.c | 2 +- drivers/power/pmic/tps65090.c | 8 +++----- include/power/pmic.h | 2 +- 11 files changed, 42 insertions(+), 59 deletions(-)
drivers/power/pmic/act8846.c +3 -5
@@ -48,13 +48,11 @@ static int act8846_read(struct udevice *dev, uint reg, uint8_t *buff, int len)static int act8846_bind (struct udevice *dev) { -const void *blob = gd->fdt_blob; -int regulators_node; +ofnode regulators_node;int children; - regulators_node =fdt_subnode_offset (blob,dev_of_offset (dev), -"regulators" ); -if (regulators_node <=0 ) { + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) {debug ("%s: %s regulators subnode not found!" , __func__, dev->name);return -ENXIO ;
drivers/power/pmic/lp873x.c +5 -7
@@ -46,15 +46,13 @@ static int lp873x_read(struct udevice *dev, uint reg, uint8_t *buff, int len)static int lp873x_bind (struct udevice *dev) { -int regulators_node; -const void *blob = gd->fdt_blob; +ofnode regulators_node;int children; -int node =dev_of_offset (dev); - regulators_node =fdt_subnode_offset (blob, node,"regulators" ); - -if (regulators_node <=0 ) { -printf ("%s: %s reg subnode not found!" , __func__, dev->name); + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) { +debug ("%s: %s regulators subnode not found!" , __func__, + dev->name);return -ENXIO ; }
drivers/power/pmic/max77686.c +3 -5
@@ -50,13 +50,11 @@ static int max77686_read(struct udevice *dev, uint reg, uint8_t *buff, int len)static int max77686_bind (struct udevice *dev) { -int regulators_node; -const void *blob = gd->fdt_blob; +ofnode regulators_node;int children; - regulators_node =fdt_subnode_offset (blob,dev_of_offset (dev), -"voltage-regulators" ); -if (regulators_node <=0 ) { + regulators_node =dev_read_subnode (dev,"voltage-regulators" ); +if (!ofnode_valid (regulators_node)) {debug ("%s: %s regulators subnode not found!" , __func__, dev->name);return -ENXIO ;
drivers/power/pmic/palmas.c +7 -9
@@ -46,17 +46,15 @@ static int palmas_read(struct udevice *dev, uint reg, uint8_t *buff, int len)static int palmas_bind (struct udevice *dev) { -int pmic_node =-1 , regulators_node; -const void *blob = gd->fdt_blob; +ofnode pmic_node =ofnode_null (), regulators_node; +ofnode subnode;int children; -int node =dev_of_offset (dev); -int subnode, len; -fdt_for_each_subnode (subnode, blob, node) { +dev_for_each_subnode (subnode, dev) {const char *name;char *temp; - name =fdt_get_name (blob, subnode, &len); + name =ofnode_get_name (subnode); temp =strstr (name,"pmic" );if (temp) { pmic_node = subnode;
@@ -64,14 +62,14 @@ static int palmas_bind(struct udevice *dev) } } -if (pmic_node <=0 ) { +if (!ofnode_valid (pmic_node)) {debug ("%s: %s pmic subnode not found!" , __func__, dev->name);return -ENXIO ; } - regulators_node =fdt_subnode_offset (blob, pmic_node,"regulators" ); + regulators_node =ofnode_find_subnode (pmic_node,"regulators" ); -if (regulators_node <=0 ) { +if (!ofnode_valid (regulators_node)) {debug ("%s: %s reg subnode not found!" , __func__, dev->name);return -ENXIO ; }
drivers/power/pmic/pfuze100.c +3 -5
@@ -52,13 +52,11 @@ static int pfuze100_read(struct udevice *dev, uint reg, uint8_t *buff, int len)static int pfuze100_bind (struct udevice *dev) { +ofnode regulators_node;int children; -int regulators_node; -const void *blob = gd->fdt_blob; - regulators_node =fdt_subnode_offset (blob,dev_of_offset (dev), -"regulators" ); -if (regulators_node <=0 ) { + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) {debug ("%s: %s regulators subnode not found!" , __func__, dev->name);return -ENXIO ;
drivers/power/pmic/pmic-uclass.c +10 -12
@@ -19,29 +19,27 @@DECLARE_GLOBAL_DATA_PTR ;#if CONFIG_IS_ENABLED (PMIC_CHILDREN ) -int pmic_bind_children (struct udevice *pmic,int offset, +int pmic_bind_children (struct udevice *pmic,ofnode parent,const struct pmic_child_info *child_info) {const struct pmic_child_info *info; -const void *blob = gd->fdt_blob;struct driver *drv;struct udevice *child;const char *node_name;int bind_count =0 ; -int node; +ofnode node;int prefix_len;int ret;debug ("%s for '%s' at node offset: %d\n" , __func__, pmic->name,dev_of_offset (pmic)); -for (node =fdt_first_subnode (blob, offset); - node >0 ; - node =fdt_next_subnode (blob, node)) { - node_name =fdt_get_name (blob, node,NULL ); +for (node =ofnode_first_subnode (parent); +ofnode_valid (node); + node =ofnode_next_subnode (node)) { + node_name =ofnode_get_name (node); -debug ("* Found child node: '%s' at offset:%d\n" , node_name, - node); +debug ("* Found child node: '%s'\n" , node_name); child =NULL ;for (info = child_info; info->prefix && info->driver; info++) {
@@ -60,8 +58,8 @@ int pmic_bind_children(struct udevice *pmic, int offset,debug (" - found child driver: '%s'\n" , drv->name); - ret =device_bind (pmic, drv, node_name,NULL , - node, &child); + ret =device_bind_with_driver_data (pmic, drv, node_name, +0 , node, &child);if (ret) {debug (" - child binding error: %d\n" , ret);continue ;
@@ -82,7 +80,7 @@ int pmic_bind_children(struct udevice *pmic, int offset, debug(" - compatible prefix not found\n"); } -debug ("Bound: %d childs for PMIC: '%s'\n" , bind_count, pmic->name); +debug ("Bound: %d children for PMIC: '%s'\n" , bind_count, pmic->name);return bind_count; }#endif
drivers/power/pmic/rk8xx.c +3 -5
@@ -57,13 +57,11 @@ static int rk8xx_read(struct udevice *dev, uint reg, uint8_t *buff, int len)#if CONFIG_IS_ENABLED (PMIC_CHILDREN )static int rk8xx_bind (struct udevice *dev) { -const void *blob = gd->fdt_blob; -int regulators_node; +ofnode regulators_node;int children; - regulators_node =fdt_subnode_offset (blob,dev_of_offset (dev), -"regulators" ); -if (regulators_node <=0 ) { + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) {debug ("%s: %s regulators subnode not found!" , __func__, dev->name);return -ENXIO ;
drivers/power/pmic/s5m8767.c +3 -4
@@ -54,12 +54,11 @@ int s5m8767_enable_32khz_cp(struct udevice *dev)static int s5m8767_bind (struct udevice *dev) { -int node; -const void *blob = gd->fdt_blob;int children; +ofnode node; - node =fdt_subnode_offset (blob,dev_of_offset (dev),"regulators" ); -if (node <=0 ) { + node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (node)) {debug ("%s: %s regulators subnode not found!" , __func__, dev->name);return -ENXIO ;
drivers/power/pmic/sandbox.c +1 -1
@@ -51,7 +51,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg,static int sandbox_pmic_bind (struct udevice *dev) { -if (!pmic_bind_children (dev,dev_of_offset (dev), pmic_children_info)) +if (!pmic_bind_children (dev,dev_ofnode (dev), pmic_children_info))error ("%s:%d PMIC: %s - no child found!" , __func__, __LINE__, dev->name);
drivers/power/pmic/tps65090.c +3 -5
@@ -52,13 +52,11 @@ static int tps65090_read(struct udevice *dev, uint reg, uint8_t *buff, int len)static int tps65090_bind (struct udevice *dev) { -int regulators_node; -const void *blob = gd->fdt_blob; +ofnode regulators_node;int children; - regulators_node =fdt_subnode_offset (blob,dev_of_offset (dev), -"regulators" ); -if (regulators_node <=0 ) { + regulators_node =dev_read_subnode (dev,"regulators" ); +if (!ofnode_valid (regulators_node)) {debug ("%s: %s regulators subnode not found!" , __func__, dev->name);return -ENXIO ;
include/power/pmic.h +1 -1
@@ -226,7 +226,7 @@ struct pmic_child_info {* buck2 { ... }; * }; */ -int pmic_bind_children (struct udevice *pmic,int offset, +int pmic_bind_children (struct udevice *pmic,ofnode parent,const struct pmic_child_info *child_info);/**
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 42/72 dm: pmic: Convert uclass to livetree
Update the pmic uclass and all pmics to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/pmic/act8846.c | 8 +++----- drivers/power/pmic/lp873x.c | 12 +++++------- drivers/power/pmic/max77686.c | 8 +++----- drivers/power/pmic/palmas.c | 16 +++++++--------- drivers/power/pmic/pfuze100.c | 8 +++----- drivers/power/pmic/pmic-uclass.c | 22 ++++++++++------------ drivers/power/pmic/rk8xx.c | 8 +++----- drivers/power/pmic/s5m8767.c | 7 +++---- drivers/power/pmic/sandbox.c | 2 +- drivers/power/pmic/tps65090.c | 8 +++----- include/power/pmic.h | 2 +- 11 files changed, 42 insertions(+), 59 deletions(-)
Applied to u-boot-dm
PATCH v3 43/72 sandbox: pmic: Convert pmic emulator to support livetree
In reply to Simon GlassUpdate this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/pmic/i2c_pmic_emul.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/power/pmic/i2c_pmic_emul.c +2 -4
@@ -6,7 +6,6 @@*/ #include <common.h> -#include <fdtdec.h> #include <errno.h> #include <dm.h> #include <i2c.h>
@@ -108,9 +107,8 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul)debug ("%s:%d Setting PMIC default registers\n" , __func__, __LINE__); - reg_defaults =fdtdec_locate_byte_array (gd->fdt_blob, -dev_of_offset (emul),"reg-defaults" , -SANDBOX_PMIC_REG_COUNT ); + reg_defaults =dev_read_u8_array_ptr (emul,"reg-defaults" , +SANDBOX_PMIC_REG_COUNT );if (!reg_defaults) { error("Property \"reg-defaults\" not found for device: %s!",
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 43/72 sandbox: pmic: Convert pmic emulator to support livetree
Update this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/pmic/i2c_pmic_emul.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Applied to u-boot-dm
PATCH v3 44/72 dm: regulator: Convert regulator uclass to support livetree
In reply to Simon GlassUpdate the regulator uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/regulator/regulator-uclass.c | 39 ++++++++++++------------------ 1 file changed, 16 insertions(+), 23 deletions(-)
drivers/power/regulator/regulator-uclass.c +16 -23
@@ -4,8 +4,8 @@* * SPDX-License-Identifier: GPL-2.0+ */ +#include <common.h> -#include <fdtdec.h> #include <errno.h> #include <dm.h> #include <dm/uclass-internal.h>
@@ -278,20 +278,16 @@ 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; -int offset =dev_of_offset (dev); -const void *blob = gd->fdt_blob;const char *property ="regulator-name" ; uc_pdata =dev_get_uclass_platdata (dev); -if (!uc_pdata) -return -ENXIO ;/* Regulator's mandatory constraint */ - uc_pdata->name =fdt_getprop (blob, offset, property,NULL ); + uc_pdata->name =dev_read_string (dev, property);if (!uc_pdata->name) { -debug ("%s: dev: %s has no property 'regulator-name'\n" , - __func__, dev->name); - uc_pdata->name =fdt_get_name (blob, offset,NULL ); +debug ("%s: dev '%s' has no property '%s'\n" , + __func__, dev->name, property); + uc_pdata->name =dev_read_name (dev);if (!uc_pdata->name)return -EINVAL ; }
@@ -299,7 +295,7 @@ static int regulator_post_bind(struct udevice *dev)if (regulator_name_is_unique (dev, uc_pdata->name))return 0 ; -debug ("\"%s\" of dev: \"%s\", has nonunique value: \"%s\"" , +debug ("'%s' of dev: '%s', has nonunique value: '%s\n" , property, dev->name, uc_pdata->name);return -EINVAL ;
@@ -308,25 +304,22 @@ static int regulator_post_bind(struct udevice *dev)static int regulator_pre_probe (struct udevice *dev) {struct dm_regulator_uclass_platdata *uc_pdata; -int offset =dev_of_offset (dev); uc_pdata =dev_get_uclass_platdata (dev);if (!uc_pdata)return -ENXIO ;/* Regulator's optional constraints */ - uc_pdata->min_uV =fdtdec_get_int (gd->fdt_blob, offset, -"regulator-min-microvolt" , -ENODATA ); - uc_pdata->max_uV =fdtdec_get_int (gd->fdt_blob, offset, -"regulator-max-microvolt" , -ENODATA ); - uc_pdata->min_uA =fdtdec_get_int (gd->fdt_blob, offset, -"regulator-min-microamp" , -ENODATA ); - uc_pdata->max_uA =fdtdec_get_int (gd->fdt_blob, offset, -"regulator-max-microamp" , -ENODATA ); - uc_pdata->always_on =fdtdec_get_bool (gd->fdt_blob, offset, -"regulator-always-on" ); - uc_pdata->boot_on =fdtdec_get_bool (gd->fdt_blob, offset, -"regulator-boot-on" ); + uc_pdata->min_uV =dev_read_u32_default (dev,"regulator-min-microvolt" , + -ENODATA ); + uc_pdata->max_uV =dev_read_u32_default (dev,"regulator-max-microvolt" , + -ENODATA ); + uc_pdata->min_uA =dev_read_u32_default (dev,"regulator-min-microamp" , + -ENODATA ); + uc_pdata->max_uA =dev_read_u32_default (dev,"regulator-max-microamp" , + -ENODATA ); + uc_pdata->always_on =dev_read_bool (dev,"regulator-always-on" ); + uc_pdata->boot_on =dev_read_bool (dev,"regulator-boot-on" );/* Those values are optional (-ENODATA if unset) */ if ((uc_pdata->min_uV != -ENODATA) &&
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 44/72 dm: regulator: Convert regulator uclass to support livetree
Update the regulator uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/regulator/regulator-uclass.c | 39 ++++++++++++------------------ 1 file changed, 16 insertions(+), 23 deletions(-)
Applied to u-boot-dm
PATCH v3 45/72 dm: regulator: Update fixed regulator to support livetree.
In reply to Simon GlassUpdate this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/regulator/fixed.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/power/regulator/fixed.c +9 -8
@@ -7,7 +7,6 @@*/ #include <common.h> -#include <fdtdec.h> #include <errno.h> #include <dm.h> #include <i2c.h>
@@ -27,8 +26,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)struct dm_regulator_uclass_platdata *uc_pdata;struct fixed_regulator_platdata *dev_pdata;struct gpio_desc *gpio; -const void *blob = gd->fdt_blob; -int node =dev_of_offset (dev), flags =GPIOD_IS_OUT ; +int flags =GPIOD_IS_OUT ;int ret; dev_pdata =dev_get_platdata (dev);
@@ -39,7 +37,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)/* Set type to fixed */ uc_pdata->type =REGULATOR_TYPE_FIXED ; -if (fdtdec_get_bool (blob, node,"enable-active-high" )) +if (dev_read_bool (dev,"enable-active-high" )) flags |=GPIOD_IS_OUT_ACTIVE ;/* Get fixed regulator optional enable GPIO desc */
@@ -53,9 +51,8 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) }/* Get optional ramp up delay */ - dev_pdata->startup_delay_us =fdtdec_get_uint (gd->fdt_blob, -dev_of_offset (dev), -"startup-delay-us" ,0 ); + dev_pdata->startup_delay_us =dev_read_u32_default (dev, +"startup-delay-us" ,0 );return 0 ; }
@@ -108,8 +105,11 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable)struct fixed_regulator_platdata *dev_pdata =dev_get_platdata (dev);int ret; +debug ("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n" , __func__, + dev->name, enable, dev_pdata->startup_delay_us, +dm_gpio_is_valid (&dev_pdata->gpio));/* Enable GPIO is optional */ -if (!dev_pdata->gpio.dev) { +if (!dm_gpio_is_valid (&dev_pdata->gpio)) {if (!enable)return -ENOSYS ;return 0 ;
@@ -124,6 +124,7 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable)if (enable && dev_pdata->startup_delay_us)udelay (dev_pdata->startup_delay_us); +debug ("%s: done\n" , __func__);return 0 ; }
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 45/72 dm: regulator: Update fixed regulator to support livetree.
Update this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/power/regulator/fixed.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
Applied to u-boot-dm
PATCH v3 46/72 dm: mmc: Convert uclass to livetree
In reply to Simon GlassUpdate the mmc uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/mmc/mmc-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/mmc-uclass.c +2 -1
@@ -204,7 +204,8 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)#endif #ifndef CONFIG_SPL_BUILD /* Use the fixed index with aliase node's index */ -fdtdec_get_alias_seq (gd->fdt_blob,"mmc" ,dev_of_offset (dev), &devnum); + ret =dev_read_alias_seq (dev, &devnum); +debug ("%s: alias ret=%d, devnum=%d\n" , __func__, ret, devnum);#endif ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 46/72 dm: mmc: Convert uclass to livetree
Update the mmc uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/mmc/mmc-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 47/72 dm: adc: Convert uclass to livetree
In reply to Simon GlassUpdate the adc uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/adc/adc-uclass.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/adc/adc-uclass.c +6 -8
@@ -345,12 +345,11 @@ nodev:static int adc_vdd_platdata_set (struct udevice *dev) {struct adc_uclass_platdata *uc_pdata =dev_get_uclass_platdata (dev); -int ret, offset =dev_of_offset (dev); -const void *fdt = gd->fdt_blob; +int ret;char *prop; prop ="vdd-polarity-negative" ; - uc_pdata->vdd_polarity_negative =fdtdec_get_bool (fdt, offset, prop); + uc_pdata->vdd_polarity_negative =dev_read_bool (dev, prop); ret =adc_vdd_platdata_update (dev);if (ret != -ENOENT )
@@ -358,7 +357,7 @@ static int adc_vdd_platdata_set(struct udevice *dev)/* No vdd-supply phandle. */ prop ="vdd-microvolts" ; - uc_pdata->vdd_microvolts =fdtdec_get_int (fdt, offset, prop, -ENODATA ); + uc_pdata->vdd_microvolts =dev_read_u32_default (dev, prop, -ENODATA );return 0 ; }
@@ -366,12 +365,11 @@ static int adc_vdd_platdata_set(struct udevice *dev)static int adc_vss_platdata_set (struct udevice *dev) {struct adc_uclass_platdata *uc_pdata =dev_get_uclass_platdata (dev); -int ret, offset =dev_of_offset (dev); -const void *fdt = gd->fdt_blob; +int ret;char *prop; prop ="vss-polarity-negative" ; - uc_pdata->vss_polarity_negative =fdtdec_get_bool (fdt, offset, prop); + uc_pdata->vss_polarity_negative =dev_read_bool (dev, prop); ret =adc_vss_platdata_update (dev);if (ret != -ENOENT )
@@ -379,7 +377,7 @@ static int adc_vss_platdata_set(struct udevice *dev)/* No vss-supply phandle. */ prop ="vss-microvolts" ; - uc_pdata->vss_microvolts =fdtdec_get_int (fdt, offset, prop, -ENODATA ); + uc_pdata->vss_microvolts =dev_read_u32_default (dev, prop, -ENODATA );return 0 ; }
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 47/72 dm: adc: Convert uclass to livetree
Update the adc uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/adc/adc-uclass.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
Applied to u-boot-dm
PATCH v3 48/72 dm: usb: Convert uclass to livetree
In reply to Simon GlassUpdate the usb uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/usb-uclass.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/usb/host/usb-uclass.c +3 -5
@@ -683,20 +683,18 @@ int usb_detect_change(void)int usb_child_post_bind (struct udevice *dev) {struct usb_dev_platdata *plat =dev_get_parent_platdata (dev); -const void *blob = gd->fdt_blob;int val; -if (dev_of_offset (dev) ==-1 ) +if (!dev_of_valid (dev))return 0 ;/* We only support matching a few things */ - val =fdtdec_get_int (blob,dev_of_offset (dev),"usb,device-class" ,-1 ); + val =dev_read_u32_default (dev,"usb,device-class" ,-1 );if (val !=-1 ) { plat->id.match_flags |=USB_DEVICE_ID_MATCH_DEV_CLASS ; plat->id.bDeviceClass = val; } - val =fdtdec_get_int (blob,dev_of_offset (dev),"usb,interface-class" , --1 ); + val =dev_read_u32_default (dev,"usb,interface-class" ,-1 );if (val !=-1 ) { plat->id.match_flags |=USB_DEVICE_ID_MATCH_INT_CLASS ; plat->id.bInterfaceClass = val;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 48/72 dm: usb: Convert uclass to livetree
Update the usb uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/usb/host/usb-uclass.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
Applied to u-boot-dm
PATCH v3 49/72 sandbox: usb: Convert emulators to livetree
In reply to Simon GlassUpdate the sandbox flash and hub USB emulators to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/usb/emul/sandbox_flash.c | 4 +--- drivers/usb/emul/sandbox_hub.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/usb/emul/sandbox_flash.c +1 -3
@@ -371,10 +371,8 @@ err:static int sandbox_flash_ofdata_to_platdata (struct udevice *dev) {struct sandbox_flash_plat *plat =dev_get_platdata (dev); -const void *blob = gd->fdt_blob; - plat->pathname =fdt_getprop (blob,dev_of_offset (dev), -"sandbox,filepath" ,NULL ); + plat->pathname =dev_read_string (dev,"sandbox,filepath" );return 0 ; }
drivers/usb/emul/sandbox_hub.c +1 -2
@@ -277,8 +277,7 @@ static int sandbox_child_post_bind(struct udevice *dev) {struct sandbox_hub_platdata *plat =dev_get_parent_platdata (dev); - plat->port =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev),"reg" , --1 ); + plat->port =dev_read_u32_default (dev,"reg" ,-1 );return 0 ; }
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 49/72 sandbox: usb: Convert emulators to livetree
Update the sandbox flash and hub USB emulators to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/usb/emul/sandbox_flash.c | 4 +--- drivers/usb/emul/sandbox_hub.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-)
Applied to u-boot-dm
PATCH v3 50/72 clk: Modify xlate() method for livetree
In reply to Simon GlassUpdate the xlate() method to use ofnode_phandle_args instead of the fdtdec variant. This will allow drivers to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/clk/at91/pmc.c | 2 +- drivers/clk/at91/pmc.h | 2 +- drivers/clk/clk-uclass.c | 7 ++++--- drivers/clk/clk_stm32f7.c | 3 +-- include/clk-uclass.h | 5 +++-- 5 files changed, 10 insertions(+), 9 deletions(-)
drivers/clk/at91/pmc.c +1 -1
@@ -87,7 +87,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)return 0 ; } -int at91_clk_of_xlate (struct clk *clk,struct fdtdec_phandle_args *args) +int at91_clk_of_xlate (struct clk *clk,struct ofnode_phandle_args *args) {int periph;
drivers/clk/at91/pmc.h +1 -1
@@ -15,7 +15,7 @@ struct pmc_platdata {int at91_pmc_core_probe (struct udevice *dev);int at91_clk_sub_device_bind (struct udevice *dev,const char *drv_name); -int at91_clk_of_xlate (struct clk *clk,struct fdtdec_phandle_args *args); +int at91_clk_of_xlate (struct clk *clk,struct ofnode_phandle_args *args);int at91_clk_probe (struct udevice *dev);#endif
drivers/clk/clk-uclass.c +4 -3
@@ -38,7 +38,7 @@ int clk_get_by_index_platdata(struct udevice *dev, int index, }# else static int clk_of_xlate_default (struct clk *clk, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {debug ("%s(clk=%p)\n" , __func__, clk);
@@ -86,9 +86,10 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) ops =clk_dev_ops (dev_clk);if (ops->of_xlate) - ret = ops->of_xlate (clk, &args); + ret = ops->of_xlate (clk, (struct ofnode_phandle_args *)&args);else - ret =clk_of_xlate_default (clk, &args); + ret =clk_of_xlate_default (clk, + (struct ofnode_phandle_args *)&args);if (ret) {debug ("of_xlate() failed: %d\n" , ret);return ret;
drivers/clk/clk_stm32f7.c +1 -2
@@ -252,8 +252,7 @@ static int stm32_clk_probe(struct udevice *dev)return 0 ; } -static int stm32_clk_of_xlate (struct clk *clk, -struct fdtdec_phandle_args *args) +static int stm32_clk_of_xlate (struct clk *clk,struct ofnode_phandle_args *args) {debug ("%s(clk=%p)\n" , __func__, clk);
include/clk-uclass.h +3 -2
@@ -12,7 +12,8 @@/* See clk.h for background documentation. */ #include <clk.h> -#include <fdtdec.h> + +struct ofnode_phandle_args ;/** * struct clk_ops - The functions that a clock driver must implement.
@@ -37,7 +38,7 @@ struct clk_ops {* @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct clk *clock, -struct fdtdec_phandle_args *args); +struct ofnode_phandle_args *args);/** * request - Request a translated clock. *
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 50/72 clk: Modify xlate() method for livetree
Update the xlate() method to use ofnode_phandle_args instead of the fdtdec variant. This will allow drivers to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/clk/at91/pmc.c | 2 +- drivers/clk/at91/pmc.h | 2 +- drivers/clk/clk-uclass.c | 7 ++++--- drivers/clk/clk_stm32f7.c | 3 +-- include/clk-uclass.h | 5 +++-- 5 files changed, 10 insertions(+), 9 deletions(-)
Applied to u-boot-dm
PATCH v3 51/72 dm: clk: Update uclass to support livetree
In reply to Simon GlassUpdate the clk uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/clk/clk-uclass.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/clk/clk-uclass.c +7 -10
@@ -58,23 +58,22 @@ static int clk_of_xlate_default(struct clk *clk,int clk_get_by_index (struct udevice *dev,int index,struct clk *clk) {int ret; -struct fdtdec_phandle_args args; +struct ofnode_phandle_args args;struct udevice *dev_clk;struct clk_ops *ops;debug ("%s(dev=%p, index=%d, clk=%p)\n" , __func__, dev, index, clk);assert (clk); - ret =fdtdec_parse_phandle_with_args (gd->fdt_blob,dev_of_offset (dev), -"clocks" ,"#clock-cells" ,0 , index, - &args); + ret =dev_read_phandle_with_args (dev,"clocks" ,"#clock-cells" ,0 , + index, &args);if (ret) {debug ("%s: fdtdec_parse_phandle_with_args failed: err=%d\n" , __func__, ret);return ret; } - ret =uclass_get_device_by_of_offset (UCLASS_CLK , args.node, &dev_clk); + ret =uclass_get_device_by_ofnode (UCLASS_CLK , args.node, &dev_clk);if (ret) {debug ("%s: uclass_get_device_by_of_offset failed: err=%d\n" , __func__, ret);
@@ -86,10 +85,9 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) ops =clk_dev_ops (dev_clk);if (ops->of_xlate) - ret = ops->of_xlate (clk, (struct ofnode_phandle_args *)&args); + ret = ops->of_xlate (clk, &args);else - ret =clk_of_xlate_default (clk, - (struct ofnode_phandle_args *)&args); + ret =clk_of_xlate_default (clk, &args);if (ret) {debug ("of_xlate() failed: %d\n" , ret);return ret;
@@ -105,8 +103,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)debug ("%s(dev=%p, name=%s, clk=%p)\n" , __func__, dev, name, clk); - index =fdt_stringlist_search (gd->fdt_blob,dev_of_offset (dev), -"clock-names" , name); + index =dev_read_stringlist_search (dev,"clock-names" , name);if (index <0 ) {debug ("fdt_stringlist_search() failed: %d\n" , index);return index;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 51/72 dm: clk: Update uclass to support livetree
Update the clk uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/clk/clk-uclass.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
Applied to u-boot-dm
PATCH v3 52/72 dm: clk: fixed: Update to support livetree
In reply to Simon GlassUpdate the fixed-rate clock driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/clk/clk_fixed_rate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clk/clk_fixed_rate.c +2 -3
@@ -31,9 +31,8 @@ const struct clk_ops clk_fixed_rate_ops = {static int clk_fixed_rate_ofdata_to_platdata (struct udevice *dev) {#if !CONFIG_IS_ENABLED (OF_PLATDATA ) -to_clk_fixed_rate (dev)->fixed_rate = -fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"clock-frequency" ,0 ); +to_clk_fixed_rate (dev)->fixed_rate =dev_read_u32_default (dev, +"clock-frequency" ,0 );#endif return 0 ;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 52/72 dm: clk: fixed: Update to support livetree
Update the fixed-rate clock driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/clk/clk_fixed_rate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Applied to u-boot-dm
PATCH v3 53/72 dm: test: Separate out the bus DT offset test
In reply to Simon GlassWe cannot access the device tree via an offset when running in livetree mode. Separate out that part of the bus' children tests and mark it as for the flat tree only.
---
Changes in v3: None
Changes in v2: None
test/dm/bus.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
test/dm/bus.c +15 -1
@@ -160,8 +160,21 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts) node =fdt_path_offset (blob,"/d-test" );ut_asserteq (-ENODEV ,device_find_child_by_of_offset (bus, node, &dev)); +return 0 ; +} +DM_TEST (dm_test_bus_children_funcs,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +static int dm_test_bus_children_of_offset (struct unit_test_state *uts) +{ +const void *blob = gd->fdt_blob; +struct udevice *bus, *dev; +int node; + +ut_assertok (uclass_get_device (UCLASS_TEST_BUS ,0 , &bus)); +/* Find a valid child */ node =fdt_path_offset (blob,"/some-bus/c-test at 1" ); +ut_assert (node >0 );ut_assertok (device_find_child_by_of_offset (bus, node, &dev));ut_assert (!(dev->flags &DM_FLAG_ACTIVATED ));ut_assertok (device_get_child_by_of_offset (bus, node, &dev));
@@ -169,7 +182,8 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)return 0 ; } -DM_TEST (dm_test_bus_children_funcs,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); +DM_TEST (dm_test_bus_children_of_offset, +DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT |DM_TESTF_FLAT_TREE );/* Test that we can iterate through children */ static int dm_test_bus_children_iterators (struct unit_test_state *uts)
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 53/72 dm: test: Separate out the bus DT offset test
We cannot access the device tree via an offset when running in livetree mode. Separate out that part of the bus' children tests and mark it as for the flat tree only.
---
Changes in v3: None
Changes in v2: None
test/dm/bus.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 54/72 dm: test: Disable the fdt_offset test with livetree
In reply to Simon GlassWe cannot run this test with livetree since it uses device tree offsets. Mark it as flat tree only.
---
Changes in v3: None
Changes in v2: None
test/dm/test-fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
test/dm/test-fdt.c +2 -1
@@ -265,4 +265,5 @@ static int dm_test_fdt_offset(struct unit_test_state *uts)return 0 ; } -DM_TEST (dm_test_fdt_offset,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); +DM_TEST (dm_test_fdt_offset, +DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT |DM_TESTF_FLAT_TREE );
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 54/72 dm: test: Disable the fdt_offset test with livetree
We cannot run this test with livetree since it uses device tree offsets. Mark it as flat tree only.
---
Changes in v3: None
Changes in v2: None
test/dm/test-fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 55/72 dm: phy: Update tests to use ut_asserteq()
In reply to Simon GlassUse ut_asserteq() to test equality since this gives a better error message on failure. Also make a few of the tests more specific.
---
Changes in v3: None
Changes in v2: None
test/dm/phy.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
test/dm/phy.c +9 -6
@@ -49,8 +49,8 @@ static int dm_test_phy_base(struct unit_test_state *uts)/* Try to get a non-existing phy */ ut_asserteq (-ENODEV ,uclass_get_device (UCLASS_PHY ,3 , &dev)); -ut_assert (generic_phy_get_by_name (parent,"phy_not_existing" , - &phy1_method1) < 0) +ut_asserteq (-ENODATA ,generic_phy_get_by_name (parent, +"phy_not_existing" , &phy1_method1));return 0 ; }
@@ -68,8 +68,11 @@ static int dm_test_phy_ops(struct unit_test_state *uts) "gen_phy_user", &parent));ut_assertok (generic_phy_get_by_name (parent,"phy1" , &phy1)); +ut_asserteq (0 , phy1.id);ut_assertok (generic_phy_get_by_name (parent,"phy2" , &phy2)); +ut_asserteq (1 , phy2.id);ut_assertok (generic_phy_get_by_name (parent,"phy3" , &phy3)); +ut_asserteq (0 , phy3.id);/* test normal operations */ ut_assertok (generic_phy_init (&phy1));
@@ -100,12 +103,12 @@ static int dm_test_phy_ops(struct unit_test_state *uts)/* PHY2 has a known problem with power off */ ut_assertok (generic_phy_init (&phy2));ut_assertok (generic_phy_power_on (&phy2)); -ut_assert (generic_phy_power_off (&phy2) == -EIO ); +ut_asserteq (-EIO ,generic_phy_power_off (&phy2)); -/* PHY3 has a known problem with power off and power on*/ +/* PHY3 has a known problem with power off and power on */ ut_assertok (generic_phy_init (&phy3)); -ut_assert (generic_phy_power_off (&phy3) == -EIO ); -ut_assert (generic_phy_power_off (&phy3) == -EIO ); +ut_asserteq (-EIO ,generic_phy_power_off (&phy3)); +ut_asserteq (-EIO ,generic_phy_power_off (&phy3));return 0 ; }
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 55/72 dm: phy: Update tests to use ut_asserteq()
Use ut_asserteq() to test equality since this gives a better error message on failure. Also make a few of the tests more specific.
---
Changes in v3: None
Changes in v2: None
test/dm/phy.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Applied to u-boot-dm
PATCH v3 56/72 dm: mailbox: Update uclass to support livetree
In reply to Simon GlassUpdate the mailbox uclass to support livetree. Fix the xlate() method in all callers.
---
Changes in v3: None
Changes in v2: None
drivers/mailbox/mailbox-uclass.c | 20 ++++++++------------ drivers/mailbox/tegra-hsp.c | 2 +- include/mailbox-uclass.h | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-)
drivers/mailbox/mailbox-uclass.c +8 -12
@@ -6,7 +6,6 @@#include <common.h> #include <dm.h> -#include <fdtdec.h> #include <mailbox.h> #include <mailbox-uclass.h>
@@ -18,7 +17,7 @@ static inline struct mbox_ops *mbox_dev_ops(struct udevice *dev) }static int mbox_of_xlate_default (struct mbox_chan *chan, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {debug ("%s(chan=%p)\n" , __func__, chan);
@@ -34,24 +33,22 @@ static int mbox_of_xlate_default(struct mbox_chan *chan,int mbox_get_by_index (struct udevice *dev,int index,struct mbox_chan *chan) { -struct fdtdec_phandle_args args; +struct ofnode_phandle_args args;int ret;struct udevice *dev_mbox;struct mbox_ops *ops;debug ("%s(dev=%p, index=%d, chan=%p)\n" , __func__, dev, index, chan); - ret =fdtdec_parse_phandle_with_args (gd->fdt_blob,dev_of_offset (dev), -"mboxes" ,"#mbox-cells" ,0 , - index, &args); + ret =dev_read_phandle_with_args (dev,"mboxes" ,"#mbox-cells" ,0 , index, + &args);if (ret) { -debug ("%s: fdtdec_parse_phandle_with_args failed: %d\n" , - __func__, ret); +debug ("%s: dev_read_phandle_with_args failed: %d\n" , __func__, + ret);return ret; } - ret =uclass_get_device_by_of_offset (UCLASS_MAILBOX , args.node, - &dev_mbox); + ret =uclass_get_device_by_ofnode (UCLASS_MAILBOX , args.node, &dev_mbox);if (ret) {debug ("%s: uclass_get_device_by_of_offset failed: %d\n" , __func__, ret);
@@ -85,8 +82,7 @@ int mbox_get_by_name(struct udevice *dev, const char *name,debug ("%s(dev=%p, name=%s, chan=%p)\n" , __func__, dev, name, chan); - index =fdt_stringlist_search (gd->fdt_blob,dev_of_offset (dev), -"mbox-names" , name); + index =dev_read_stringlist_search (dev,"mbox-names" , name);if (index <0 ) {debug ("fdt_stringlist_search() failed: %d\n" , index);return index;
drivers/mailbox/tegra-hsp.c +1 -1
@@ -72,7 +72,7 @@ static int tegra_hsp_db_id(ulong chan_id) }static int tegra_hsp_of_xlate (struct mbox_chan *chan, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {debug ("%s(chan=%p)\n" , __func__, chan);
include/mailbox-uclass.h +1 -1
@@ -36,7 +36,7 @@ struct mbox_ops {* @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct mbox_chan *chan, -struct fdtdec_phandle_args *args); +struct ofnode_phandle_args *args);/** * request - Request a translated channel. *
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 56/72 dm: mailbox: Update uclass to support livetree
Update the mailbox uclass to support livetree. Fix the xlate() method in all callers.
---
Changes in v3: None
Changes in v2: None
drivers/mailbox/mailbox-uclass.c | 20 ++++++++------------ drivers/mailbox/tegra-hsp.c | 2 +- include/mailbox-uclass.h | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-)
Applied to u-boot-dm
PATCH v3 57/72 dm: phy: Update uclass to support livetree
In reply to Simon GlassUpdate the phy uclass to support livetree. Fix the xlate() method which has no callers.
---
Changes in v3: None
Changes in v2: None
drivers/phy/phy-uclass.c | 21 +++++++++------------ include/generic-phy.h | 3 +-- 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/phy/phy-uclass.c +9 -12
@@ -17,7 +17,7 @@ static inline struct phy_ops *phy_dev_ops(struct udevice *dev) }static int generic_phy_xlate_offs_flags (struct phy *phy, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {debug ("%s(phy=%p)\n" , __func__, phy);
@@ -31,14 +31,13 @@ static int generic_phy_xlate_offs_flags(struct phy *phy,else phy->id =0 ; -return 0 ; }int generic_phy_get_by_index (struct udevice *dev,int index,struct phy *phy) { -struct fdtdec_phandle_args args; +struct ofnode_phandle_args args;struct phy_ops *ops;int ret;struct udevice *phydev;
@@ -46,18 +45,17 @@ int generic_phy_get_by_index(struct udevice *dev, int index,debug ("%s(dev=%p, index=%d, phy=%p)\n" , __func__, dev, index, phy);assert (phy); - ret =fdtdec_parse_phandle_with_args (gd->fdt_blob,dev_of_offset (dev), -"phys" ,"#phy-cells" ,0 , index, - &args); + ret =dev_read_phandle_with_args (dev,"phys" ,"#phy-cells" ,0 , index, + &args);if (ret) { -debug ("%s: fdtdec_parse_phandle_with_args failed: err=%d\n" , +debug ("%s: dev_read_phandle_with_args failed: err=%d\n" , __func__, ret);return ret; } - ret =uclass_get_device_by_of_offset (UCLASS_PHY , args.node, &phydev); + ret =uclass_get_device_by_ofnode (UCLASS_PHY , args.node, &phydev);if (ret) { -debug ("%s: uclass_get_device_by_of_offset failed: err=%d\n" , +debug ("%s: uclass_get_device_by_ofnode failed: err=%d\n" , __func__, ret);return ret; }
@@ -88,10 +86,9 @@ int generic_phy_get_by_name(struct udevice *dev, const char *phy_name,debug ("%s(dev=%p, name=%s, phy=%p)\n" , __func__, dev, phy_name, phy); - index =fdt_stringlist_search (gd->fdt_blob,dev_of_offset (dev), -"phy-names" , phy_name); + index =dev_read_stringlist_search (dev,"phy-names" , phy_name);if (index <0 ) { -debug ("fdt_stringlist_search() failed: %d\n" , index); +debug ("dev_read_stringlist_search() failed: %d\n" , index);return index; }
include/generic-phy.h +1 -2
@@ -50,8 +50,7 @@ struct phy_ops {* @args: The phy specifier values from device tree. * @return 0 if OK, or a negative error code. */ -int (*of_xlate)(struct phy *phy, -struct fdtdec_phandle_args *args); +int (*of_xlate)(struct phy *phy,struct ofnode_phandle_args *args);/** * init - initialize the hardware.
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 57/72 dm: phy: Update uclass to support livetree
Update the phy uclass to support livetree. Fix the xlate() method which has no callers.
---
Changes in v3: None
Changes in v2: None
drivers/phy/phy-uclass.c | 21 +++++++++------------ include/generic-phy.h | 3 +-- 2 files changed, 10 insertions(+), 14 deletions(-)
Applied to u-boot-dm
PATCH v3 58/72 sandbox: phy: Update driver for livetree
In reply to Simon GlassUpdate the sandbox phy driver to support livetree.
---
Changes in v3: None
Changes in v2: None
drivers/phy/sandbox-phy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/phy/sandbox-phy.c +1 -2
@@ -80,8 +80,7 @@ static int sandbox_phy_probe(struct udevice *dev) priv->initialized = false; priv->on = false; - priv->broken =fdtdec_get_bool (gd->fdt_blob,dev_of_offset (dev), -"broken" ); + priv->broken =dev_read_bool (dev,"broken" );return 0 ; }
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 58/72 sandbox: phy: Update driver for livetree
Update the sandbox phy driver to support livetree.
---
Changes in v3: None
Changes in v2: None
drivers/phy/sandbox-phy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Applied to u-boot-dm
PATCH v3 59/72 dm: power-domain: Update uclass to support livetree
In reply to Simon GlassUpdate the power domain uclass to support livetree. Fix the xlate() method which has no callers.
---
Changes in v3: None
Changes in v2: None
drivers/power/domain/power-domain-uclass.c | 19 ++++++++----------- include/power-domain-uclass.h | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-)
drivers/power/domain/power-domain-uclass.c +8 -11
@@ -6,7 +6,6 @@#include <common.h> #include <dm.h> -#include <fdtdec.h> #include <power-domain.h> #include <power-domain-uclass.h>
@@ -18,7 +17,7 @@ static inline struct power_domain_ops *power_domain_dev_ops(struct udevice *dev) }static int power_domain_of_xlate_default (struct power_domain *power_domain, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {debug ("%s(power_domain=%p)\n" , __func__, power_domain);
@@ -34,27 +33,25 @@ static int power_domain_of_xlate_default(struct power_domain *power_domain,int power_domain_get (struct udevice *dev,struct power_domain *power_domain) { -struct fdtdec_phandle_args args; +struct ofnode_phandle_args args;int ret;struct udevice *dev_power_domain;struct power_domain_ops *ops;debug ("%s(dev=%p, power_domain=%p)\n" , __func__, dev, power_domain); - ret =fdtdec_parse_phandle_with_args (gd->fdt_blob,dev_of_offset (dev), -"power-domains" , -"#power-domain-cells" ,0 ,0 , - &args); + ret =dev_read_phandle_with_args (dev,"power-domains" , +"#power-domain-cells" ,0 ,0 , &args);if (ret) { -debug ("%s: fdtdec_parse_phandle_with_args failed: %d\n" , +debug ("%s: dev_read_phandle_with_args failed: %d\n" , __func__, ret);return ret; } - ret =uclass_get_device_by_of_offset (UCLASS_POWER_DOMAIN , args.node, - &dev_power_domain); + ret =uclass_get_device_by_ofnode (UCLASS_POWER_DOMAIN , args.node, + &dev_power_domain);if (ret) { -debug ("%s: uclass_get_device_by_of_offset failed: %d\n" , +debug ("%s: uclass_get_device_by_ofnode failed: %d\n" , __func__, ret);return ret; }
include/power-domain-uclass.h +1 -1
@@ -40,7 +40,7 @@ struct power_domain_ops {* @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct power_domain *power_domain, -struct fdtdec_phandle_args *args); +struct ofnode_phandle_args *args);/** * request - Request a translated power domain. *
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 59/72 dm: power-domain: Update uclass to support livetree
Update the power domain uclass to support livetree. Fix the xlate() method which has no callers.
---
Changes in v3: None
Changes in v2: None
drivers/power/domain/power-domain-uclass.c | 19 ++++++++----------- include/power-domain-uclass.h | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-)
Applied to u-boot-dm
PATCH v3 60/72 dm: reset: Update uclass to support livetree
In reply to Simon GlassUpdate the reset domain uclass to support livetree. Fix the xlate() method which has no callers.
---
Changes in v3: None
Changes in v2: None
drivers/reset/reset-uclass.c | 21 ++++++++++----------- include/reset-uclass.h | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-)
drivers/reset/reset-uclass.c +10 -11
@@ -18,7 +18,7 @@ static inline struct reset_ops *reset_dev_ops(struct udevice *dev) }static int reset_of_xlate_default (struct reset_ctl *reset_ctl, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) {debug ("%s(reset_ctl=%p)\n" , __func__, reset_ctl);
@@ -35,7 +35,7 @@ static int reset_of_xlate_default(struct reset_ctl *reset_ctl,int reset_get_by_index (struct udevice *dev,int index,struct reset_ctl *reset_ctl) { -struct fdtdec_phandle_args args; +struct ofnode_phandle_args args;int ret;struct udevice *dev_reset;struct reset_ops *ops;
@@ -43,20 +43,20 @@ int reset_get_by_index(struct udevice *dev, int index,debug ("%s(dev=%p, index=%d, reset_ctl=%p)\n" , __func__, dev, index, reset_ctl); - ret =fdtdec_parse_phandle_with_args (gd->fdt_blob,dev_of_offset (dev), -"resets" ,"#reset-cells" ,0 , - index, &args); + ret =dev_read_phandle_with_args (dev,"resets" ,"#reset-cells" ,0 , + index, &args);if (ret) { -debug ("%s: fdtdec_parse_phandle_with_args failed: %d\n" , +debug ("%s: fdtdec_parse_phandle_with_args() failed: %d\n" , __func__, ret);return ret; } - ret =uclass_get_device_by_of_offset (UCLASS_RESET , args.node, - &dev_reset); + ret =uclass_get_device_by_ofnode (UCLASS_RESET , args.node, + &dev_reset);if (ret) { -debug ("%s: uclass_get_device_by_of_offset failed: %d\n" , +debug ("%s: uclass_get_device_by_ofnode() failed: %d\n" , __func__, ret); +debug ("%s %d\n" ,ofnode_get_name (args.node), args.args[0 ]);return ret; } ops =reset_dev_ops (dev_reset);
@@ -88,8 +88,7 @@ int reset_get_by_name(struct udevice *dev, const char *name,debug ("%s(dev=%p, name=%s, reset_ctl=%p)\n" , __func__, dev, name, reset_ctl); - index =fdt_stringlist_search (gd->fdt_blob,dev_of_offset (dev), -"reset-names" , name); + index =dev_read_stringlist_search (dev,"reset-names" , name);if (index <0 ) {debug ("fdt_stringlist_search() failed: %d\n" , index);return index;
include/reset-uclass.h +2 -2
@@ -11,7 +11,7 @@#include <reset.h> -struct fdtdec_phandle_args ; +struct ofnode_phandle_args ;struct udevice ;/**
@@ -38,7 +38,7 @@ struct reset_ops {* @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct reset_ctl *reset_ctl, -struct fdtdec_phandle_args *args); +struct ofnode_phandle_args *args);/** * request - Request a translated reset control. *
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 60/72 dm: reset: Update uclass to support livetree
Update the reset domain uclass to support livetree. Fix the xlate() method which has no callers.
---
Changes in v3: None
Changes in v2: None
drivers/reset/reset-uclass.c | 21 ++++++++++----------- include/reset-uclass.h | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-)
Applied to u-boot-dm
PATCH v3 61/72 dm: pci: Update uclass to support livetree
In reply to Simon GlassUpdate the PCI uclass to support livetree. This mostly involves fixing the address decoding from the device tree.
---
Changes in v3: None
Changes in v2: None
drivers/pci/pci-uclass.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/pci/pci-uclass.c +12 -14
@@ -8,12 +8,11 @@#include <common.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> #include <inttypes.h> #include <pci.h> #include <asm/io.h> -#include <dm/lists.h> #include <dm/device-internal.h> +#include <dm/lists.h> #if defined(CONFIG_X86 ) && defined(CONFIG_HAVE_FSP )#include <asm/fsp/fsp_support.h> #endif
@@ -754,8 +753,8 @@ error:return ret; } -static int decode_regions (struct pci_controller *hose,const void *blob, -int parent_node,int node) +static int decode_regions (struct pci_controller *hose,ofnode parent_node, +ofnode node) {int pci_addr_cells, addr_cells, size_cells;phys_addr_t base =0 , size;
@@ -764,12 +763,12 @@ static int decode_regions(struct pci_controller *hose, const void *blob,int len;int i; - prop =fdt_getprop (blob, node,"ranges" , &len); + prop =ofnode_read_prop (node,"ranges" , &len);if (!prop)return -EINVAL ; - pci_addr_cells =fdt_address_cells (blob, node); - addr_cells =fdt_address_cells (blob, parent_node); - size_cells =fdt_size_cells (blob, node); + pci_addr_cells =ofnode_read_addr_cells (node); + addr_cells =ofnode_read_addr_cells (parent_node); + size_cells =ofnode_read_size_cells (node);/* PCI addresses are always 3-cells */ len /=sizeof (u32);
@@ -841,9 +840,8 @@ static int pci_uclass_pre_probe(struct udevice *bus)/* For bridges, use the top-level PCI controller */ if (!device_is_on_pci_bus (bus)) { hose->ctlr = bus; - ret =decode_regions (hose, gd->fdt_blob, -dev_of_offset (bus->parent), -dev_of_offset (bus)); + ret =decode_regions (hose,dev_ofnode (bus->parent), +dev_ofnode (bus));if (ret) {debug ("%s: Cannot decode regions\n" , __func__);return ret;
@@ -906,7 +904,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)struct fdt_pci_addr addr;int ret; -if (dev_of_offset (dev) ==-1 ) +if (!dev_of_valid (dev))return 0 ;/*
@@ -914,8 +912,8 @@ static int pci_uclass_child_post_bind(struct udevice *dev)* just check the address. */ pplat =dev_get_parent_platdata (dev); - ret =fdtdec_get_pci_addr (gd->fdt_blob,dev_of_offset (dev), -FDT_PCI_SPACE_CONFIG ,"reg" , &addr); + ret =ofnode_read_pci_addr (dev_ofnode (dev),FDT_PCI_SPACE_CONFIG ,"reg" , + &addr);if (ret) {if (ret != -ENOENT )
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 61/72 dm: pci: Update uclass to support livetree
Update the PCI uclass to support livetree. This mostly involves fixing the address decoding from the device tree.
---
Changes in v3: None
Changes in v2: None
drivers/pci/pci-uclass.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
Applied to u-boot-dm
PATCH v3 62/72 dm: Update the I2C eeprom driver for livetree
In reply to Simon GlassUpdate this driver so that it works with livetree.
---
Changes in v3: None
Changes in v2: None
drivers/misc/i2c_eeprom_emul.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/misc/i2c_eeprom_emul.c +2 -5
@@ -9,7 +9,6 @@#include <common.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> #include <i2c.h> #include <malloc.h> #include <asm/test.h>
@@ -115,10 +114,8 @@ static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev) {struct sandbox_i2c_flash_plat_data *plat =dev_get_platdata (dev); - plat->size =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"sandbox,size" ,32 ); - plat->filename =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), -"sandbox,filename" ,NULL ); + plat->size =dev_read_u32_default (dev,"sandbox,size" ,32 ); + plat->filename =dev_read_string (dev,"sandbox,filename" );if (!plat->filename) {debug ("%s: No filename for device '%s'\n" , __func__, dev->name);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 62/72 dm: Update the I2C eeprom driver for livetree
Update this driver so that it works with livetree.
---
Changes in v3: None
Changes in v2: None
drivers/misc/i2c_eeprom_emul.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Applied to u-boot-dm
PATCH v3 63/72 cros_ec: Update the cros_ec keyboard driver to livetree
In reply to Simon GlassUpdate this driver and key_matrix to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/input/cros_ec_keyb.c | 24 ++++++++++++------------ drivers/input/key_matrix.c | 19 +++++++++---------- drivers/input/tegra-kbc.c | 3 +-- include/key_matrix.h | 3 +-- 4 files changed, 23 insertions(+), 26 deletions(-)
drivers/input/cros_ec_keyb.c +12 -12
@@ -10,7 +10,6 @@#include <cros_ec.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> #include <input.h> #include <keyboard.h> #include <key_matrix.h>
@@ -161,15 +160,15 @@ int cros_ec_kbc_check(struct input_config *input)* @param config Configuration data read from fdt * @return 0 if ok, -1 on error */ -static int cros_ec_keyb_decode_fdt (const void *blob,int node, -struct cros_ec_keyb_priv *config) +static int cros_ec_keyb_decode_fdt (struct udevice *dev, +struct cros_ec_keyb_priv *config) {/* * Get keyboard rows and columns - at present we are limited to * 8 columns by the protocol (one byte per row scan) */ - config->key_rows =fdtdec_get_int (blob, node,"keypad,num-rows" ,0 ); - config->key_cols =fdtdec_get_int (blob, node,"keypad,num-columns" ,0 ); + config->key_rows =dev_read_u32_default (dev,"keypad,num-rows" ,0 ); + config->key_cols =dev_read_u32_default (dev,"keypad,num-columns" ,0 );if (!config->key_rows || !config->key_cols || config->key_rows * config->key_cols /8 >CROS_EC_KEYSCAN_COLS ) {
@@ -177,8 +176,8 @@ static int cros_ec_keyb_decode_fdt(const void *blob, int node, config->key_rows, config->key_cols);return -1 ; } - config->ghost_filter =fdtdec_get_bool (blob, node, -"google,needs-ghost-filter" ); + config->ghost_filter =dev_read_bool (dev,"google,needs-ghost-filter" ); +return 0 ; }
@@ -188,12 +187,13 @@ static int cros_ec_kbd_probe(struct udevice *dev)struct keyboard_priv *uc_priv =dev_get_uclass_priv (dev);struct stdio_dev *sdev = &uc_priv->sdev;struct input_config *input = &uc_priv->input; -const void *blob = gd->fdt_blob; -int node =dev_of_offset (dev);int ret; -if (cros_ec_keyb_decode_fdt (blob, node, priv)) -return -1 ; + ret =cros_ec_keyb_decode_fdt (dev, priv); +if (ret) { +debug ("%s: Cannot decode node (ret=%d)\n" , __func__, ret); +return -EINVAL ; + }input_set_delays (input,KBC_REPEAT_DELAY_MS ,KBC_REPEAT_RATE_MS ); ret =key_matrix_init (&priv->matrix, priv->key_rows, priv->key_cols, priv->ghost_filter);
@@ -201,7 +201,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)debug ("%s: cannot init key matrix\n" , __func__);return ret; } - ret =key_matrix_decode_fdt (&priv->matrix, gd->fdt_blob, node); + ret =key_matrix_decode_fdt (dev, &priv->matrix);if (ret) {debug ("%s: Could not decode key matrix from fdt\n" , __func__);return ret;
drivers/input/key_matrix.c +9 -10
@@ -8,7 +8,7 @@*/ #include <common.h> -#include <fdtdec.h> +#include <dm.h> #include <key_matrix.h> #include <malloc.h> #include <linux/input.h>
@@ -105,7 +105,7 @@ int key_matrix_decode(struct key_matrix *config, struct key_matrix_key keys[],* @param pos Returns position of map_keycode, if found, else -1 * @return map Pointer to allocated map */ -static uchar *create_keymap (struct key_matrix *config,u32 *data,int len, +static uchar *create_keymap (struct key_matrix *config,const u32 *data,int len,int map_keycode,int *pos) {uchar *map;
@@ -138,33 +138,32 @@ static uchar *create_keymap(struct key_matrix *config, u32 *data, int len,return map; } -int key_matrix_decode_fdt (struct key_matrix *config,const void *blob,int node) +int key_matrix_decode_fdt (struct udevice *dev,struct key_matrix *config) { -const struct fdt_property *prop; +const u32 *prop;int proplen;uchar *plain_keycode; - prop =fdt_get_property (blob, node,"linux,keymap" , &proplen); + prop =dev_read_prop (dev,"linux,keymap" , &proplen);/* Basic keymap is required */ if (!prop) {debug ("%s: cannot find keycode-plain map\n" , __func__);return -1 ; } - plain_keycode =create_keymap (config, (u32 *)prop->data, - proplen,KEY_FN , &config->fn_pos); + plain_keycode =create_keymap (config, prop, proplen,KEY_FN , + &config->fn_pos); config->plain_keycode = plain_keycode;/* Conversion error -> fail */ if (!config->plain_keycode)return -1 ; - prop =fdt_get_property (blob, node,"linux,fn-keymap" , &proplen); + prop =dev_read_prop (dev,"linux,fn-keymap" , &proplen);/* fn keymap is optional */ if (!prop) goto done; - config->fn_keycode =create_keymap (config, (u32 *)prop->data, - proplen,-1 ,NULL ); + config->fn_keycode =create_keymap (config, prop, proplen,-1 ,NULL );/* Conversion error -> fail */ if (!config->fn_keycode) {free (plain_keycode);
drivers/input/tegra-kbc.c +1 -2
@@ -290,7 +290,6 @@ static int tegra_kbd_probe(struct udevice *dev)struct keyboard_priv *uc_priv =dev_get_uclass_priv (dev);struct stdio_dev *sdev = &uc_priv->sdev;struct input_config *input = &uc_priv->input; -int node =dev_of_offset (dev);int ret; priv->kbc = (struct kbc_tegra *)devfdt_get_addr (dev);
@@ -306,7 +305,7 @@ static int tegra_kbd_probe(struct udevice *dev)debug ("%s: Could not init key matrix: %d\n" , __func__, ret);return ret; } - ret =key_matrix_decode_fdt (&priv->matrix, gd->fdt_blob, node); + ret =key_matrix_decode_fdt (dev, &priv->matrix);if (ret) {debug ("%s: Could not decode key matrix from fdt: %d\n" , __func__, ret);
include/key_matrix.h +1 -2
@@ -69,8 +69,7 @@ int key_matrix_decode(struct key_matrix *config, struct key_matrix_key *keys,* @param node Node containing compatible data * @return 0 if ok, -1 on error */ -int key_matrix_decode_fdt (struct key_matrix *config,const void *blob, -int node); +int key_matrix_decode_fdt (struct udevice *dev,struct key_matrix *config);/** * Set up a new key matrix.
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 63/72 cros_ec: Update the cros_ec keyboard driver to livetree
Update this driver and key_matrix to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/input/cros_ec_keyb.c | 24 ++++++++++++------------ drivers/input/key_matrix.c | 19 +++++++++---------- drivers/input/tegra-kbc.c | 3 +-- include/key_matrix.h | 3 +-- 4 files changed, 23 insertions(+), 26 deletions(-)
Applied to u-boot-dm
PATCH v3 64/72 dm: spi: Convert uclass to livetree
In reply to Simon GlassUpdate the SPI uclass to support a live device tree. Also adjust spi_slave_ofdata_to_platdata() to accept a device instead of a blob and offset.
---
Changes in v3: None
Changes in v2: None
drivers/spi/spi-uclass.c | 31 ++++++++++++++----------------- include/spi.h | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-)
drivers/spi/spi-uclass.c +14 -17
@@ -7,7 +7,6 @@#include <common.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> #include <malloc.h> #include <spi.h> #include <dm/device-internal.h>
@@ -113,11 +112,10 @@ static int spi_child_post_bind(struct udevice *dev) {struct dm_spi_slave_platdata *plat =dev_get_parent_platdata (dev); -if (dev_of_offset (dev) ==-1 ) +if (!dev_of_valid (dev))return 0 ; -return spi_slave_ofdata_to_platdata (gd->fdt_blob,dev_of_offset (dev), - plat); +return spi_slave_ofdata_to_platdata (dev, plat); }#endif
@@ -126,8 +124,7 @@ static int spi_post_probe(struct udevice *bus)#if !CONFIG_IS_ENABLED (OF_PLATDATA )struct dm_spi_bus *spi =dev_get_uclass_priv (bus); - spi->max_hz =fdtdec_get_int (gd->fdt_blob,dev_of_offset (bus), -"spi-max-frequency" ,0 ); + spi->max_hz =dev_read_u32_default (bus,"spi-max-frequency" ,0 );#endif #if defined(CONFIG_NEEDS_MANUAL_RELOC )struct dm_spi_ops *ops =spi_get_ops (bus);
@@ -375,7 +372,7 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs,int ret; ret =spi_get_bus_and_cs (busnum, cs, speed, mode,NULL ,0 , &dev, - &slave); + &slave);if (ret)return NULL ;
@@ -388,27 +385,27 @@ void spi_free_slave(struct spi_slave *slave) slave->dev =NULL ; } -int spi_slave_ofdata_to_platdata (const void *blob,int node, +int spi_slave_ofdata_to_platdata (struct udevice *dev,struct dm_spi_slave_platdata *plat) {int mode =0 ;int value; - plat->cs =fdtdec_get_int (blob, node,"reg" ,-1 ); - plat->max_hz =fdtdec_get_int (blob, node,"spi-max-frequency" ,0 ); -if (fdtdec_get_bool (blob, node,"spi-cpol" )) + plat->cs =dev_read_u32_default (dev,"reg" ,-1 ); + plat->max_hz =dev_read_u32_default (dev,"spi-max-frequency" ,0 ); +if (dev_read_bool (dev,"spi-cpol" )) mode |=SPI_CPOL ; -if (fdtdec_get_bool (blob, node,"spi-cpha" )) +if (dev_read_bool (dev,"spi-cpha" )) mode |=SPI_CPHA ; -if (fdtdec_get_bool (blob, node,"spi-cs-high" )) +if (dev_read_bool (dev,"spi-cs-high" )) mode |=SPI_CS_HIGH ; -if (fdtdec_get_bool (blob, node,"spi-3wire" )) +if (dev_read_bool (dev,"spi-3wire" )) mode |=SPI_3WIRE ; -if (fdtdec_get_bool (blob, node,"spi-half-duplex" )) +if (dev_read_bool (dev,"spi-half-duplex" )) mode |=SPI_PREAMBLE ;/* Device DUAL/QUAD mode */ - value =fdtdec_get_uint (blob, node,"spi-tx-bus-width" ,1 ); + value =dev_read_u32_default (dev,"spi-tx-bus-width" ,1 );switch (value) {case 1 :break ;
@@ -423,7 +420,7 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node,break ; } - value =fdtdec_get_uint (blob, node,"spi-rx-bus-width" ,1 ); + value =dev_read_u32_default (dev,"spi-rx-bus-width" ,1 );switch (value) {case 1 :break ;
include/spi.h +1 -1
@@ -562,7 +562,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 (const void *blob,int node, +int spi_slave_ofdata_to_platdata (struct udevice *dev,struct dm_spi_slave_platdata *plat);/**
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 64/72 dm: spi: Convert uclass to livetree
Update the SPI uclass to support a live device tree. Also adjust spi_slave_ofdata_to_platdata() to accept a device instead of a blob and offset.
---
Changes in v3: None
Changes in v2: None
drivers/spi/spi-uclass.c | 31 ++++++++++++++----------------- include/spi.h | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-)
Applied to u-boot-dm
PATCH v3 65/72 dm: sandbox: i2c: Drop fdtdec.h header
In reply to Simon GlassThis is not needed in this driver. Drop it.
---
Changes in v3: None
Changes in v2: None
drivers/i2c/sandbox_i2c.c | 1 - 1 file changed, 1 deletion(-)
drivers/i2c/sandbox_i2c.c +0 -1
@@ -9,7 +9,6 @@#include <common.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> #include <i2c.h> #include <asm/test.h> #include <dm/lists.h>
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 65/72 dm: sandbox: i2c: Drop fdtdec.h header
This is not needed in this driver. Drop it.
---
Changes in v3: None
Changes in v2: None
drivers/i2c/sandbox_i2c.c | 1 - 1 file changed, 1 deletion(-)
Applied to u-boot-dm
PATCH v3 66/72 dm: sandbox: i2c_rtc: Drop fdtdec.h header
In reply to Simon GlassThis is not needed in this driver. Drop it.
---
Changes in v3: None
Changes in v2: None
drivers/rtc/i2c_rtc_emul.c | 1 - 1 file changed, 1 deletion(-)
drivers/rtc/i2c_rtc_emul.c +0 -1
@@ -16,7 +16,6 @@#include <common.h> #include <dm.h> -#include <fdtdec.h> #include <i2c.h> #include <os.h> #include <rtc.h>
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 66/72 dm: sandbox: i2c_rtc: Drop fdtdec.h header
This is not needed in this driver. Drop it.
---
Changes in v3: None
Changes in v2: None
drivers/rtc/i2c_rtc_emul.c | 1 - 1 file changed, 1 deletion(-)
Applied to u-boot-dm
PATCH v3 67/72 dm: spi-flash: Convert uclass to livetree
In reply to Simon GlassUpdate the SPI flash uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/mtd/spi/spi_flash.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/mtd/spi/spi_flash.c +3 -4
@@ -914,14 +914,13 @@ static int set_quad_mode(struct spi_flash *flash, }#if CONFIG_IS_ENABLED (OF_CONTROL ) -int spi_flash_decode_fdt (const void *blob,struct spi_flash *flash) +int spi_flash_decode_fdt (struct spi_flash *flash) {#ifdef CONFIG_DM_SPI_FLASH fdt_addr_t addr;fdt_size_t size; -int node =dev_of_offset (flash->dev); - addr =fdtdec_get_addr_size (blob, node,"memory-map" , &size); + addr =dev_read_addr_size (flash->dev,"memory-map" , &size);if (addr ==FDT_ADDR_T_NONE ) {debug ("%s: Cannot decode address\n" , __func__);return 0 ;
@@ -1081,7 +1080,7 @@ int spi_flash_scan(struct spi_flash *flash)#endif #if CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA ) - ret =spi_flash_decode_fdt (gd->fdt_blob, flash); + ret =spi_flash_decode_fdt (flash);if (ret) {debug ("SF: FDT decode error\n" );return -EINVAL ;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 67/72 dm: spi-flash: Convert uclass to livetree
Update the SPI flash uclass to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/mtd/spi/spi_flash.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Applied to u-boot-dm
PATCH v3 68/72 dm: sandbox: spi: Convert driver to support livetree
In reply to Simon GlassUpdate this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/mtd/spi/sandbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mtd/spi/sandbox.c +2 -4
@@ -515,11 +515,9 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,int sandbox_sf_ofdata_to_platdata (struct udevice *dev) {struct sandbox_spi_flash_plat_data *pdata =dev_get_platdata (dev); -const void *blob = gd->fdt_blob; -int node =dev_of_offset (dev); - pdata->filename =fdt_getprop (blob, node,"sandbox,filename" ,NULL ); - pdata->device_name =fdt_getprop (blob, node,"compatible" ,NULL ); + pdata->filename =dev_read_string (dev,"sandbox,filename" ); + pdata->device_name =dev_read_string (dev,"compatible" );if (!pdata->filename || !pdata->device_name) {debug ("%s: Missing properties, filename=%s, device_name=%s\n" , __func__, pdata->filename, pdata->device_name);
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 68/72 dm: sandbox: spi: Convert driver to support livetree
Update this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/mtd/spi/sandbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Applied to u-boot-dm
PATCH v3 69/72 dm: sandbox: sysreset: Convert driver to livetree
In reply to Simon GlassUpdate this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/sysreset/sysreset_sandbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/sysreset/sysreset_sandbox.c +1 -1
@@ -41,7 +41,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)* (see the U_BOOT_DEVICE() declaration below) should not do anything. * If we are that device, return an error. */ -if (state->fdt_fname &&dev_of_offset (dev) ==-1 ) +if (state->fdt_fname && !dev_of_valid (dev))return -ENODEV ;switch (type) {
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 69/72 dm: sandbox: sysreset: Convert driver to livetree
Update this driver to support a live device tree.
---
Changes in v3: None
Changes in v2: None
drivers/sysreset/sysreset_sandbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 70/72 dm: test: Fix nit with position of backslash
In reply to Simon GlassLine up this backslash with all the others.
---
Changes in v3: None
Changes in v2: None
include/test/ut.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/test/ut.h +1 -1
@@ -104,7 +104,7 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line, }/* Assert that a pointer is not an error pointer */ -#define ut_assertok_ptr (expr) { \ +#define ut_assertok_ptr (expr) { \ const void *val = (expr); \ \ if (IS_ERR(val)) { \
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 70/72 dm: test: Fix nit with position of backslash
Line up this backslash with all the others.
---
Changes in v3: None
Changes in v2: None
include/test/ut.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v3 71/72 dm: gpio: power: Convert pm8916 drivers to livetree
In reply to Simon GlassThis PMIC driver (power and GPIO) is used by the sandbox SPMI tests. Update the drivers to support a live device tree so that the tests pass.
---
Changes in v3: None
Changes in v2: None
drivers/gpio/pm8916_gpio.c | 8 +++----- drivers/power/pmic/pm8916.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpio/pm8916_gpio.c +3 -5
@@ -173,7 +173,7 @@ static int pm8916_gpio_probe(struct udevice *dev)struct pm8916_gpio_bank *priv =dev_get_priv (dev);int reg; - priv->pid =devfdt_get_addr (dev); + priv->pid =dev_read_addr (dev);if (priv->pid ==FDT_ADDR_T_NONE )return -EINVAL ;
@@ -193,10 +193,8 @@ static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev) {struct gpio_dev_priv *uc_priv =dev_get_uclass_priv (dev); - uc_priv->gpio_count =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"gpio-count" ,0 ); - uc_priv->bank_name =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), -"gpio-bank-name" ,NULL ); + uc_priv->gpio_count =dev_read_u32_default (dev,"gpio-count" ,0 ); + uc_priv->bank_name =dev_read_string (dev,"gpio-bank-name" );if (uc_priv->bank_name ==NULL ) uc_priv->bank_name ="pm8916" ;
drivers/power/pmic/pm8916.c +1 -1
@@ -70,7 +70,7 @@ static int pm8916_probe(struct udevice *dev) {struct pm8916_priv *priv =dev_get_priv (dev); - priv->usid =devfdt_get_addr (dev); + priv->usid =dev_read_addr (dev);if (priv->usid ==FDT_ADDR_T_NONE )return -EINVAL ;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 72/72 sandbox: Move to use live tree
In reply to Simon GlassThis updates sandbox to use a live device tree. This means that after relocation (from board_init_r() onwards) it no-longer uses flat device tree.
---
Changes in v3: None
Changes in v2:
- Rewrite based on testing and refining the v1 series
- Convert various subsystems to enable sandbox tests to pass
configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/sandbox_defconfig +1 -0
@@ -58,6 +58,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_MAC_PARTITION=y CONFIG_AMIGA_PARTITION=y CONFIG_OF_CONTROL=y +CONFIG_OF_LIVE=y CONFIG_OF_HOSTFILE=y CONFIG_NETCONSOLE=y CONFIG_REGMAP=y
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH v3 72/72 sandbox: Move to use live tree
This updates sandbox to use a live device tree. This means that after relocation (from board_init_r() onwards) it no-longer uses flat device tree.
---
Changes in v3: None
Changes in v2:
- Rewrite based on testing and refining the v1 series
- Convert various subsystems to enable sandbox tests to pass
configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm