mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 12:56:00 +01:00
replace devfdt_get_addr_ptr() with dev_read_addr_ptr()
binman fixes for portage various minor fixes 'bind' command improvements -----BEGIN PGP SIGNATURE----- iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAl9BbZcRHHNqZ0BjaHJv bWl1bS5vcmcACgkQfxc6PpAIreZZiQf/UVsriftmxdDz3Lvbz7Jw6UCBXbeM3UN8 KgRxVll3kurZeu8bIcjAPY4YRrbWRqSXmZTXpZWgbyZzHLM4RnkamY3KF3DoxPjc cbskd/fr4nPjSZVFrkzrvD+D5bhm+VrMtf861AkbAqqpG+Q1FmWHgApqOL1fXn3s 2VoMxRz8Cn9KkSDmxaCtJnLX77GVYYdfgii7RuNWGDqr3eBWrzflV38VbPHLplEg VLqaLBe3G4zVwElA9Nc2hXpZB84KZEETHcBnmCzNkrSYTN2ofvSeZrWbtRztQFhz yKur1y7jFsryRkMfxBzgldsKFRNnPT9vr+0qGtrztHjCmvhDkx1YMg== =iDRJ -----END PGP SIGNATURE----- Merge tag 'dm-pull-22aug20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm replace devfdt_get_addr_ptr() with dev_read_addr_ptr() binman fixes for portage various minor fixes 'bind' command improvements
This commit is contained in:
commit
d584648dad
@ -16,8 +16,6 @@ SECTIONS
|
|||||||
__u_boot_sandbox_option_start = .;
|
__u_boot_sandbox_option_start = .;
|
||||||
_u_boot_sandbox_getopt : { KEEP(*(.u_boot_sandbox_getopt)) }
|
_u_boot_sandbox_getopt : { KEEP(*(.u_boot_sandbox_getopt)) }
|
||||||
__u_boot_sandbox_option_end = .;
|
__u_boot_sandbox_option_end = .;
|
||||||
|
|
||||||
__bss_start = .;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INSERT AFTER .data;
|
INSERT AFTER .data;
|
||||||
|
@ -44,8 +44,6 @@ SECTIONS
|
|||||||
{
|
{
|
||||||
*(.__efi_runtime_rel_stop)
|
*(.__efi_runtime_rel_stop)
|
||||||
}
|
}
|
||||||
|
|
||||||
__bss_start = .;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INSERT BEFORE .data;
|
INSERT BEFORE .data;
|
||||||
|
@ -149,6 +149,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
bind-test {
|
bind-test {
|
||||||
|
compatible = "simple-bus";
|
||||||
bind-test-child1 {
|
bind-test-child1 {
|
||||||
compatible = "sandbox,phy";
|
compatible = "sandbox,phy";
|
||||||
#phy-cells = <1>;
|
#phy-cells = <1>;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <dm/device-internal.h>
|
#include <dm/device-internal.h>
|
||||||
#include <dm/lists.h>
|
#include <dm/lists.h>
|
||||||
|
#include <dm/root.h>
|
||||||
#include <dm/uclass-internal.h>
|
#include <dm/uclass-internal.h>
|
||||||
|
|
||||||
static int bind_by_class_index(const char *uclass, int index,
|
static int bind_by_class_index(const char *uclass, int index,
|
||||||
@ -151,8 +152,8 @@ static int bind_by_node_path(const char *path, const char *drv_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ofnode = ofnode_path(path);
|
ofnode = ofnode_path(path);
|
||||||
ret = device_bind_with_driver_data(parent, drv, ofnode_get_name(ofnode),
|
ret = lists_bind_fdt(parent, ofnode, &dev, false);
|
||||||
0, ofnode, &dev);
|
|
||||||
if (!dev || ret) {
|
if (!dev || ret) {
|
||||||
printf("Unable to bind. err:%d\n", ret);
|
printf("Unable to bind. err:%d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -254,11 +254,7 @@ __weak int dram_init_banksize(void)
|
|||||||
static int init_func_i2c(void)
|
static int init_func_i2c(void)
|
||||||
{
|
{
|
||||||
puts("I2C: ");
|
puts("I2C: ");
|
||||||
#ifdef CONFIG_SYS_I2C
|
|
||||||
i2c_init_all();
|
i2c_init_all();
|
||||||
#else
|
|
||||||
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
|
|
||||||
#endif
|
|
||||||
puts("ready\n");
|
puts("ready\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
49
doc/driver-model/bind.rst
Normal file
49
doc/driver-model/bind.rst
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
.. SPDX-License-Identifier: GPL-2.0+
|
||||||
|
.. sectionauthor:: Patrice Chotard <patrice.chotard@st.com>
|
||||||
|
|
||||||
|
Binding/unbinding a driver
|
||||||
|
==========================
|
||||||
|
|
||||||
|
This document aims to describe the bind and unbind commands.
|
||||||
|
|
||||||
|
For debugging purpose, it should be useful to bind or unbind a driver from
|
||||||
|
the U-boot command line.
|
||||||
|
|
||||||
|
The unbind command calls the remove device driver callback and unbind the
|
||||||
|
device from its driver.
|
||||||
|
|
||||||
|
The bind command binds a device to its driver.
|
||||||
|
|
||||||
|
In some cases it can be useful to be able to bind a device to a driver from
|
||||||
|
the command line.
|
||||||
|
The obvious example is for versatile devices such as USB gadget.
|
||||||
|
Another use case is when the devices are not yet ready at startup and
|
||||||
|
require some setup before the drivers are bound (ex: FPGA which bitsream is
|
||||||
|
fetched from a mass storage or ethernet)
|
||||||
|
|
||||||
|
usage:
|
||||||
|
|
||||||
|
bind <node path> <driver>
|
||||||
|
bind <class> <index> <driver>
|
||||||
|
|
||||||
|
unbind <node path>
|
||||||
|
unbind <class> <index>
|
||||||
|
unbind <class> <index> <driver>
|
||||||
|
|
||||||
|
Where:
|
||||||
|
- <node path> is the node's device tree path
|
||||||
|
- <class> is one of the class available in the list given by the "dm uclass"
|
||||||
|
command or first column of "dm tree" command.
|
||||||
|
- <index> is the index of the parent's node (second column of "dm tree" output).
|
||||||
|
- <driver> is the driver name to bind given by the "dm drivers" command or the by
|
||||||
|
the fourth column of "dm tree" output.
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
bind usb_dev_generic 0 usb_ether
|
||||||
|
unbind usb_dev_generic 0 usb_ether
|
||||||
|
or
|
||||||
|
unbind eth 1
|
||||||
|
|
||||||
|
bind /ocp/omap_dwc3@48380000/usb@48390000 usb_ether
|
||||||
|
unbind /ocp/omap_dwc3@48380000/usb@48390000
|
@ -6,6 +6,7 @@ Driver Model
|
|||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
|
bind
|
||||||
debugging
|
debugging
|
||||||
design
|
design
|
||||||
ethernet
|
ethernet
|
||||||
|
@ -39,7 +39,7 @@ static int mvebu_ahci_probe(struct udevice *dev)
|
|||||||
*/
|
*/
|
||||||
board_ahci_enable();
|
board_ahci_enable();
|
||||||
|
|
||||||
ahci_probe_scsi(dev, (ulong)devfdt_get_addr_ptr(dev));
|
ahci_probe_scsi(dev, dev_read_addr(dev));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -497,9 +497,9 @@ static int ast2500_clk_ofdata_to_platdata(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct ast2500_clk_priv *priv = dev_get_priv(dev);
|
struct ast2500_clk_priv *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
priv->scu = devfdt_get_addr_ptr(dev);
|
priv->scu = dev_read_addr_ptr(dev);
|
||||||
if (IS_ERR(priv->scu))
|
if (!priv->scu)
|
||||||
return PTR_ERR(priv->scu);
|
return -EINVAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ int at91_pmc_core_probe(struct udevice *dev)
|
|||||||
|
|
||||||
dev = dev_get_parent(dev);
|
dev = dev_get_parent(dev);
|
||||||
|
|
||||||
plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev);
|
plat->reg_base = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ int at91_clk_probe(struct udevice *dev)
|
|||||||
dev_periph_container = dev_get_parent(dev);
|
dev_periph_container = dev_get_parent(dev);
|
||||||
dev_pmc = dev_get_parent(dev_periph_container);
|
dev_pmc = dev_get_parent(dev_periph_container);
|
||||||
|
|
||||||
plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev_pmc);
|
plat->reg_base = dev_read_addr_ptr(dev_pmc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,9 @@ fdt_addr_t devfdt_get_addr(const struct udevice *dev)
|
|||||||
|
|
||||||
void *devfdt_get_addr_ptr(const struct udevice *dev)
|
void *devfdt_get_addr_ptr(const struct udevice *dev)
|
||||||
{
|
{
|
||||||
return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0);
|
fdt_addr_t addr = devfdt_get_addr_index(dev, 0);
|
||||||
|
|
||||||
|
return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *devfdt_remap_addr_index(const struct udevice *dev, int index)
|
void *devfdt_remap_addr_index(const struct udevice *dev, int index)
|
||||||
|
@ -776,18 +776,26 @@ int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device)
|
|||||||
|
|
||||||
int ofnode_read_addr_cells(ofnode node)
|
int ofnode_read_addr_cells(ofnode node)
|
||||||
{
|
{
|
||||||
if (ofnode_is_np(node))
|
if (ofnode_is_np(node)) {
|
||||||
return of_n_addr_cells(ofnode_to_np(node));
|
return of_n_addr_cells(ofnode_to_np(node));
|
||||||
else /* NOTE: this call should walk up the parent stack */
|
} else {
|
||||||
return fdt_address_cells(gd->fdt_blob, ofnode_to_offset(node));
|
int parent = fdt_parent_offset(gd->fdt_blob,
|
||||||
|
ofnode_to_offset(node));
|
||||||
|
|
||||||
|
return fdt_address_cells(gd->fdt_blob, parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ofnode_read_size_cells(ofnode node)
|
int ofnode_read_size_cells(ofnode node)
|
||||||
{
|
{
|
||||||
if (ofnode_is_np(node))
|
if (ofnode_is_np(node)) {
|
||||||
return of_n_size_cells(ofnode_to_np(node));
|
return of_n_size_cells(ofnode_to_np(node));
|
||||||
else /* NOTE: this call should walk up the parent stack */
|
} else {
|
||||||
return fdt_size_cells(gd->fdt_blob, ofnode_to_offset(node));
|
int parent = fdt_parent_offset(gd->fdt_blob,
|
||||||
|
ofnode_to_offset(node));
|
||||||
|
|
||||||
|
return fdt_size_cells(gd->fdt_blob, parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ofnode_read_simple_addr_cells(ofnode node)
|
int ofnode_read_simple_addr_cells(ofnode node)
|
||||||
|
@ -606,7 +606,7 @@ static int at91_gpio_probe(struct udevice *dev)
|
|||||||
clk_free(&clk);
|
clk_free(&clk);
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
||||||
plat->base_addr = (uint32_t)devfdt_get_addr_ptr(dev);
|
plat->base_addr = dev_read_addr(dev);
|
||||||
#endif
|
#endif
|
||||||
plat->bank_name = at91_get_bank_name(plat->base_addr);
|
plat->bank_name = at91_get_bank_name(plat->base_addr);
|
||||||
port->regs = (struct at91_port *)plat->base_addr;
|
port->regs = (struct at91_port *)plat->base_addr;
|
||||||
|
@ -83,7 +83,7 @@ static int hsdk_creg_gpio_probe(struct udevice *dev)
|
|||||||
u32 shift, bit_per_gpio, activate, deactivate, gpio_count;
|
u32 shift, bit_per_gpio, activate, deactivate, gpio_count;
|
||||||
const u8 *defaults;
|
const u8 *defaults;
|
||||||
|
|
||||||
hcg->regs = (u32 *)devfdt_get_addr_ptr(dev);
|
hcg->regs = dev_read_addr_ptr(dev);
|
||||||
gpio_count = dev_read_u32_default(dev, "gpio-count", 1);
|
gpio_count = dev_read_u32_default(dev, "gpio-count", 1);
|
||||||
shift = dev_read_u32_default(dev, "gpio-first-shift", 0);
|
shift = dev_read_u32_default(dev, "gpio-first-shift", 0);
|
||||||
bit_per_gpio = dev_read_u32_default(dev, "gpio-bit-per-line", 1);
|
bit_per_gpio = dev_read_u32_default(dev, "gpio-bit-per-line", 1);
|
||||||
|
@ -92,9 +92,9 @@ static int ast_i2c_ofdata_to_platdata(struct udevice *dev)
|
|||||||
struct ast_i2c_priv *priv = dev_get_priv(dev);
|
struct ast_i2c_priv *priv = dev_get_priv(dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
priv->regs = devfdt_get_addr_ptr(dev);
|
priv->regs = dev_read_addr_ptr(dev);
|
||||||
if (IS_ERR(priv->regs))
|
if (!priv->regs)
|
||||||
return PTR_ERR(priv->regs);
|
return -EINVAL;
|
||||||
|
|
||||||
ret = clk_get_by_index(dev, 0, &priv->clk);
|
ret = clk_get_by_index(dev, 0, &priv->clk);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -768,7 +768,7 @@ int designware_i2c_ofdata_to_platdata(struct udevice *bus)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!priv->regs)
|
if (!priv->regs)
|
||||||
priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
|
priv->regs = dev_read_addr_ptr(bus);
|
||||||
dev_read_u32(bus, "i2c-scl-rising-time-ns", &priv->scl_rise_time_ns);
|
dev_read_u32(bus, "i2c-scl-rising-time-ns", &priv->scl_rise_time_ns);
|
||||||
dev_read_u32(bus, "i2c-scl-falling-time-ns", &priv->scl_fall_time_ns);
|
dev_read_u32(bus, "i2c-scl-falling-time-ns", &priv->scl_fall_time_ns);
|
||||||
dev_read_u32(bus, "i2c-sda-hold-time-ns", &priv->sda_hold_time_ns);
|
dev_read_u32(bus, "i2c-sda-hold-time-ns", &priv->sda_hold_time_ns);
|
||||||
|
@ -580,7 +580,7 @@ static int mv_i2c_probe(struct udevice *bus)
|
|||||||
{
|
{
|
||||||
struct mv_i2c_priv *priv = dev_get_priv(bus);
|
struct mv_i2c_priv *priv = dev_get_priv(bus);
|
||||||
|
|
||||||
priv->base = (void *)devfdt_get_addr_ptr(bus);
|
priv->base = dev_read_addr_ptr(bus);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -798,7 +798,7 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus)
|
|||||||
{
|
{
|
||||||
struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
|
struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
|
||||||
|
|
||||||
dev->base = devfdt_get_addr_ptr(bus);
|
dev->base = dev_read_addr_ptr(bus);
|
||||||
|
|
||||||
if (!dev->base)
|
if (!dev->base)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -820,7 +820,7 @@ static void twsi_disable_i2c_slave(struct mvtwsi_registers *twsi)
|
|||||||
|
|
||||||
static int mvtwsi_i2c_bind(struct udevice *bus)
|
static int mvtwsi_i2c_bind(struct udevice *bus)
|
||||||
{
|
{
|
||||||
struct mvtwsi_registers *twsi = devfdt_get_addr_ptr(bus);
|
struct mvtwsi_registers *twsi = dev_read_addr_ptr(bus);
|
||||||
|
|
||||||
/* Disable the hidden slave in i2c0 of these platforms */
|
/* Disable the hidden slave in i2c0 of these platforms */
|
||||||
if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARCH_KIRKWOOD))
|
if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARCH_KIRKWOOD))
|
||||||
|
@ -592,7 +592,7 @@ static int atmel_mci_probe(struct udevice *dev)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
plat->mci = (struct atmel_mci *)devfdt_get_addr_ptr(dev);
|
plat->mci = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
atmel_mci_setup_cfg(dev);
|
atmel_mci_setup_cfg(dev);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ static int snps_dwmmc_ofdata_to_platdata(struct udevice *dev)
|
|||||||
u32 fifo_depth;
|
u32 fifo_depth;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
host->ioaddr = devfdt_get_addr_ptr(dev);
|
host->ioaddr = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If fifo-depth is unset don't set fifoth_val - we will try to
|
* If fifo-depth is unset don't set fifoth_val - we will try to
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <generic-phy.h>
|
#include <generic-phy.h>
|
||||||
|
|
||||||
|
#define DRIVER_DATA 0x12345678
|
||||||
|
|
||||||
struct sandbox_phy_priv {
|
struct sandbox_phy_priv {
|
||||||
bool initialized;
|
bool initialized;
|
||||||
bool on;
|
bool on;
|
||||||
@ -71,6 +73,14 @@ static int sandbox_phy_exit(struct phy *phy)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sandbox_phy_bind(struct udevice *dev)
|
||||||
|
{
|
||||||
|
if (dev_get_driver_data(dev) != DRIVER_DATA)
|
||||||
|
return -ENODATA;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int sandbox_phy_probe(struct udevice *dev)
|
static int sandbox_phy_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct sandbox_phy_priv *priv = dev_get_priv(dev);
|
struct sandbox_phy_priv *priv = dev_get_priv(dev);
|
||||||
@ -90,13 +100,19 @@ static struct phy_ops sandbox_phy_ops = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct udevice_id sandbox_phy_ids[] = {
|
static const struct udevice_id sandbox_phy_ids[] = {
|
||||||
{ .compatible = "sandbox,phy" },
|
{ .compatible = "sandbox,phy_no_driver_data",
|
||||||
|
},
|
||||||
|
|
||||||
|
{ .compatible = "sandbox,phy",
|
||||||
|
.data = DRIVER_DATA
|
||||||
|
},
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
U_BOOT_DRIVER(phy_sandbox) = {
|
U_BOOT_DRIVER(phy_sandbox) = {
|
||||||
.name = "phy_sandbox",
|
.name = "phy_sandbox",
|
||||||
.id = UCLASS_PHY,
|
.id = UCLASS_PHY,
|
||||||
|
.bind = sandbox_phy_bind,
|
||||||
.of_match = sandbox_phy_ids,
|
.of_match = sandbox_phy_ids,
|
||||||
.ops = &sandbox_phy_ops,
|
.ops = &sandbox_phy_ops,
|
||||||
.probe = sandbox_phy_probe,
|
.probe = sandbox_phy_probe,
|
||||||
|
@ -193,8 +193,8 @@ int mvebu_pinctl_probe(struct udevice *dev)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->base_reg = devfdt_get_addr_ptr(dev);
|
priv->base_reg = dev_read_addr_ptr(dev);
|
||||||
if (priv->base_reg == (void *)FDT_ADDR_T_NONE) {
|
if (!priv->base_reg) {
|
||||||
debug("%s: Failed to get base address\n", __func__);
|
debug("%s: Failed to get base address\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ static int socfpga_reset_probe(struct udevice *dev)
|
|||||||
u32 modrst_offset;
|
u32 modrst_offset;
|
||||||
void __iomem *membase;
|
void __iomem *membase;
|
||||||
|
|
||||||
membase = devfdt_get_addr_ptr(dev);
|
membase = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
modrst_offset = dev_read_u32_default(dev, "altr,modrst-offset", 0x10);
|
modrst_offset = dev_read_u32_default(dev, "altr,modrst-offset", 0x10);
|
||||||
data->modrst_base = membase + modrst_offset;
|
data->modrst_base = membase + modrst_offset;
|
||||||
|
@ -104,7 +104,7 @@ static int mvebu_serial_ofdata_to_platdata(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct mvebu_platdata *plat = dev_get_platdata(dev);
|
struct mvebu_platdata *plat = dev_get_platdata(dev);
|
||||||
|
|
||||||
plat->base = devfdt_get_addr_ptr(dev);
|
plat->base = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ static int uniphier_spi_ofdata_to_platdata(struct udevice *bus)
|
|||||||
const void *blob = gd->fdt_blob;
|
const void *blob = gd->fdt_blob;
|
||||||
int node = dev_of_offset(bus);
|
int node = dev_of_offset(bus);
|
||||||
|
|
||||||
plat->base = devfdt_get_addr_ptr(bus);
|
plat->base = dev_read_addr_ptr(bus);
|
||||||
|
|
||||||
plat->frequency =
|
plat->frequency =
|
||||||
fdtdec_get_int(blob, node, "spi-max-frequency", 12500000);
|
fdtdec_get_int(blob, node, "spi-max-frequency", 12500000);
|
||||||
|
@ -40,7 +40,7 @@ static int socfpga_sysreset_probe(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct socfpga_sysreset_data *data = dev_get_priv(dev);
|
struct socfpga_sysreset_data *data = dev_get_priv(dev);
|
||||||
|
|
||||||
data->rstmgr_base = devfdt_get_addr_ptr(dev);
|
data->rstmgr_base = dev_read_addr_ptr(dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ static int ast_timer_ofdata_to_platdata(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct ast_timer_priv *priv = dev_get_priv(dev);
|
struct ast_timer_priv *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
priv->regs = devfdt_get_addr_ptr(dev);
|
priv->regs = dev_read_addr_ptr(dev);
|
||||||
if (IS_ERR(priv->regs))
|
if (!priv->regs)
|
||||||
return PTR_ERR(priv->regs);
|
return -EINVAL;
|
||||||
|
|
||||||
priv->tmc = ast_get_timer_counter(priv->regs, AST_TICK_TIMER);
|
priv->tmc = ast_get_timer_counter(priv->regs, AST_TICK_TIMER);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ static int atmel_pit_ofdata_to_platdata(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct atmel_pit_platdata *plat = dev_get_platdata(dev);
|
struct atmel_pit_platdata *plat = dev_get_platdata(dev);
|
||||||
|
|
||||||
plat->regs = (struct atmel_pit_regs *)devfdt_get_addr_ptr(dev);
|
plat->regs = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ static int ehci_zynq_ofdata_to_platdata(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct zynq_ehci_priv *priv = dev_get_priv(dev);
|
struct zynq_ehci_priv *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
priv->ehci = (struct usb_ehci *)devfdt_get_addr_ptr(dev);
|
priv->ehci = dev_read_addr_ptr(dev);
|
||||||
if (!priv->ehci)
|
if (!priv->ehci)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ static int ast_wdt_ofdata_to_platdata(struct udevice *dev)
|
|||||||
{
|
{
|
||||||
struct ast_wdt_priv *priv = dev_get_priv(dev);
|
struct ast_wdt_priv *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
priv->regs = devfdt_get_addr_ptr(dev);
|
priv->regs = dev_read_addr_ptr(dev);
|
||||||
if (IS_ERR(priv->regs))
|
if (!priv->regs)
|
||||||
return PTR_ERR(priv->regs);
|
return -EINVAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -802,9 +802,7 @@ static inline fdt_addr_t dev_read_addr(const struct udevice *dev)
|
|||||||
|
|
||||||
static inline void *dev_read_addr_ptr(const struct udevice *dev)
|
static inline void *dev_read_addr_ptr(const struct udevice *dev)
|
||||||
{
|
{
|
||||||
void *addr = devfdt_get_addr_ptr(dev);
|
return devfdt_get_addr_ptr(dev);
|
||||||
|
|
||||||
return ((fdt_addr_t)(uintptr_t)addr == FDT_ADDR_T_NONE) ? NULL : addr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline fdt_addr_t dev_read_addr_pci(const struct udevice *dev)
|
static inline fdt_addr_t dev_read_addr_pci(const struct udevice *dev)
|
||||||
@ -878,14 +876,16 @@ static inline int dev_count_phandle_with_args(const struct udevice *dev,
|
|||||||
|
|
||||||
static inline int dev_read_addr_cells(const struct udevice *dev)
|
static inline int dev_read_addr_cells(const struct udevice *dev)
|
||||||
{
|
{
|
||||||
/* NOTE: this call should walk up the parent stack */
|
int parent = fdt_parent_offset(gd->fdt_blob, dev_of_offset(dev));
|
||||||
return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
|
|
||||||
|
return fdt_address_cells(gd->fdt_blob, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int dev_read_size_cells(const struct udevice *dev)
|
static inline int dev_read_size_cells(const struct udevice *dev)
|
||||||
{
|
{
|
||||||
/* NOTE: this call should walk up the parent stack */
|
int parent = fdt_parent_offset(gd->fdt_blob, dev_of_offset(dev));
|
||||||
return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
|
|
||||||
|
return fdt_size_cells(gd->fdt_blob, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int dev_read_simple_addr_cells(const struct udevice *dev)
|
static inline int dev_read_simple_addr_cells(const struct udevice *dev)
|
||||||
|
@ -47,7 +47,7 @@ static int dm_test_phy_base(struct unit_test_state *uts)
|
|||||||
ut_assert(phy2.dev != phy3.dev);
|
ut_assert(phy2.dev != phy3.dev);
|
||||||
|
|
||||||
/* Try to get a non-existing phy */
|
/* Try to get a non-existing phy */
|
||||||
ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PHY, 3, &dev));
|
ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PHY, 4, &dev));
|
||||||
ut_asserteq(-ENODATA, generic_phy_get_by_name(parent,
|
ut_asserteq(-ENODATA, generic_phy_get_by_name(parent,
|
||||||
"phy_not_existing", &phy1_method1));
|
"phy_not_existing", &phy1_method1));
|
||||||
|
|
||||||
|
@ -619,6 +619,24 @@ static int dm_test_fdt_translation(struct unit_test_state *uts)
|
|||||||
}
|
}
|
||||||
DM_TEST(dm_test_fdt_translation, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
|
DM_TEST(dm_test_fdt_translation, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
|
||||||
|
|
||||||
|
static int dm_test_fdt_get_addr_ptr_flat(struct unit_test_state *uts)
|
||||||
|
{
|
||||||
|
struct udevice *gpio, *dev;
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
/* Test for missing reg property */
|
||||||
|
ut_assertok(uclass_first_device_err(UCLASS_GPIO, &gpio));
|
||||||
|
ut_assertnull(devfdt_get_addr_ptr(gpio));
|
||||||
|
|
||||||
|
ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev));
|
||||||
|
ptr = devfdt_get_addr_ptr(dev);
|
||||||
|
ut_asserteq_ptr((void *)0x8000, ptr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DM_TEST(dm_test_fdt_get_addr_ptr_flat,
|
||||||
|
UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
|
||||||
|
|
||||||
static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts)
|
static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
|
@ -7,13 +7,16 @@ import re
|
|||||||
|
|
||||||
def in_tree(response, name, uclass, drv, depth, last_child):
|
def in_tree(response, name, uclass, drv, depth, last_child):
|
||||||
lines = [x.strip() for x in response.splitlines()]
|
lines = [x.strip() for x in response.splitlines()]
|
||||||
leaf = ' ' * 4 * depth;
|
leaf = ''
|
||||||
if not last_child:
|
if depth != 0:
|
||||||
leaf = leaf + r'\|'
|
leaf = ' ' + ' ' * (depth - 1) ;
|
||||||
else:
|
if not last_child:
|
||||||
leaf = leaf + '`'
|
leaf = leaf + r'\|'
|
||||||
|
else:
|
||||||
|
leaf = leaf + '`'
|
||||||
|
|
||||||
leaf = leaf + '-- ' + name
|
leaf = leaf + '-- ' + name
|
||||||
line = (r' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$'
|
line = (r' *{:10.10} [0-9]* \[ [ +] \] {:20.20} [` |]{}$'
|
||||||
.format(uclass, drv, leaf))
|
.format(uclass, drv, leaf))
|
||||||
prog = re.compile(line)
|
prog = re.compile(line)
|
||||||
for l in lines:
|
for l in lines:
|
||||||
@ -25,9 +28,6 @@ def in_tree(response, name, uclass, drv, depth, last_child):
|
|||||||
@pytest.mark.buildconfigspec('cmd_bind')
|
@pytest.mark.buildconfigspec('cmd_bind')
|
||||||
def test_bind_unbind_with_node(u_boot_console):
|
def test_bind_unbind_with_node(u_boot_console):
|
||||||
|
|
||||||
#bind /bind-test. Device should come up as well as its children
|
|
||||||
response = u_boot_console.run_command('bind /bind-test simple_bus')
|
|
||||||
assert response == ''
|
|
||||||
tree = u_boot_console.run_command('dm tree')
|
tree = u_boot_console.run_command('dm tree')
|
||||||
assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
|
assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
|
||||||
assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False)
|
assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
import glob
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from patman import tools
|
from patman import tools
|
||||||
@ -51,6 +52,18 @@ def _FindBinmanNode(dtb):
|
|||||||
return node
|
return node
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def GetEntryModules(include_testing=True):
|
||||||
|
"""Get a set of entry class implementations
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Set of paths to entry class filenames
|
||||||
|
"""
|
||||||
|
our_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
|
||||||
|
return set([os.path.splitext(os.path.basename(item))[0]
|
||||||
|
for item in glob_list
|
||||||
|
if include_testing or '_testing' not in item])
|
||||||
|
|
||||||
def WriteEntryDocs(modules, test_missing=None):
|
def WriteEntryDocs(modules, test_missing=None):
|
||||||
"""Write out documentation for all entries
|
"""Write out documentation for all entries
|
||||||
|
|
||||||
@ -110,7 +123,7 @@ def ReadEntry(image_fname, entry_path, decomp=True):
|
|||||||
data extracted from the entry
|
data extracted from the entry
|
||||||
"""
|
"""
|
||||||
global Image
|
global Image
|
||||||
from image import Image
|
from binman.image import Image
|
||||||
|
|
||||||
image = Image.FromFile(image_fname)
|
image = Image.FromFile(image_fname)
|
||||||
entry = image.FindEntryPath(entry_path)
|
entry = image.FindEntryPath(entry_path)
|
||||||
@ -483,7 +496,7 @@ def Binman(args):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# Put these here so that we can import this module without libfdt
|
# Put these here so that we can import this module without libfdt
|
||||||
from image import Image
|
from binman.image import Image
|
||||||
from binman import state
|
from binman import state
|
||||||
|
|
||||||
if args.cmd in ['ls', 'extract', 'replace']:
|
if args.cmd in ['ls', 'extract', 'replace']:
|
||||||
|
@ -24,13 +24,12 @@ from binman import control
|
|||||||
from binman import elf
|
from binman import elf
|
||||||
from binman import elf_test
|
from binman import elf_test
|
||||||
from binman import fmap_util
|
from binman import fmap_util
|
||||||
from binman import main
|
|
||||||
from binman import state
|
from binman import state
|
||||||
from dtoc import fdt
|
from dtoc import fdt
|
||||||
from dtoc import fdt_util
|
from dtoc import fdt_util
|
||||||
from binman.etype import fdtmap
|
from binman.etype import fdtmap
|
||||||
from binman.etype import image_header
|
from binman.etype import image_header
|
||||||
from image import Image
|
from binman.image import Image
|
||||||
from patman import command
|
from patman import command
|
||||||
from patman import test_util
|
from patman import test_util
|
||||||
from patman import tools
|
from patman import tools
|
||||||
@ -1440,14 +1439,14 @@ class TestFunctional(unittest.TestCase):
|
|||||||
def testEntryDocs(self):
|
def testEntryDocs(self):
|
||||||
"""Test for creation of entry documentation"""
|
"""Test for creation of entry documentation"""
|
||||||
with test_util.capture_sys_output() as (stdout, stderr):
|
with test_util.capture_sys_output() as (stdout, stderr):
|
||||||
control.WriteEntryDocs(main.GetEntryModules())
|
control.WriteEntryDocs(control.GetEntryModules())
|
||||||
self.assertTrue(len(stdout.getvalue()) > 0)
|
self.assertTrue(len(stdout.getvalue()) > 0)
|
||||||
|
|
||||||
def testEntryDocsMissing(self):
|
def testEntryDocsMissing(self):
|
||||||
"""Test handling of missing entry documentation"""
|
"""Test handling of missing entry documentation"""
|
||||||
with self.assertRaises(ValueError) as e:
|
with self.assertRaises(ValueError) as e:
|
||||||
with test_util.capture_sys_output() as (stdout, stderr):
|
with test_util.capture_sys_output() as (stdout, stderr):
|
||||||
control.WriteEntryDocs(main.GetEntryModules(), 'u_boot')
|
control.WriteEntryDocs(control.GetEntryModules(), 'u_boot')
|
||||||
self.assertIn('Documentation is missing for modules: u_boot',
|
self.assertIn('Documentation is missing for modules: u_boot',
|
||||||
str(e.exception))
|
str(e.exception))
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from image import Image
|
from binman.image import Image
|
||||||
from patman.test_util import capture_sys_output
|
from patman.test_util import capture_sys_output
|
||||||
|
|
||||||
class TestImage(unittest.TestCase):
|
class TestImage(unittest.TestCase):
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
"""See README for more information"""
|
"""See README for more information"""
|
||||||
|
|
||||||
from distutils.sysconfig import get_python_lib
|
from distutils.sysconfig import get_python_lib
|
||||||
import glob
|
|
||||||
import os
|
import os
|
||||||
import site
|
import site
|
||||||
import sys
|
import sys
|
||||||
@ -62,7 +61,6 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
|
|||||||
from binman import fdt_test
|
from binman import fdt_test
|
||||||
from binman import ftest
|
from binman import ftest
|
||||||
from binman import image_test
|
from binman import image_test
|
||||||
from binman import test
|
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
result = unittest.TestResult()
|
result = unittest.TestResult()
|
||||||
@ -78,20 +76,9 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
|
|||||||
|
|
||||||
return test_util.ReportResult('binman', test_name, result)
|
return test_util.ReportResult('binman', test_name, result)
|
||||||
|
|
||||||
def GetEntryModules(include_testing=True):
|
|
||||||
"""Get a set of entry class implementations
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Set of paths to entry class filenames
|
|
||||||
"""
|
|
||||||
glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
|
|
||||||
return set([os.path.splitext(os.path.basename(item))[0]
|
|
||||||
for item in glob_list
|
|
||||||
if include_testing or '_testing' not in item])
|
|
||||||
|
|
||||||
def RunTestCoverage(toolpath):
|
def RunTestCoverage(toolpath):
|
||||||
"""Run the tests and check that we get 100% coverage"""
|
"""Run the tests and check that we get 100% coverage"""
|
||||||
glob_list = GetEntryModules(False)
|
glob_list = control.GetEntryModules(False)
|
||||||
all_set = set([os.path.splitext(os.path.basename(item))[0]
|
all_set = set([os.path.splitext(os.path.basename(item))[0]
|
||||||
for item in glob_list if '_testing' not in item])
|
for item in glob_list if '_testing' not in item])
|
||||||
extra_args = ''
|
extra_args = ''
|
||||||
@ -127,7 +114,7 @@ def RunBinman(args):
|
|||||||
args.toolpath)
|
args.toolpath)
|
||||||
|
|
||||||
elif args.cmd == 'entry-docs':
|
elif args.cmd == 'entry-docs':
|
||||||
control.WriteEntryDocs(GetEntryModules())
|
control.WriteEntryDocs(control.GetEntryModules())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
12
tools/binman/setup.py
Normal file
12
tools/binman/setup.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
|
from distutils.core import setup
|
||||||
|
setup(name='binman',
|
||||||
|
version='1.0',
|
||||||
|
license='GPL-2.0+',
|
||||||
|
scripts=['binman'],
|
||||||
|
packages=['binman', 'binman.etype'],
|
||||||
|
package_dir={'binman': ''},
|
||||||
|
package_data={'binman': ['README', 'README.entries']},
|
||||||
|
classifiers=['Environment :: Console',
|
||||||
|
'Topic :: Software Development :: Embedded Systems'])
|
12
tools/dtoc/setup.py
Normal file
12
tools/dtoc/setup.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
|
from distutils.core import setup
|
||||||
|
setup(name='dtoc',
|
||||||
|
version='1.0',
|
||||||
|
license='GPL-2.0+',
|
||||||
|
scripts=['dtoc'],
|
||||||
|
packages=['dtoc'],
|
||||||
|
package_dir={'dtoc': ''},
|
||||||
|
package_data={'dtoc': ['README']},
|
||||||
|
classifiers=['Environment :: Console',
|
||||||
|
'Topic :: Software Development :: Embedded Systems'])
|
Loading…
x
Reference in New Issue
Block a user