./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
./tools/buildman/buildman -t
./tools/dtoc/dtoc -t
- ./tools/patman/patman test
+ ./tools/patman/patman --test
make O=${UBOOT_TRAVIS_BUILD_DIR} testconfig
EOF
cat build.sh
*.orig
*~
\#*#
-
-# Python cache
-__pycache__
./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
./tools/buildman/buildman -t;
./tools/dtoc/dtoc -t;
- ./tools/patman/patman test;
+ ./tools/patman/patman --test;
make testconfig
Run tests for Nokia RX-51 (aka N900):
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test &&
- ./tools/patman/patman test &&
+ ./tools/patman/patman --test &&
./tools/buildman/buildman -t &&
./tools/dtoc/dtoc -t &&
make testconfig;
clocks = <&k3_clks 115 1>;
power-domains = <&k3_pds 115 TI_SCI_PD_EXCLUSIVE>;
};
-
- chipid: chipid@43000014 {
- compatible = "ti,am654-chipid";
- reg = <0x43000014 0x4>;
- };
};
u-boot,dm-spl;
};
};
-
-&chipid {
- u-boot,dm-spl;
-};
&mcu_fss0_ospi1_pins_default {
u-boot,dm-spl;
};
-
-&chipid {
- u-boot,dm-spl;
-};
ti,cpts-periodic-outputs = <2>;
};
};
-
- chipid: chipid@43000014 {
- compatible = "ti,am654-chipid";
- reg = <0x0 0x43000014 0x0 0x4>;
- };
};
#include <fs.h>
#include <env.h>
#include <elf.h>
-#include <soc.h>
struct ti_sci_handle *get_ti_sci_handle(void)
{
#if defined(CONFIG_DISPLAY_CPUINFO)
int print_cpuinfo(void)
{
- struct udevice *soc;
- char name[64];
- int ret;
-
- printf("SoC: ");
+ u32 soc, rev;
+ char *name;
- ret = soc_get(&soc);
- if (ret) {
- printf("UNKNOWN\n");
- return 0;
- }
+ soc = (readl(CTRLMMR_WKUP_JTAG_ID) &
+ JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
+ rev = (readl(CTRLMMR_WKUP_JTAG_ID) &
+ JTAG_ID_VARIANT_MASK) >> JTAG_ID_VARIANT_SHIFT;
- ret = soc_get_family(soc, name, 64);
- if (!ret) {
- printf("%s ", name);
- }
+ printf("SoC: ");
+ switch (soc) {
+ case AM65X:
+ name = "AM65x";
+ break;
+ case J721E:
+ name = "J721E";
+ break;
+ default:
+ name = "Unknown Silicon";
+ };
- ret = soc_get_revision(soc, name, 64);
- if (!ret) {
- printf("%s\n", name);
- }
+ printf("%s SR ", name);
+ switch (rev) {
+ case REV_PG1_0:
+ name = "1.0";
+ break;
+ case REV_PG2_0:
+ name = "2.0";
+ break;
+ default:
+ name = "Unknown Revision";
+ };
+ printf("%s\n", name);
return 0;
}
#include <asm/armv7_mpu.h>
+#define AM65X 0xbb5a
+#define J721E 0xbb64
+
+#define REV_PG1_0 0
+#define REV_PG2_0 1
+
struct fwl_data {
const char *name;
u16 fwl_id;
#endif
/* Assuming these addresses and definitions stay common across K3 devices */
+#define CTRLMMR_WKUP_JTAG_ID 0x43000014
#define JTAG_ID_VARIANT_SHIFT 28
#define JTAG_ID_VARIANT_MASK (0xf << 28)
#define JTAG_ID_PARTNO_SHIFT 12
{
struct msm_clk_priv *priv = dev_get_priv(dev);
- priv->base = dev_read_addr(dev);
+ priv->base = devfdt_get_addr(dev);
if (priv->base == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct msm_pinctrl_priv *priv = dev_get_priv(dev);
- priv->base = dev_read_addr(dev);
+ priv->base = devfdt_get_addr(dev);
priv->data = (struct msm_pinctrl_data *)dev->driver_data;
return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0;
return 0;
}
-static int altera_nios2_get_desc(const struct udevice *dev, char *buf,
- int size)
+static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size)
{
const char *cpu_name = "Nios-II";
return 0;
}
-static int altera_nios2_get_info(const struct udevice *dev,
- struct cpu_info *info)
+static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info)
{
info->cpu_freq = gd->cpu_clk;
info->features = (1 << CPU_FEAT_L1_CACHE) |
return 0;
}
-static int altera_nios2_get_count(const struct udevice *dev)
+static int altera_nios2_get_count(struct udevice *dev)
{
return 1;
}
};
};
- chipid: chipid {
- compatible = "sandbox,soc";
- };
-
i2s: i2s {
compatible = "sandbox,i2s";
#sound-dai-cells = <1>;
#include <asm/cpu_common.h>
#include <asm/cpu_x86.h>
-static int apl_get_info(const struct udevice *dev, struct cpu_info *info)
+static int apl_get_info(struct udevice *dev, struct cpu_info *info)
{
return cpu_intel_get_info(info, INTEL_BCLK_MHZ);
}
return bclk * ((platform_info.lo >> 8) & 0xff);
}
-static int baytrail_get_info(const struct udevice *dev, struct cpu_info *info)
+static int baytrail_get_info(struct udevice *dev, struct cpu_info *info)
{
info->cpu_freq = tsc_freq();
info->features = 1 << CPU_FEAT_L1_CACHE | 1 << CPU_FEAT_MMU;
return 0;
}
-static int baytrail_get_count(const struct udevice *dev)
+static int baytrail_get_count(struct udevice *dev)
{
int ecx = 0;
}
}
-static int broadwell_get_info(const struct udevice *dev, struct cpu_info *info)
+static int broadwell_get_info(struct udevice *dev, struct cpu_info *info)
{
return cpu_intel_get_info(info, INTEL_BCLK_MHZ);
}
-static int broadwell_get_count(const struct udevice *dev)
+static int broadwell_get_count(struct udevice *dev)
{
return 4;
}
return 0;
}
-int cpu_x86_get_vendor(const struct udevice *dev, char *buf, int size)
+int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size)
{
const char *vendor = cpu_vendor_name(gd->arch.x86_vendor);
return 0;
}
-int cpu_x86_get_desc(const struct udevice *dev, char *buf, int size)
+int cpu_x86_get_desc(struct udevice *dev, char *buf, int size)
{
char *ptr;
return 0;
}
-int cpu_x86_get_count(const struct udevice *dev)
+int cpu_x86_get_count(struct udevice *dev)
{
int node, cpu;
int num = 0;
return 0;
}
-static int model_206ax_get_info(const struct udevice *dev,
- struct cpu_info *info)
+static int model_206ax_get_info(struct udevice *dev, struct cpu_info *info)
{
return cpu_intel_get_info(info, INTEL_BCLK_MHZ);
return 0;
}
-static int model_206ax_get_count(const struct udevice *dev)
+static int model_206ax_get_count(struct udevice *dev)
{
return 4;
}
#include <qfw.h>
#include <asm/cpu.h>
-int cpu_qemu_get_desc(const struct udevice *dev, char *buf, int size)
+int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size)
{
if (size < CPU_MAX_NAME_LEN)
return -ENOSPC;
return 0;
}
-static int cpu_qemu_get_count(const struct udevice *dev)
+static int cpu_qemu_get_count(struct udevice *dev)
{
return qemu_fwcfg_online_cpus();
}
* @size: Size of string space
* @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
-int cpu_x86_get_desc(const struct udevice *dev, char *buf, int size);
+int cpu_x86_get_desc(struct udevice *dev, char *buf, int size);
/**
* cpu_x86_get_count() - Get the number of cores for an x86 CPU
* @return: Number of cores if successful,
* -ENOENT if not "/cpus" entry is found in the device tree
*/
-int cpu_x86_get_count(const struct udevice *dev);
+int cpu_x86_get_count(struct udevice *dev);
/**
* cpu_x86_get_vendor() - Get a vendor string for an x86 CPU
* @size: Size of string space
* @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
-int cpu_x86_get_vendor(const struct udevice *dev, char *buf, int size);
+int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size);
#endif /* _ASM_CPU_X86_H */
int dram_init(void)
{
- return fdtdec_setup_mem_size_base();
+ return fdtdec_setup_mem_size_base_fdt(gd->fdt_blob);
}
int dram_init_banksize(void)
{
- fdtdec_setup_memory_banksize();
+ fdtdec_setup_memory_banksize_fdt(gd->fdt_blob);
return 0;
}
stop_at = offset;
prop = fdt_get_property_by_offset(fdt, offset, NULL);
str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
- if (!str)
- return -FDT_ERR_BADSTRUCTURE;
if (str_in_list(str, exc_prop, exc_prop_count))
include = 0;
break;
return 0;
}
-static int fdt_node_set_part_info(void *blob, int parent_offset,
- struct mtd_device *dev)
+int fdt_node_set_part_info(void *blob, int parent_offset,
+ struct mtd_device *dev)
{
struct list_head *pentry;
struct part_info *part;
struct mtd_device *dev;
int i, idx;
int noff;
- bool inited = false;
+
+ if (mtdparts_init() != 0)
+ return;
for (i = 0; i < node_info_size; i++) {
idx = 0;
- noff = -1;
-
- while ((noff = fdt_node_offset_by_compatible(blob, noff,
- node_info[i].compat)) >= 0) {
- const char *prop;
-
- prop = fdt_getprop(blob, noff, "status", NULL);
- if (prop && !strcmp(prop, "disabled"))
- continue;
-
+ noff = fdt_node_offset_by_compatible(blob, -1,
+ node_info[i].compat);
+ while (noff != -FDT_ERR_NOTFOUND) {
debug("%s: %s, mtd dev type %d\n",
fdt_get_name(blob, noff, 0),
node_info[i].compat, node_info[i].type);
-
- if (!inited) {
- if (mtdparts_init() != 0)
- return;
- inited = true;
- }
-
dev = device_find(node_info[i].type, idx++);
if (dev) {
if (fdt_node_set_part_info(blob, noff, dev))
return; /* return on error */
}
+
+ /* Jump to next flash node */
+ noff = fdt_node_offset_by_compatible(blob, noff,
+ node_info[i].compat);
}
}
}
CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_FAT_WRITE=y
CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_SPL_TIMER=y
CONFIG_OMAP_TIMER=y
CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_FAT_WRITE=y
CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_SPL_TIMER=y
CONFIG_OMAP_TIMER=y
CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_TI_J721E_UFS=y
CONFIG_FAT_WRITE=y
CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_FS_EXT4=y
CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_TI_J721E_UFS=y
CONFIG_FAT_WRITE=y
CONFIG_OF_LIBFDT_OVERLAY=y
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_OMAP_TIMER=y
CONFIG_FS_EXT4=y
CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
-CONFIG_SOC_DEVICE=y
-CONFIG_SOC_DEVICE_TI_K3=y
CONFIG_DM_MAILBOX=y
CONFIG_SANDBOX_MBOX=y
CONFIG_MISC=y
-CONFIG_SOC_DEVICE=y
CONFIG_CROS_EC=y
CONFIG_CROS_EC_I2C=y
CONFIG_CROS_EC_LPC=y
CONFIG_DM_MAILBOX=y
CONFIG_SANDBOX_MBOX=y
CONFIG_MISC=y
-CONFIG_SOC_DEVICE=y
CONFIG_CROS_EC=y
CONFIG_CROS_EC_I2C=y
CONFIG_CROS_EC_LPC=y
CONFIG_DM_MAILBOX=y
CONFIG_SANDBOX_MBOX=y
CONFIG_MISC=y
-CONFIG_SOC_DEVICE=y
CONFIG_CROS_EC=y
CONFIG_CROS_EC_I2C=y
CONFIG_CROS_EC_LPC=y
CONFIG_DM_MAILBOX=y
CONFIG_SANDBOX_MBOX=y
CONFIG_MISC=y
-CONFIG_SOC_DEVICE=y
CONFIG_CROS_EC=y
CONFIG_CROS_EC_I2C=y
CONFIG_CROS_EC_LPC=y
pmic-framework
remoteproc-framework
serial-howto
- soc-framework
spi-howto
usb-info
+++ /dev/null
-.. SPDX-License-Identifier: GPL-2.0+
-.. (C) Copyright 2020
-.. Texas Instruments Incorporated - http://www.ti.com/
-
-SOC ID Framework
-================
-
-Introduction
-------------
-
-The driver-model SOC ID framework is able to provide identification
-information about a specific SoC in use at runtime, and also provide matching
-from a set of identification information from an array. This can be useful for
-enabling small quirks in drivers that exist between SoC variants that are
-impractical to implement using device tree flags. It is based on UCLASS_SOC.
-
-UCLASS_SOC:
- - drivers/soc/soc-uclass.c
- - include/soc.h
-
-Configuration:
- - CONFIG_SOC_DEVICE is selected by drivers as needed.
-
-Implementing a UCLASS_SOC provider
-----------------------------------
-
-The purpose of this framework is to allow UCLASS_SOC provider drivers to supply
-identification information about the SoC in use at runtime. The framework
-allows drivers to define soc_ops that return identification strings. All
-soc_ops need not be defined and can be left as NULL, in which case the
-framework will return -ENOSYS and not consider the value when doing an
-soc_device_match.
-
-It is left to the driver implementor to decide how the information returned is
-determined, but in general the same SOC should always return the same set of
-identifying information. Information returned must be in the form of a NULL
-terminated string.
-
-See include/soc.h for documentation of the available soc_ops and the intended
-meaning of the values that can be returned. See drivers/soc/soc_sandbox.c for
-an example UCLASS_SOC provider driver.
-
-Using a UCLASS_SOC driver
--------------------------
-
-The framework provides the ability to retrieve and use the identification
-strings directly. It also has the ability to return a match from a list of
-different sets of SoC data using soc_device_match.
-
-An array of 'struct soc_attr' can be defined, each containing ID information
-for a specific SoC, and when passed to soc_device_match, the identifier values
-for each entry in the list will be compared against the values provided by the
-UCLASS_SOC driver that is in use. The first entry in the list that matches all
-non-null values will be returned by soc_device_match.
-
-An example of various uses of the framework can be found at test/dm/soc.c.
-
-Describing the device using device tree
----------------------------------------
-
-.. code-block:: none
-
- chipid: chipid {
- compatible = "sandbox,soc";
- };
-
-All that is required in a DT node is a compatible for a corresponding
-UCLASS_SOC driver.
must be verified for the image to boot. Without this option, the verification
will be optional (useful for testing but not for release).
-.TP
-.BI "\-t
-Update the timestamp in the FIT.
-
-Normally the FIT timestamp is created the first time mkimage is run on a FIT,
-when converting the source .its to the binary .fit file. This corresponds to
-using the -f flag. But if the original input to mkimage is a binary file
-(already compiled) then the timestamp is assumed to have been set previously.
-
.SH EXAMPLES
List image information:
struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
struct exynos_adc_priv *priv = dev_get_priv(dev);
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (struct exynos_adc_v2 *)devfdt_get_addr(dev);
if (priv->regs == (struct exynos_adc_v2 *)FDT_ADDR_T_NONE) {
pr_err("Dev: %s - can't get address!", dev->name);
return -ENODATA;
struct dwc_ahci_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
- priv->base = map_physmem(dev_read_addr(dev), sizeof(void *),
+ priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
MAP_NOCACHE);
addr = devfdt_get_addr_index(dev, 1);
struct socfpga_clk_platdata *plat = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
plat->regs = (void __iomem *)addr;
socfpga_a10_handoff_workaround(dev);
if (!fdt_node_check_compatible(fdt, offset, "altr,clk-mgr")) {
- plat->regs = dev_read_addr(dev);
+ plat->regs = devfdt_get_addr(dev);
} else {
pdev = dev_get_parent(dev);
if (!pdev)
fdt_addr_t base;
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
if (!priv)
return -EINVAL;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
u32 cpg_mode;
int ret;
- priv->base = dev_read_addr_ptr(dev);
+ priv->base = (struct gen2_base *)devfdt_get_addr(dev);
if (!priv->base)
return -EINVAL;
u32 cpg_mode;
int ret;
- priv->base = dev_read_addr_ptr(dev);
+ priv->base = (struct gen3_base *)devfdt_get_addr(dev);
if (!priv->base)
return -EINVAL;
struct uniphier_clk_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev->parent);
+ addr = devfdt_get_addr(dev->parent);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
* This is just a 'requested' sequence, and will be
* resolved (and ->seq updated) when the device is probed.
*/
- if (CONFIG_IS_ENABLED(OF_CONTROL) &&
- !CONFIG_IS_ENABLED(OF_PLATDATA)) {
+ if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
if (uc->uc_drv->name && ofnode_valid(node))
dev_read_alias_seq(dev, &dev->req_seq);
#if CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
};
/* Generic CPU Ops */
-static int bmips_cpu_get_desc(const struct udevice *dev, char *buf, int size)
+static int bmips_cpu_get_desc(struct udevice *dev, char *buf, int size)
{
struct bmips_cpu_priv *priv = dev_get_priv(dev);
const struct bmips_cpu_hw *hw = priv->hw;
return hw->get_cpu_desc(priv, buf, size);
}
-static int bmips_cpu_get_info(const struct udevice *dev, struct cpu_info *info)
+static int bmips_cpu_get_info(struct udevice *dev, struct cpu_info *info)
{
struct bmips_cpu_priv *priv = dev_get_priv(dev);
const struct bmips_cpu_hw *hw = priv->hw;
return 0;
}
-static int bmips_cpu_get_count(const struct udevice *dev)
+static int bmips_cpu_get_count(struct udevice *dev)
{
struct bmips_cpu_priv *priv = dev_get_priv(dev);
const struct bmips_cpu_hw *hw = priv->hw;
return hw->get_cpu_count(priv);
}
-static int bmips_cpu_get_vendor(const struct udevice *dev, char *buf, int size)
+static int bmips_cpu_get_vendor(struct udevice *dev, char *buf, int size)
{
snprintf(buf, size, "Broadcom");
return cpu;
}
-int cpu_get_desc(const struct udevice *dev, char *buf, int size)
+int cpu_get_desc(struct udevice *dev, char *buf, int size)
{
struct cpu_ops *ops = cpu_get_ops(dev);
return ops->get_desc(dev, buf, size);
}
-int cpu_get_info(const struct udevice *dev, struct cpu_info *info)
+int cpu_get_info(struct udevice *dev, struct cpu_info *info)
{
struct cpu_ops *ops = cpu_get_ops(dev);
return ops->get_info(dev, info);
}
-int cpu_get_count(const struct udevice *dev)
+int cpu_get_count(struct udevice *dev)
{
struct cpu_ops *ops = cpu_get_ops(dev);
return ops->get_count(dev);
}
-int cpu_get_vendor(const struct udevice *dev, char *buf, int size)
+int cpu_get_vendor(struct udevice *dev, char *buf, int size)
{
struct cpu_ops *ops = cpu_get_ops(dev);
#include <dm.h>
#include <cpu.h>
-int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size)
+int cpu_sandbox_get_desc(struct udevice *dev, char *buf, int size)
{
snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1");
return 0;
}
-int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info)
+int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info)
{
info->cpu_freq = 42 * 42 * 42 * 42 * 42;
info->features = 0x42424242;
return 0;
}
-int cpu_sandbox_get_count(const struct udevice *dev)
+int cpu_sandbox_get_count(struct udevice *dev)
{
return 42;
}
-int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, int size)
+int cpu_sandbox_get_vendor(struct udevice *dev, char *buf, int size)
{
snprintf(buf, size, "Languid Example Garbage Inc.");
}
#endif
-int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size)
+int cpu_imx_get_desc(struct udevice *dev, char *buf, int size)
{
struct cpu_imx_platdata *plat = dev_get_platdata(dev);
int ret, temp;
return 0;
}
-static int cpu_imx_get_info(const struct udevice *dev, struct cpu_info *info)
+static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info)
{
struct cpu_imx_platdata *plat = dev_get_platdata(dev);
return 0;
}
-static int cpu_imx_get_count(const struct udevice *dev)
+static int cpu_imx_get_count(struct udevice *dev)
{
ofnode node;
int num = 0;
return num;
}
-static int cpu_imx_get_vendor(const struct udevice *dev, char *buf, int size)
+static int cpu_imx_get_vendor(struct udevice *dev, char *buf, int size)
{
snprintf(buf, size, "NXP");
return 0;
* determine_type() - Determine CPU family of MPC83xx device
* @dev: CPU device from which to read CPU family from
*/
-static inline void determine_family(const struct udevice *dev)
+static inline void determine_family(struct udevice *dev)
{
struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
/* Upper 12 bits of PARTID field (bits 0-23 in SPRIDR) */
* determine_type() - Determine CPU type of MPC83xx device
* @dev: CPU device from which to read CPU type from
*/
-static inline void determine_type(const struct udevice *dev)
+static inline void determine_type(struct udevice *dev)
{
struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
/* Upper 16 bits of PVR (Processor Version Register) */
* determine_e300_type() - Determine e300 core type of MPC83xx device
* @dev: CPU device from which to read e300 core type from
*/
-static inline void determine_e300_type(const struct udevice *dev)
+static inline void determine_e300_type(struct udevice *dev)
{
struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
/* Upper 16 bits of PVR (Processor Version Register) */
* determine_revid() - Determine revision ID of CPU device
* @dev: CPU device from which to read revision ID
*/
-static inline void determine_revid(const struct udevice *dev)
+static inline void determine_revid(struct udevice *dev)
{
struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
u32 REVID_MAJOR_MASK;
* determine_cpu_data() - Determine CPU information from hardware
* @dev: CPU device from which to read information
*/
-static void determine_cpu_data(const struct udevice *dev)
+static void determine_cpu_data(struct udevice *dev)
{
struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
const u32 E_FLAG_MASK = 0x00010000;
priv->is_e_processor = !bitfield_extract_by_mask(spridr, E_FLAG_MASK);
}
-static int mpc83xx_cpu_get_desc(const struct udevice *dev, char *buf, int size)
+static int mpc83xx_cpu_get_desc(struct udevice *dev, char *buf, int size)
{
struct mpc83xx_cpu_priv *priv = dev_get_priv(dev);
struct clk core_clk;
char csb_freq[32];
int ret;
- ret = clk_get_by_index((struct udevice *)dev, 0, &core_clk);
+ ret = clk_get_by_index(dev, 0, &core_clk);
if (ret) {
debug("%s: Failed to get core clock (err = %d)\n",
dev->name, ret);
return ret;
}
- ret = clk_get_by_index((struct udevice *)dev, 1, &csb_clk);
+ ret = clk_get_by_index(dev, 1, &csb_clk);
if (ret) {
debug("%s: Failed to get CSB clock (err = %d)\n",
dev->name, ret);
return 0;
}
-static int mpc83xx_cpu_get_info(const struct udevice *dev,
- struct cpu_info *info)
+static int mpc83xx_cpu_get_info(struct udevice *dev, struct cpu_info *info)
{
struct clk clock;
int ret;
ulong freq;
- ret = clk_get_by_index((struct udevice *)dev, 0, &clock);
+ ret = clk_get_by_index(dev, 0, &clock);
if (ret) {
debug("%s: Failed to get core clock (err = %d)\n",
dev->name, ret);
return 0;
}
-static int mpc83xx_cpu_get_count(const struct udevice *dev)
+static int mpc83xx_cpu_get_count(struct udevice *dev)
{
/* We have one e300cX core */
return 1;
}
-static int mpc83xx_cpu_get_vendor(const struct udevice *dev, char *buf,
- int size)
+static int mpc83xx_cpu_get_vendor(struct udevice *dev, char *buf, int size)
{
snprintf(buf, size, "NXP");
DECLARE_GLOBAL_DATA_PTR;
-static int riscv_cpu_get_desc(const struct udevice *dev, char *buf, int size)
+static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)
{
const char *isa;
return 0;
}
-static int riscv_cpu_get_info(const struct udevice *dev, struct cpu_info *info)
+static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info)
{
int ret;
struct clk clk;
u32 d_cache_size;
/* First try getting the frequency from the assigned clock */
- ret = clk_get_by_index((struct udevice *)dev, 0, &clk);
+ ret = clk_get_by_index(dev, 0, &clk);
if (!ret) {
ret = clk_get_rate(&clk);
if (!IS_ERR_VALUE(ret))
return 0;
}
-static int riscv_cpu_get_count(const struct udevice *dev)
+static int riscv_cpu_get_count(struct udevice *dev)
{
ofnode node;
int num = 0;
{
struct ti_edma3_priv *priv = dev_get_priv(dev);
- priv->base = dev_read_addr(dev);
+ priv->base = devfdt_get_addr(dev);
return 0;
}
{
struct altera_pio_platdata *plat = dev_get_platdata(dev);
- plat->regs = map_physmem(dev_read_addr(dev),
+ plat->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct altera_pio_regs),
MAP_NOCACHE);
plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
clk_free(&clk);
- addr_base = dev_read_addr(dev);
+ addr_base = devfdt_get_addr(dev);
if (addr_base == FDT_ADDR_T_NONE)
return -EINVAL;
struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct davinci_gpio_platdata *plat = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
int node = dev_of_offset(dev);
int ret;
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (void __iomem *)devfdt_get_addr(dev);
uc_priv->bank_name = dev->name;
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, node, "gpio-ranges",
uc_priv->bank_name = dev->name;
dev = dev_get_parent(dev);
- addr_base = dev_read_addr(dev);
+ addr_base = devfdt_get_addr(dev);
if (addr_base == FDT_ADDR_T_NONE)
return -EINVAL;
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct msm_gpio_bank *priv = dev_get_priv(dev);
- priv->base = dev_read_addr(dev);
+ priv->base = devfdt_get_addr(dev);
return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0;
}
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct mvebu_gpio_priv *priv = dev_get_priv(dev);
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (struct mvebu_gpio_regs *)devfdt_get_addr(dev);
uc_priv->gpio_count = MVEBU_GPIOS_PER_BANK;
priv->name[0] = 'A' + dev->req_seq;
uc_priv->bank_name = priv->name;
fdt_addr_t addr;
struct mxc_gpio_plat *plat = dev_get_platdata(dev);
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
int node = dev_of_offset(dev);
int ret;
- plat->bank = dev_read_addr(dev);
+ plat->bank = devfdt_get_addr(dev);
if (plat->bank == FDT_ADDR_T_NONE) {
printf("%s: No 'reg' property defined!\n", __func__);
return -EINVAL;
if (plat)
return 0;
- base_addr = dev_read_addr(dev);
+ base_addr = devfdt_get_addr(dev);
if (base_addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct omap_gpio_platdata *plat = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct pm8916_gpio_bank *priv = dev_get_priv(dev);
int reg;
- priv->pid = dev_read_addr(dev);
+ priv->pid = devfdt_get_addr(dev);
if (priv->pid == FDT_ADDR_T_NONE)
return log_msg_ret("bad address", -EINVAL);
if (plat)
return 0;
- base = dev_read_addr_ptr(parent);
+ base = (struct s5p_gpio_bank *)devfdt_get_addr(parent);
for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base;
node > 0;
node = fdt_next_subnode(blob, node), bank++) {
dev_set_of_offset(dev, node);
- reg = dev_read_addr(dev);
+ reg = devfdt_get_addr(dev);
if (reg != FDT_ADDR_T_NONE)
bank = (struct s5p_gpio_bank *)((ulong)base + reg);
struct sifive_gpio_platdata *plat = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
if (plat)
return 0;
- ctlr = dev_read_addr_ptr(parent);
+ ctlr = (struct sunxi_gpio_reg *)devfdt_get_addr(parent);
for (bank = 0; bank < soc_data->no_banks; bank++) {
struct sunxi_gpio_platdata *plat;
struct udevice *dev;
struct vybrid_gpio_platdata *plat = dev_get_platdata(dev);
fdt_addr_t base_addr;
- base_addr = dev_read_addr(dev);
+ base_addr = devfdt_get_addr(dev);
if (base_addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct at91_i2c_bus *bus = dev_get_priv(dev);
int node = dev_of_offset(dev);
- bus->regs = dev_read_addr_ptr(dev);
+ bus->regs = (struct at91_i2c_regs *)devfdt_get_addr(dev);
bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev);
bus->clock_frequency = fdtdec_get_int(blob, node,
"clock-frequency", 100000);
struct i2c_bus *i2c_bus = dev_get_priv(dev);
i2c_bus->id = dev->seq;
- i2c_bus->regs = dev_read_addr_ptr(dev);
+ i2c_bus->regs = (struct i2c_regs *)devfdt_get_addr(dev);
i2c_bus->speed = 100000;
_davinci_i2c_init(i2c_bus->regs, i2c_bus->speed, 0);
node = dev_of_offset(dev);
- i2c_bus->hsregs = dev_read_addr_ptr(dev);
+ i2c_bus->hsregs = (struct exynos5_hsi2c *)devfdt_get_addr(dev);
i2c_bus->id = pinmux_decode_periph_id(blob, node);
fdt_addr_t addr;
struct uniphier_fi2c_priv *priv = dev_get_priv(dev);
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t addr;
struct uniphier_i2c_priv *priv = dev_get_priv(dev);
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
i2c_bus->driver_data = dev_get_driver_data(bus);
- addr = dev_read_addr(bus);
+ addr = devfdt_get_addr(bus);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
int node = dev_of_offset(bus);
const void *blob = gd->fdt_blob;
- bus_prvdata->base = map_physmem(dev_read_addr(bus),
+ bus_prvdata->base = map_physmem(devfdt_get_addr(bus),
sizeof(void *),
MAP_NOCACHE);
i2c_bus->driver_data = dev_get_driver_data(bus);
- addr = dev_read_addr(bus);
+ addr = devfdt_get_addr(bus);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct omap_i2c_platdata *plat = dev_get_platdata(bus);
- plat->base = dev_read_addr(bus);
+ plat->base = devfdt_get_addr(bus);
plat->speed = dev_read_u32_default(bus, "clock-frequency",
I2C_SPEED_STANDARD_RATE);
plat->ip_rev = dev_get_driver_data(bus);
node = dev_of_offset(dev);
- i2c_bus->regs = dev_read_addr_ptr(dev);
+ i2c_bus->regs = (struct s3c24x0_i2c *)devfdt_get_addr(dev);
i2c_bus->id = pinmux_decode_periph_id(blob, node);
struct input_config *input = &uc_priv->input;
int ret;
- priv->kbc = dev_read_addr_ptr(dev);
+ priv->kbc = (struct kbc_tegra *)devfdt_get_addr(dev);
if ((fdt_addr_t)priv->kbc == FDT_ADDR_T_NONE) {
debug("%s: No keyboard register found\n", __func__);
return -EINVAL;
debug("%s(dev=%p)\n", __func__, dev);
- thsp->regs = dev_read_addr(dev);
+ thsp->regs = devfdt_get_addr(dev);
if (thsp->regs == FDT_ADDR_T_NONE)
return -ENODEV;
{
struct altera_sysid_platdata *plat = dev_get_platdata(dev);
- plat->regs = map_physmem(dev_read_addr(dev),
+ plat->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct altera_sysid_regs),
MAP_NOCACHE);
debug("%s(dev=%p) (plat=%p)\n", __func__, dev, plat);
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct microchip_flexcom_platdata *plat = dev_get_platdata(dev);
int ret;
- plat->regs = map_physmem(dev_read_addr(dev),
+ plat->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct microchip_flexcom_regs),
MAP_NOCACHE);
goto free;
host->name = dev->name;
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
max_clk = clk_get_rate(&clk);
if (IS_ERR_VALUE(max_clk)) {
return ret;
host->name = dev->name;
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD;
host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
int ret;
int clock_id = (int)dev_get_driver_data(dev);
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
upriv->mmc = &plat->mmc;
plat->cfg.name = dev->name;
- host->phys_addr = dev_read_addr(dev);
+ host->phys_addr = devfdt_get_addr(dev);
if (host->phys_addr == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t base;
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
struct ftsdc_priv *priv = dev_get_priv(dev);
struct ftsdc010_chip *chip = &priv->chip;
chip->name = dev->name;
- chip->ioaddr = dev_read_addr_ptr(dev);
+ chip->ioaddr = (void *)devfdt_get_addr(dev);
chip->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"bus-width", 4);
chip->priv = dev;
struct dwmci_host *host = &priv->host;
host->name = dev->name;
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"bus-width", 4);
iproc_host->shadow_blk = 0;
host->name = dev->name;
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
host->voltages = MMC_VDD_165_195 |
MMC_VDD_32_33 | MMC_VDD_33_34;
host->quirks = SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B;
struct mmc_config *cfg;
int ret;
- priv->regs = map_physmem(dev_read_addr(dev), 0x100, MAP_NOCACHE);
+ priv->regs = map_physmem(devfdt_get_addr(dev), 0x100, MAP_NOCACHE);
cfg = &plat->cfg;
cfg->name = "MSC";
struct meson_mmc_platdata *pdata = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
int node = dev_of_offset(dev);
host->name = strdup(dev->name);
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
host->bus_width = fdtdec_get_int(gd->fdt_blob, node, "bus-width", 4);
host->index = fdtdec_get_uint(gd->fdt_blob, node, "index", 0);
priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
int ret;
host->name = MVSDH_NAME;
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
host->quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD;
host->mmc = &plat->mmc;
host->mmc->dev = dev;
int node = dev_of_offset(dev);
int ret;
- plat->base_addr = map_physmem(dev_read_addr(dev),
+ plat->base_addr = map_physmem(devfdt_get_addr(dev),
sizeof(struct hsmmc *),
MAP_NOCACHE);
plat->controller_flags |= of_data->controller_flags;
#ifdef CONFIG_OMAP54XX
- fixups = platform_fixups_mmc(dev_read_addr(dev));
+ fixups = platform_fixups_mmc(devfdt_get_addr(dev));
if (fixups) {
plat->hw_rev = fixups->hw_rev;
cfg->host_caps &= ~fixups->unsupported_caps;
fdt_addr_t base;
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t base;
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t base;
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
}
host->name = dev->name;
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"bus-width", 4);
host->clksel = socfpga_dwmci_clksel;
struct sdhci_host *host = dev_get_priv(dev);
host->name = strdup(dev->name);
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"bus-width", 4);
fdt_addr_t base;
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
ulong mclk;
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
const char *name;
host->name = dev->name;
- host->ioaddr = dev_read_addr_ptr(dev);
+ host->ioaddr = (void *)devfdt_get_addr(dev);
if (device_is_compatible(dev, "marvell,armada-3700-sdhci"))
priv->pad_ctrl_reg = (void *)devfdt_get_addr_index(dev, 1);
const char *phy_mode;
int ret;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
pdata->phy_interface = -1;
/* Decoding of convoluted PHY wiring on Atheros MIPS. */
eqos->dev = dev;
eqos->config = (void *)dev_get_driver_data(dev);
- eqos->regs = dev_read_addr(dev);
+ eqos->regs = devfdt_get_addr(dev);
if (eqos->regs == FDT_ADDR_T_NONE) {
- pr_err("dev_read_addr() failed");
+ pr_err("devfdt_get_addr() failed");
return -ENODEV;
}
eqos->mac_regs = (void *)(eqos->regs + EQOS_MAC_REGS_BASE);
struct ethoc_eth_pdata *pdata = dev_get_platdata(dev);
fdt_addr_t addr;
- pdata->eth_pdata.iobase = dev_read_addr(dev);
+ pdata->eth_pdata.iobase = devfdt_get_addr(dev);
addr = devfdt_get_addr_index(dev, 1);
if (addr != FDT_ADDR_T_NONE)
pdata->packet_base = addr;
struct fec_priv *priv = dev_get_priv(dev);
const char *phy_mode;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
priv->eth = (struct ethernet_regs *)pdata->iobase;
pdata->phy_interface = -1;
struct eth_pdata *pdata = dev_get_platdata(dev);
const u32 *val;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
/* Default to 10Mbit/s */
pdata->max_speed = 10;
struct ftgmac100_data *priv = dev_get_priv(dev);
const char *phy_mode;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
pdata->phy_interface = -1;
phy_mode = dev_read_string(dev, "phy-mode");
if (phy_mode)
struct ftmac100_data *priv = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_platdata(dev);
const char *mac;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
priv->iobase = pdata->iobase;
mac = dtbmacaddr(0);
if (mac)
struct ks_net *ks = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_platdata(dev);
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
ks->iobase = pdata->iobase;
return 0;
struct eth_pdata *pdata = dev_get_platdata(dev);
const u32 *val;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
/* Default to 10Mbit/s */
pdata->max_speed = 10;
priv->soc = dev_get_driver_data(dev);
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
/* get corresponding ethsys phandle */
ret = dev_read_phandle_with_args(dev, "mediatek,ethsys", NULL, 0, 0,
int pnode;
unsigned long addr;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
pdata->phy_interface = -1;
pnode = fdt_node_offset_by_compatible(blob, node,
struct eth_pdata *pdata = dev_get_platdata(dev);
const char *phy_mode;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
/* Get phy-mode / phy_interface from DT */
pdata->phy_interface = -1;
const fdt32_t *cell;
int ret = 0;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
pdata->phy_interface = -1;
phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
NULL);
const fdt32_t *cell;
int ret = 0;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
pdata->phy_interface = -1;
phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
NULL);
struct smc911x_priv *priv = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_platdata(dev);
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
priv->iobase = pdata->iobase;
return 0;
if (!priv->data)
return -EINVAL;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
pdata->phy_interface = -1;
phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
NULL);
#endif
int ret;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
if (pdata->iobase == FDT_ADDR_T_NONE) {
debug("%s: Cannot find MAC base address\n", __func__);
return -EINVAL;
{
struct eth_pdata *pdata = dev_get_platdata(dev);
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
return 0;
}
ks2_eth_parse_slave_interface(dev_of_offset(dev), gbe_0, priv, pdata);
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
return 0;
}
int offset = 0;
const char *phy_mode;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
priv->iobase = (struct axi_regs *)pdata->iobase;
offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
struct xemaclite *emaclite = dev_get_priv(dev);
int offset = 0;
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
emaclite->regs = (struct emaclite_regs *)ioremap_nocache(pdata->iobase,
0x10000);
{
struct cdns_pcie *pdata = dev_get_priv(dev);
- pdata->reg_base = dev_read_addr_ptr(dev);
+ pdata->reg_base = (void __iomem *)devfdt_get_addr(dev);
if (!pdata->reg_base)
return -ENOMEM;
struct ar933x_pinctrl_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct qca953x_pinctrl_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
if (!priv)
return -EINVAL;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
info->data = (struct armada_37xx_pin_data *)dev_get_driver_data(dev);
pin_data = info->data;
- info->base = dev_read_addr_ptr(dev);
+ info->base = (void __iomem *)devfdt_get_addr(dev);
if (!info->base) {
pr_err("unable to find regmap\n");
return -ENODEV;
fdt_addr_t addr_base;
dev = dev_get_parent(dev);
- addr_base = dev_read_addr(dev);
+ addr_base = devfdt_get_addr(dev);
if (addr_base == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t addr_base;
ofnode node;
- addr_base = dev_read_addr(dev);
+ addr_base = devfdt_get_addr(dev);
if (addr_base == FDT_ADDR_T_NONE)
return -EINVAL;
enum sh_pfc_model model = dev_get_driver_data(dev);
fdt_addr_t base;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev->parent);
+ addr = devfdt_get_addr(dev->parent);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct exynos_pwm_priv *priv = dev_get_priv(dev);
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (struct s5p_timer *)devfdt_get_addr(dev);
return 0;
}
{
struct imx_pwm_priv *priv = dev_get_priv(dev);
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (struct pwm_regs *)devfdt_get_addr(dev);
return 0;
}
int i;
priv->soc = (struct mtk_pwm_soc *)dev_get_driver_data(dev);
- priv->base = dev_read_addr_ptr(dev);
+ priv->base = (void __iomem *)devfdt_get_addr(dev);
if (!priv->base)
return -EINVAL;
ret = clk_get_by_name(dev, "top", &priv->top_clk);
{
struct sunxi_pwm_priv *priv = dev_get_priv(dev);
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (struct sunxi_pwm *)devfdt_get_addr(dev);
return 0;
}
struct uniphier_reset_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev->parent);
+ addr = devfdt_get_addr(dev->parent);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct mvrtc_pdata *pdata = dev_get_platdata(dev);
- pdata->iobase = dev_read_addr(dev);
+ pdata->iobase = devfdt_get_addr(dev);
return 0;
}
{
struct altera_jtaguart_platdata *plat = dev_get_platdata(dev);
- plat->regs = map_physmem(dev_read_addr(dev),
+ plat->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct altera_jtaguart_regs),
MAP_NOCACHE);
{
struct altera_uart_platdata *plat = dev_get_platdata(dev);
- plat->regs = map_physmem(dev_read_addr(dev),
+ plat->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct altera_uart_regs),
MAP_NOCACHE);
plat->uartclk = dev_read_u32_default(dev, "clock-frequency", 0);
#if CONFIG_IS_ENABLED(OF_CONTROL)
fdt_addr_t addr_base;
- addr_base = dev_read_addr(dev);
+ addr_base = devfdt_get_addr(dev);
if (addr_base == FDT_ADDR_T_NONE)
return -ENODEV;
fdt_addr_t addr;
u32 val;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct arc_serial_platdata *plat = dev_get_platdata(dev);
DECLARE_GLOBAL_DATA_PTR;
- plat->reg = dev_read_addr_ptr(dev);
+ plat->reg = (struct arc_serial_regs *)devfdt_get_addr(dev);
plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"clock-frequency", 0);
* since we need the soc simple-bus to be probed so that the 'ranges'
* property is used.
*/
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
int node = dev_of_offset(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct coldfire_serial_platdata *plat = dev_get_platdata(dev);
fdt_addr_t addr_base;
- addr_base = dev_read_addr(dev);
+ addr_base = devfdt_get_addr(dev);
if (addr_base == FDT_ADDR_T_NONE)
return -ENODEV;
struct meson_serial_platdata *plat = dev->platdata;
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct msm_serial_data *priv = dev_get_priv(dev);
- priv->base = dev_read_addr(dev);
+ priv->base = devfdt_get_addr(dev);
if (priv->base == FDT_ADDR_T_NONE)
return -EINVAL;
struct mxc_serial_platdata *plat = dev->platdata;
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t addr;
int ret;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
struct s5p_serial_platdata *plat = dev->platdata;
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t addr;
int ret;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (!addr)
return -EINVAL;
unsigned long val;
fdt_addr_t base;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
- plat->base = dev_read_addr(dev);
+ plat->base = devfdt_get_addr(dev);
if (plat->base == FDT_ADDR_T_NONE)
return -EINVAL;
fdt_addr_t base;
u32 tmp;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct uartlite_platdata *plat = dev_get_platdata(dev);
- plat->regs = dev_read_addr_ptr(dev);
+ plat->regs = (struct uartlite *)devfdt_get_addr(dev);
return 0;
}
menu "SOC (System On Chip) specific Drivers"
-config SOC_DEVICE
- bool "Enable SoC Device ID drivers using Driver Model"
- help
- This allows drivers to be provided for SoCs to help in identifying
- the SoC in use and matching SoC attributes for selecting SoC
- specific data. This is useful for other device drivers that may
- need different parameters or quirks enabled depending on the
- specific device variant in use.
-
-config SOC_DEVICE_TI_K3
- depends on SOC_DEVICE
- bool "Enable SoC Device ID driver for TI K3 SoCs"
- help
- This allows Texas Instruments Keystone 3 SoCs to identify
- specifics about the SoC in use.
-
source "drivers/soc/ti/Kconfig"
endmenu
# Makefile for the U-Boot SOC specific device drivers.
obj-$(CONFIG_SOC_TI) += ti/
-obj-$(CONFIG_SOC_DEVICE) += soc-uclass.o
-obj-$(CONFIG_SOC_DEVICE_TI_K3) += soc_ti_k3.o
-obj-$(CONFIG_SANDBOX) += soc_sandbox.o
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/
- * Dave Gerlach <d-gerlach@ti.com>
- */
-
-#include <common.h>
-#include <soc.h>
-#include <dm.h>
-#include <errno.h>
-#include <dm/lists.h>
-#include <dm/root.h>
-
-int soc_get(struct udevice **devp)
-{
- return uclass_first_device_err(UCLASS_SOC, devp);
-}
-
-int soc_get_machine(struct udevice *dev, char *buf, int size)
-{
- struct soc_ops *ops = soc_get_ops(dev);
-
- if (!ops->get_machine)
- return -ENOSYS;
-
- return ops->get_machine(dev, buf, size);
-}
-
-int soc_get_family(struct udevice *dev, char *buf, int size)
-{
- struct soc_ops *ops = soc_get_ops(dev);
-
- if (!ops->get_family)
- return -ENOSYS;
-
- return ops->get_family(dev, buf, size);
-}
-
-int soc_get_revision(struct udevice *dev, char *buf, int size)
-{
- struct soc_ops *ops = soc_get_ops(dev);
-
- if (!ops->get_revision)
- return -ENOSYS;
-
- return ops->get_revision(dev, buf, size);
-}
-
-const struct soc_attr *
-soc_device_match(const struct soc_attr *matches)
-{
- bool match;
- struct udevice *soc;
- char str[SOC_MAX_STR_SIZE];
-
- if (!matches)
- return NULL;
-
- if (soc_get(&soc))
- return NULL;
-
- while (1) {
- if (!(matches->machine || matches->family ||
- matches->revision))
- break;
-
- match = true;
-
- if (matches->machine) {
- if (!soc_get_machine(soc, str, SOC_MAX_STR_SIZE)) {
- if (strcmp(matches->machine, str))
- match = false;
- }
- }
-
- if (matches->family) {
- if (!soc_get_family(soc, str, SOC_MAX_STR_SIZE)) {
- if (strcmp(matches->family, str))
- match = false;
- }
- }
-
- if (matches->revision) {
- if (!soc_get_revision(soc, str, SOC_MAX_STR_SIZE)) {
- if (strcmp(matches->revision, str))
- match = false;
- }
- }
-
- if (match)
- return matches;
-
- matches++;
- }
-
- return NULL;
-}
-
-UCLASS_DRIVER(soc) = {
- .id = UCLASS_SOC,
- .name = "soc",
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Sandbox driver for the SOC uclass
- *
- * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/
- * Dave Gerlach <d-gerlach@ti.com>
- */
-
-#include <common.h>
-#include <dm.h>
-#include <soc.h>
-
-int soc_sandbox_get_family(struct udevice *dev, char *buf, int size)
-{
- snprintf(buf, size, "SANDBOX1xx");
-
- return 0;
-}
-
-int soc_sandbox_get_machine(struct udevice *dev, char *buf, int size)
-{
- snprintf(buf, size, "SANDBOX123");
-
- return 0;
-}
-
-int soc_sandbox_get_revision(struct udevice *dev, char *buf, int size)
-{
- snprintf(buf, size, "1.0");
-
- return 0;
-}
-
-static const struct soc_ops soc_sandbox_ops = {
- .get_family = soc_sandbox_get_family,
- .get_revision = soc_sandbox_get_revision,
- .get_machine = soc_sandbox_get_machine,
-};
-
-int soc_sandbox_probe(struct udevice *dev)
-{
- return 0;
-}
-
-static const struct udevice_id soc_sandbox_ids[] = {
- { .compatible = "sandbox,soc" },
- { }
-};
-
-U_BOOT_DRIVER(soc_sandbox) = {
- .name = "soc_sandbox",
- .id = UCLASS_SOC,
- .ops = &soc_sandbox_ops,
- .of_match = soc_sandbox_ids,
- .probe = soc_sandbox_probe,
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
- * Dave Gerlach <d-gerlach@ti.com>
- */
-
-#include <common.h>
-#include <dm.h>
-#include <soc.h>
-
-#include <asm/io.h>
-
-#define AM65X 0xbb5a
-#define J721E 0xbb64
-
-#define REV_SR1_0 0
-#define REV_SR2_0 1
-
-#define JTAG_ID_VARIANT_SHIFT 28
-#define JTAG_ID_VARIANT_MASK (0xf << 28)
-#define JTAG_ID_PARTNO_SHIFT 12
-#define JTAG_ID_PARTNO_MASK (0xffff << 12)
-
-struct soc_ti_k3_platdata {
- const char *family;
- const char *revision;
-};
-
-static const char *get_family_string(u32 idreg)
-{
- const char *family;
- u32 soc;
-
- soc = (idreg & JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
-
- switch (soc) {
- case AM65X:
- family = "AM65X";
- break;
- case J721E:
- family = "J721E";
- break;
- default:
- family = "Unknown Silicon";
- };
-
- return family;
-}
-
-static const char *get_rev_string(u32 idreg)
-{
- const char *revision;
- u32 rev;
-
- rev = (idreg & JTAG_ID_VARIANT_MASK) >> JTAG_ID_VARIANT_SHIFT;
-
- switch (rev) {
- case REV_SR1_0:
- revision = "1.0";
- break;
- case REV_SR2_0:
- revision = "2.0";
- break;
- default:
- revision = "Unknown Revision";
- };
-
- return revision;
-}
-
-static int soc_ti_k3_get_family(struct udevice *dev, char *buf, int size)
-{
- struct soc_ti_k3_platdata *plat = dev_get_platdata(dev);
-
- snprintf(buf, size, "%s", plat->family);
-
- return 0;
-}
-
-static int soc_ti_k3_get_revision(struct udevice *dev, char *buf, int size)
-{
- struct soc_ti_k3_platdata *plat = dev_get_platdata(dev);
-
- snprintf(buf, size, "SR%s", plat->revision);
-
- return 0;
-}
-
-static const struct soc_ops soc_ti_k3_ops = {
- .get_family = soc_ti_k3_get_family,
- .get_revision = soc_ti_k3_get_revision,
-};
-
-int soc_ti_k3_probe(struct udevice *dev)
-{
- struct soc_ti_k3_platdata *plat = dev_get_platdata(dev);
- u32 idreg;
- void *idreg_addr;
-
- idreg_addr = dev_read_addr_ptr(dev);
- if (!idreg_addr)
- return -EINVAL;
-
- idreg = readl(idreg_addr);
-
- plat->family = get_family_string(idreg);
- plat->revision = get_rev_string(idreg);
-
- return 0;
-}
-
-static const struct udevice_id soc_ti_k3_ids[] = {
- { .compatible = "ti,am654-chipid" },
- { }
-};
-
-U_BOOT_DRIVER(soc_ti_k3) = {
- .name = "soc_ti_k3",
- .id = UCLASS_SOC,
- .ops = &soc_ti_k3_ops,
- .of_match = soc_ti_k3_ids,
- .probe = soc_ti_k3_probe,
- .platdata_auto_alloc_size = sizeof(struct soc_ti_k3_platdata),
-};
{
struct altera_spi_platdata *plat = dev_get_platdata(bus);
- plat->regs = map_physmem(dev_read_addr(bus),
+ plat->regs = map_physmem(devfdt_get_addr(bus),
sizeof(struct altera_spi_regs),
MAP_NOCACHE);
const void *blob = gd->fdt_blob;
int node = dev_of_offset(bus);
- ns->regs = map_physmem(dev_read_addr(bus),
+ ns->regs = map_physmem(devfdt_get_addr(bus),
sizeof(struct atcspi200_spi_regs),
MAP_NOCACHE);
if (!ns->regs) {
struct ath79_spi_priv *priv = dev_get_priv(bus);
fdt_addr_t addr;
- addr = dev_read_addr(bus);
+ addr = devfdt_get_addr(bus);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
if (ret)
return ret;
- bus_plat->regs = dev_read_addr_ptr(bus);
+ bus_plat->regs = (struct at91_spi *)devfdt_get_addr(bus);
#if CONFIG_IS_ENABLED(DM_GPIO)
struct atmel_spi_priv *priv = dev_get_priv(bus);
int node = dev_of_offset(bus);
int *ctar, len;
- addr = dev_read_addr(bus);
+ addr = devfdt_get_addr(bus);
if (addr == FDT_ADDR_T_NONE)
return -ENOMEM;
struct davinci_spi_platdata *plat = bus->platdata;
fdt_addr_t addr;
- addr = dev_read_addr(bus);
+ addr = devfdt_get_addr(bus);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct dw_spi_platdata *plat = bus->platdata;
- plat->regs = dev_read_addr_ptr(bus);
+ plat->regs = (struct dw_spi *)devfdt_get_addr(bus);
/* Use 500KHz as a suitable default */
plat->frequency = dev_read_u32_default(bus, "spi-max-frequency",
const void *blob = gd->fdt_blob;
int node = dev_of_offset(bus);
- plat->regs = dev_read_addr_ptr(bus);
+ plat->regs = (struct exynos_spi *)devfdt_get_addr(bus);
plat->periph_id = pinmux_decode_periph_id(blob, node);
if (plat->periph_id == PERIPH_ID_NONE) {
plat->num_chipselect =
fdtdec_get_int(blob, node, "num-cs", FSL_DSPI_MAX_CHIPSELECT);
- addr = dev_read_addr(bus);
+ addr = devfdt_get_addr(bus);
if (addr == FDT_ADDR_T_NONE) {
debug("DSPI: Can't get base address or size\n");
return -ENOMEM;
const struct mvebu_spi_dev *drvdata =
(struct mvebu_spi_dev *)dev_get_driver_data(bus);
- plat->spireg = dev_read_addr_ptr(bus);
+ plat->spireg = (struct kwspi_registers *)devfdt_get_addr(bus);
plat->is_errata_50mhz_ac = drvdata->is_errata_50mhz_ac;
return 0;
struct mtk_snfi_priv *priv = dev_get_priv(bus);
int ret;
- priv->base = dev_read_addr_ptr(bus);
+ priv->base = (void __iomem *)devfdt_get_addr(bus);
if (!priv->base)
return -EINVAL;
struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
int ret;
- plat->spireg = dev_read_addr_ptr(bus);
+ plat->spireg = (struct spi_reg *)devfdt_get_addr(bus);
ret = clk_get_by_index(bus, 0, &plat->clk);
if (ret) {
}
}
- mxcs->base = dev_read_addr(bus);
+ mxcs->base = devfdt_get_addr(bus);
if (mxcs->base == FDT_ADDR_T_NONE)
return -ENODEV;
struct omap2_mcspi_platform_config* data =
(struct omap2_mcspi_platform_config*)dev_get_driver_data(dev);
- priv->regs = (struct mcspi *)(dev_read_addr(dev) + data->regs_offset);
+ priv->regs = (struct mcspi *)(devfdt_get_addr(dev) + data->regs_offset);
if (fdtdec_get_bool(blob, node, "ti,pindir-d0-out-d1-in"))
priv->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
else
struct sun4i_spi_platdata *plat = dev_get_platdata(bus);
int node = dev_of_offset(bus);
- plat->base = dev_read_addr(bus);
+ plat->base = devfdt_get_addr(bus);
plat->variant = (struct sun4i_spi_variant *)dev_get_driver_data(bus);
plat->max_hz = fdtdec_get_int(gd->fdt_blob, node,
"spi-max-frequency",
const void *blob = gd->fdt_blob;
int node = dev_of_offset(bus);
- plat->base = dev_read_addr(bus);
+ plat->base = devfdt_get_addr(bus);
plat->periph_id = clock_decode_periph_id(bus);
if (plat->periph_id == PERIPH_ID_NONE) {
const void *blob = gd->fdt_blob;
int node = dev_of_offset(bus);
- plat->base = dev_read_addr(bus);
+ plat->base = devfdt_get_addr(bus);
plat->periph_id = clock_decode_periph_id(bus);
if (plat->periph_id == PERIPH_ID_NONE) {
fdt_addr_t mmap_size;
priv->ctrl_mod_mmap = map_syscon_chipselects(bus);
- priv->base = map_physmem(dev_read_addr(bus),
+ priv->base = map_physmem(devfdt_get_addr(bus),
sizeof(struct ti_qspi_regs), MAP_NOCACHE);
mmap_addr = devfdt_get_addr_size_index(bus, 1, &mmap_size);
priv->memory_map = map_physmem(mmap_addr, mmap_size, MAP_NOCACHE);
const void *blob = gd->fdt_blob;
int node = dev_of_offset(bus);
- plat->regs = dev_read_addr_ptr(bus);
+ plat->regs = (struct zynq_spi_regs *)devfdt_get_addr(bus);
/* FIXME: Use 250MHz as a suitable default */
plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
debug("%s\n", __func__);
- plat->regs = (struct zynqmp_qspi_regs *)(dev_read_addr(bus) +
+ plat->regs = (struct zynqmp_qspi_regs *)(devfdt_get_addr(bus) +
GQSPI_REG_OFFSET);
plat->dma_regs = (struct zynqmp_qspi_dma_regs *)
- (dev_read_addr(bus) + GQSPI_DMA_REG_OFFSET);
+ (devfdt_get_addr(bus) + GQSPI_DMA_REG_OFFSET);
return 0;
}
bool is_v1;
int i;
- priv->arb_chnl = dev_read_addr(dev);
+ priv->arb_chnl = devfdt_get_addr(dev);
priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
dev_of_offset(parent), node, "reg", 1, NULL, false);
priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
static int atftme_timer_ofdata_to_platdata(struct udevice *dev)
{
struct atftmr_timer_platdata *plat = dev_get_platdata(dev);
- plat->regs = map_physmem(dev_read_addr(dev),
+ plat->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct atftmr_timer_regs),
MAP_NOCACHE);
return 0;
{
struct altera_timer_platdata *plat = dev_get_platdata(dev);
- plat->regs = map_physmem(dev_read_addr(dev),
+ plat->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct altera_timer_regs),
MAP_NOCACHE);
static int atcpit_timer_ofdata_to_platdata(struct udevice *dev)
{
struct atcpit_timer_platdata *plat = dev_get_platdata(dev);
- plat->regs = map_physmem(dev_read_addr(dev), 0x100 , MAP_NOCACHE);
+ plat->regs = map_physmem(devfdt_get_addr(dev) , 0x100 , MAP_NOCACHE);
return 0;
}
{
struct omap_timer_priv *priv = dev_get_priv(dev);
- priv->regs = map_physmem(dev_read_addr(dev),
+ priv->regs = map_physmem(devfdt_get_addr(dev),
sizeof(struct omap_gptimer_regs), MAP_NOCACHE);
return 0;
int (*init)(void __iomem *regs);
int ret;
- base = dev_read_addr(dev);
+ base = devfdt_get_addr(dev);
if (base == FDT_ADDR_T_NONE)
return -EINVAL;
/*
* Get the base address for EHCI controller from the device node
*/
- hcd_base = dev_read_addr(dev);
+ hcd_base = devfdt_get_addr(dev);
if (hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the EHCI register base address\n");
return -ENXIO;
/*
* Get the base address for XHCI controller from the device node
*/
- plat->hcd_base = dev_read_addr(dev);
+ plat->hcd_base = devfdt_get_addr(dev);
if (plat->hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the XHCI register base address\n");
return -ENXIO;
/*
* Get the base address for EHCI controller from the device node
*/
- priv->hcd_base = dev_read_addr(dev);
+ priv->hcd_base = devfdt_get_addr(dev);
if (priv->hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the EHCI register base address\n");
return -ENXIO;
/*
* Get the base address for EHCI controller from the device node
*/
- priv->hcd_base = dev_read_addr(dev);
+ priv->hcd_base = devfdt_get_addr(dev);
if (priv->hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the EHCI register base address\n");
return -ENXIO;
static int ehci_usb_probe(struct udevice *dev)
{
struct usb_platdata *plat = dev_get_platdata(dev);
- struct usb_ehci *ehci = dev_read_addr_ptr(dev);
+ struct usb_ehci *ehci = (struct usb_ehci *)devfdt_get_addr(dev);
struct ehci_mx5_priv_data *priv = dev_get_priv(dev);
enum usb_init_type type = plat->init_type;
struct ehci_hccr *hccr;
static int ehci_usb_phy_mode(struct udevice *dev)
{
struct usb_platdata *plat = dev_get_platdata(dev);
- void *__iomem addr = dev_read_addr_ptr(dev);
+ void *__iomem addr = (void *__iomem)devfdt_get_addr(dev);
void *__iomem phy_ctrl, *__iomem phy_status;
const void *blob = gd->fdt_blob;
int offset = dev_of_offset(dev), phy_off;
static int ehci_usb_probe(struct udevice *dev)
{
struct usb_platdata *plat = dev_get_platdata(dev);
- struct usb_ehci *ehci = dev_read_addr_ptr(dev);
+ struct usb_ehci *ehci = (struct usb_ehci *)devfdt_get_addr(dev);
struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
enum usb_init_type type = plat->init_type;
struct ehci_hccr *hccr;
struct ehci_hccr *hccr;
struct ehci_hcor *hcor;
- priv->ehci = dev_read_addr_ptr(dev);
+ priv->ehci = (struct omap_ehci *)devfdt_get_addr(dev);
priv->portnr = dev->seq;
priv->init_type = plat->init_type;
priv->portnr = dev->seq;
- priv->ehci = dev_read_addr_ptr(dev);
+ priv->ehci = (struct usb_ehci *)devfdt_get_addr(dev);
mode = fdt_getprop(dt_blob, node, "dr_mode", NULL);
if (mode) {
if (0 == strcmp(mode, "host")) {
#if CONFIG_IS_ENABLED(DM_USB)
static int ohci_da8xx_probe(struct udevice *dev)
{
- struct ohci_regs *regs = dev_read_addr_ptr(dev);
+ struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev);
struct da8xx_ohci *priv = dev_get_priv(dev);
int i, err, ret, clock_nb;
static int ohci_usb_probe(struct udevice *dev)
{
- struct ohci_regs *regs = dev_read_addr_ptr(dev);
+ struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev);
struct generic_ohci *priv = dev_get_priv(dev);
int i, err, ret, clock_nb, reset_nb;
/*
* Get the base address for XHCI controller from the device node
*/
- plat->hcd_base = dev_read_addr(dev);
+ plat->hcd_base = devfdt_get_addr(dev);
if (plat->hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the XHCI register base address\n");
return -ENXIO;
/*
* Get the base address for XHCI controller from the device node
*/
- priv->hcd_base = dev_read_addr(dev);
+ priv->hcd_base = devfdt_get_addr(dev);
if (priv->hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the XHCI register base address\n");
return -ENXIO;
/*
* Get the base address for XHCI controller from the device node
*/
- plat->hcd_base = dev_read_addr(dev);
+ plat->hcd_base = devfdt_get_addr(dev);
if (plat->hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the XHCI register base address\n");
return -ENXIO;
{
struct rcar_xhci_platdata *plat = dev_get_platdata(dev);
- plat->hcd_base = dev_read_addr(dev);
+ plat->hcd_base = devfdt_get_addr(dev);
if (plat->hcd_base == FDT_ADDR_T_NONE) {
debug("Can't get the XHCI register base address\n");
return -ENXIO;
const void *blob = gd->fdt_blob;
int node = dev_of_offset(dev);
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (struct atmel_hlcd_regs *)devfdt_get_addr(dev);
if (!priv->regs) {
debug("%s: No display controller address\n", __func__);
return -EINVAL;
unsigned int node = dev_of_offset(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE) {
debug("Can't get the DP base address\n");
return -EINVAL;
const void *blob = gd->fdt_blob;
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE) {
debug("Can't get the FIMD base address\n");
return -EINVAL;
int rgb;
int ret;
- priv->disp = dev_read_addr_ptr(dev);
+ priv->disp = (struct disp_ctlr *)devfdt_get_addr(dev);
if (!priv->disp) {
debug("%s: No display controller address\n", __func__);
return -EINVAL;
struct mxc_w1_pdata *pdata = dev_get_platdata(dev);
fdt_addr_t addr;
- addr = dev_read_addr(dev);
+ addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
{
struct omap3_wdt_priv *priv = dev_get_priv(dev);
- priv->regs = dev_read_addr_ptr(dev);
+ priv->regs = (struct wd_timer *)devfdt_get_addr(dev);
if (!priv->regs)
return -EINVAL;
debug("IWDG init\n");
- priv->base = dev_read_addr(dev);
+ priv->base = devfdt_get_addr(dev);
if (priv->base == FDT_ADDR_T_NONE)
return -EINVAL;
* @size: Size of string space
* @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
- int (*get_desc)(const struct udevice *dev, char *buf, int size);
+ int (*get_desc)(struct udevice *dev, char *buf, int size);
/**
* get_info() - Get information about a CPU
* @info: Returns CPU info
* @return 0 if OK, -ve on error
*/
- int (*get_info)(const struct udevice *dev, struct cpu_info *info);
+ int (*get_info)(struct udevice *dev, struct cpu_info *info);
/**
* get_count() - Get number of CPUs
* @dev: Device to check (UCLASS_CPU)
* @return CPU count if OK, -ve on error
*/
- int (*get_count)(const struct udevice *dev);
+ int (*get_count)(struct udevice *dev);
/**
* get_vendor() - Get vendor name of a CPU
* @size: Size of string space
* @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
- int (*get_vendor)(const struct udevice *dev, char *buf, int size);
+ int (*get_vendor)(struct udevice *dev, char *buf, int size);
/**
* is_current() - Check if the CPU that U-Boot is currently running from
*
* Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
-int cpu_get_desc(const struct udevice *dev, char *buf, int size);
+int cpu_get_desc(struct udevice *dev, char *buf, int size);
/**
* cpu_get_info() - Get information about a CPU
*
* Return: 0 if OK, -ve on error
*/
-int cpu_get_info(const struct udevice *dev, struct cpu_info *info);
+int cpu_get_info(struct udevice *dev, struct cpu_info *info);
/**
* cpu_get_count() - Get number of CPUs
*
* Return: CPU count if OK, -ve on error
*/
-int cpu_get_count(const struct udevice *dev);
+int cpu_get_count(struct udevice *dev);
/**
* cpu_get_vendor() - Get vendor name of a CPU
*
* Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
-int cpu_get_vendor(const struct udevice *dev, char *buf, int size);
+int cpu_get_vendor(struct udevice *dev, char *buf, int size);
/**
* cpu_probe_all() - Probe all available CPUs
UCLASS_SERIAL, /* Serial UART */
UCLASS_SIMPLE_BUS, /* Bus with child devices */
UCLASS_SMEM, /* Shared memory interface */
- UCLASS_SOC, /* SOC Device */
UCLASS_SOUND, /* Playing simple sounds */
UCLASS_SPI, /* SPI bus */
UCLASS_SPI_FLASH, /* SPI flash */
int fdtdec_decode_display_timing(const void *blob, int node, int index,
struct display_timing *config);
+/**
+ * fdtdec_setup_mem_size_base_fdt() - decode and setup gd->ram_size and
+ * gd->ram_start
+ *
+ * Decode the /memory 'reg' property to determine the size and start of the
+ * first memory bank, populate the global data with the size and start of the
+ * first bank of memory.
+ *
+ * This function should be called from a boards dram_init(). This helper
+ * function allows for boards to query the device tree for DRAM size and start
+ * address instead of hard coding the value in the case where the memory size
+ * and start address cannot be detected automatically.
+ *
+ * @param blob FDT blob
+ *
+ * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or
+ * invalid
+ */
+int fdtdec_setup_mem_size_base_fdt(const void *blob);
+
/**
* fdtdec_setup_mem_size_base() - decode and setup gd->ram_size and
* gd->ram_start
*/
int fdtdec_setup_mem_size_base(void);
+/**
+ * fdtdec_setup_memory_banksize_fdt() - decode and populate gd->bd->bi_dram
+ *
+ * Decode the /memory 'reg' property to determine the address and size of the
+ * memory banks. Use this data to populate the global data board info with the
+ * phys address and size of memory banks.
+ *
+ * This function should be called from a boards dram_init_banksize(). This
+ * helper function allows for boards to query the device tree for memory bank
+ * information instead of hard coding the information in cases where it cannot
+ * be detected automatically.
+ *
+ * @param blob FDT blob
+ *
+ * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or
+ * invalid
+ */
+int fdtdec_setup_memory_banksize_fdt(const void *blob);
+
/**
* fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram
*
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/
- * Dave Gerlach <d-gerlach@ti.com>
- */
-
-#ifndef __SOC_H
-#define __SOC_H
-
-#define SOC_MAX_STR_SIZE 128
-
-/**
- * struct soc_attr - Contains SoC identify information to be used in
- * SoC matching. An array of these structs
- * representing different SoCs can be passed to
- * soc_device_match and the struct matching the SoC
- * in use will be returned.
- *
- * @family - Name of SoC family that can include multiple related SoC
- * variants. Example: am33
- * @machine - Name of a specific SoC. Example: am3352
- * @revision - Name of a specific SoC revision. Example: SR1.1
- * @data - A pointer to user data for the SoC variant
- */
-struct soc_attr {
- const char *family;
- const char *machine;
- const char *revision;
- const void *data;
-};
-
-struct soc_ops {
- /**
- * get_machine() - Get machine name of an SOC
- *
- * @dev: Device to check (UCLASS_SOC)
- * @buf: Buffer to place string
- * @size: Size of string space
- * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
- */
- int (*get_machine)(struct udevice *dev, char *buf, int size);
-
- /**
- * get_revision() - Get revision name of a SOC
- *
- * @dev: Device to check (UCLASS_SOC)
- * @buf: Buffer to place string
- * @size: Size of string space
- * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
- */
- int (*get_revision)(struct udevice *dev, char *buf, int size);
-
- /**
- * get_family() - Get family name of an SOC
- *
- * @dev: Device to check (UCLASS_SOC)
- * @buf: Buffer to place string
- * @size: Size of string space
- * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
- */
- int (*get_family)(struct udevice *dev, char *buf, int size);
-};
-
-#define soc_get_ops(dev) ((struct soc_ops *)(dev)->driver->ops)
-
-#ifdef CONFIG_SOC_DEVICE
-/**
- * soc_get() - Return the soc device for the soc in use.
- * @devp: Pointer to structure to receive the soc device.
- *
- * Since there can only be at most one SOC instance, the API can supply a
- * function that returns the unique device.
- *
- * Return: 0 if OK, -ve on error.
- */
-int soc_get(struct udevice **devp);
-
-/**
- * soc_get_machine() - Get machine name of an SOC
- * @dev: Device to check (UCLASS_SOC)
- * @buf: Buffer to place string
- * @size: Size of string space
- *
- * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
- */
-int soc_get_machine(struct udevice *dev, char *buf, int size);
-
-/**
- * soc_get_revision() - Get revision name of an SOC
- * @dev: Device to check (UCLASS_SOC)
- * @buf: Buffer to place string
- * @size: Size of string space
- *
- * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
- */
-int soc_get_revision(struct udevice *dev, char *buf, int size);
-
-/**
- * soc_get_family() - Get family name of an SOC
- * @dev: Device to check (UCLASS_SOC)
- * @buf: Buffer to place string
- * @size: Size of string space
- *
- * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
- */
-int soc_get_family(struct udevice *dev, char *buf, int size);
-
-/**
- * soc_device_match() - Return match from an array of soc_attr
- * @matches: Array with any combination of family, revision or machine set
- *
- * Return: Pointer to struct from matches array with set attributes matching
- * those provided by the soc device, or NULL if no match found.
- */
-const struct soc_attr *
-soc_device_match(const struct soc_attr *matches);
-
-#else
-static inline int soc_get(struct udevice **devp)
-{
- return -ENOSYS;
-}
-
-static inline int soc_get_machine(struct udevice *dev, char *buf, int size)
-{
- return -ENOSYS;
-}
-
-static inline int soc_get_revision(struct udevice *dev, char *buf, int size)
-{
- return -ENOSYS;
-}
-
-static inline int soc_get_family(struct udevice *dev, char *buf, int size)
-{
- return -ENOSYS;
-}
-
-static inline const struct soc_attr *
-soc_device_match(const struct soc_attr *matches)
-{
- return NULL;
-}
-#endif
-#endif /* _SOC_H */
return ret;
}
-int fdtdec_setup_mem_size_base(void)
+int fdtdec_setup_mem_size_base_fdt(const void *blob)
{
int ret, mem;
struct fdt_resource res;
- mem = fdt_path_offset(gd->fdt_blob, "/memory");
+ mem = fdt_path_offset(blob, "/memory");
if (mem < 0) {
debug("%s: Missing /memory node\n", __func__);
return -EINVAL;
}
- ret = fdt_get_resource(gd->fdt_blob, mem, "reg", 0, &res);
+ ret = fdt_get_resource(blob, mem, "reg", 0, &res);
if (ret != 0) {
debug("%s: Unable to decode first memory bank\n", __func__);
return -EINVAL;
return 0;
}
+int fdtdec_setup_mem_size_base(void)
+{
+ return fdtdec_setup_mem_size_base_fdt(gd->fdt_blob);
+}
+
#if defined(CONFIG_NR_DRAM_BANKS)
static int get_next_memory_node(const void *blob, int mem)
{
do {
- mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem,
+ mem = fdt_node_offset_by_prop_value(blob, mem,
"device_type", "memory", 7);
} while (!fdtdec_get_is_enabled(blob, mem));
return mem;
}
-int fdtdec_setup_memory_banksize(void)
+int fdtdec_setup_memory_banksize_fdt(const void *blob)
{
int bank, ret, mem, reg = 0;
struct fdt_resource res;
- mem = get_next_memory_node(gd->fdt_blob, -1);
+ mem = get_next_memory_node(blob, -1);
if (mem < 0) {
debug("%s: Missing /memory node\n", __func__);
return -EINVAL;
}
for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
- ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res);
+ ret = fdt_get_resource(blob, mem, "reg", reg++, &res);
if (ret == -FDT_ERR_NOTFOUND) {
reg = 0;
- mem = get_next_memory_node(gd->fdt_blob, mem);
+ mem = get_next_memory_node(blob, mem);
if (mem == -FDT_ERR_NOTFOUND)
break;
- ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res);
+ ret = fdt_get_resource(blob, mem, "reg", reg++, &res);
if (ret == -FDT_ERR_NOTFOUND)
break;
}
return 0;
}
+
+int fdtdec_setup_memory_banksize(void)
+{
+ return fdtdec_setup_memory_banksize_fdt(gd->fdt_blob);
+
+}
#endif
#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
$(PYTHON3) $< --quiet build_ext --inplace
$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
- @# Remove the library since otherwise Python doesn't seem to regenerate
- @# the libfdt.py file if it is missing.
- rm -f $(obj)/_libfdt*.so
$(call if_changed,pymod)
always += _libfdt.so
obj-$(CONFIG_MISC) += misc.o
obj-$(CONFIG_DM_SERIAL) += serial.o
obj-$(CONFIG_CPU) += cpu.o
-obj-$(CONFIG_SOC_DEVICE) += soc.o
obj-$(CONFIG_SOUND) += sound.o
obj-$(CONFIG_TEE) += tee.o
obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o
static int dm_test_acpi_create_dmar(struct unit_test_state *uts)
{
struct acpi_dmar dmar;
- struct udevice *cpu;
- ut_assertok(uclass_first_device(UCLASS_CPU, &cpu));
- ut_assertnonnull(cpu);
ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP));
ut_asserteq(DMAR_INTR_REMAP, dmar.flags);
ut_asserteq(32 - 1, dmar.host_address_width);
for (uclass_find_first_device(UCLASS_TEST, &dev);
dev;
uclass_find_next_device(&dev)) {
- ut_assertnonnull(dev);
+ ut_assert(dev);
uc_pdata = dev_get_uclass_platdata(dev);
ut_assert(uc_pdata);
for (uclass_find_first_device(UCLASS_TEST, &dev);
dev;
uclass_find_next_device(&dev)) {
- ut_assertnonnull(dev);
+ ut_assert(dev);
uc_pdata = dev_get_uclass_platdata(dev);
ut_assert(uc_pdata);
dev;
ret = uclass_find_next_device(&dev)) {
ut_assert(!ret);
- ut_assertnonnull(dev);
+ ut_assert(dev);
}
ut_assertok(uclass_find_first_device(UCLASS_TEST_DUMMY, &dev));
- ut_assertnull(dev);
+ ut_assert(!dev);
return 0;
}
testdev;
ret = uclass_find_next_device(&testdev)) {
ut_assertok(ret);
- ut_assertnonnull(testdev);
+ ut_assert(testdev);
findret = uclass_find_device_by_name(UCLASS_TEST_FDT,
testdev->name,
* allocation created in the bind() method.
*/
ut_assertok(uclass_find_first_device(UCLASS_TEST_DEVRES, &dev));
- ut_assertnonnull(dev);
devres_get_stats(dev, &stats);
ut_asserteq(1, stats.allocs);
ut_asserteq(TEST_DEVRES_SIZE, stats.total_size);
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Test for the SOC uclass
- *
- * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/
- * Dave Gerlach <d-gerlach@ti.com>
- */
-
-#include <common.h>
-#include <dm.h>
-#include <dm/test.h>
-#include <dm/uclass-internal.h>
-#include <soc.h>
-#include <test/ut.h>
-
-struct sb_soc_data {
- unsigned long param;
-};
-
-static int dm_test_soc(struct unit_test_state *uts)
-{
- struct udevice *dev;
- char text[128];
- const struct soc_attr *soc_data;
- const struct sb_soc_data *match_data;
-
- static const struct sb_soc_data soc_sandbox1_sr10_data = { 0x91919191 };
- static const struct sb_soc_data soc_sandbox123_data = { 0x84848484 };
-
- static const struct soc_attr sb_soc_devices_full[] = {
- {
- .family = "SANDBOX0xx",
- .machine = "SANDBOX012",
- .revision = "1.0",
- .data = NULL,
- },
- {
- .family = "SANDBOX1xx",
- .machine = "SANDBOX107",
- .revision = "1.0",
- .data = NULL,
- },
- {
- .family = "SANDBOX1xx",
- .machine = "SANDBOX123",
- .revision = "1.0",
- .data = &soc_sandbox123_data,
- },
- {
- .family = "SANDBOX1xx",
- .machine = "SANDBOX131",
- .revision = "2.0",
- .data = NULL,
- },
- { /* sentinel */ }
- };
-
- static const struct soc_attr sb_soc_devices_partial[] = {
- {
- .family = "SANDBOX0xx",
- .revision = "1.0",
- .data = NULL,
- },
- {
- .family = "SANDBOX1xx",
- .revision = "1.0",
- .data = &soc_sandbox1_sr10_data,
- },
- {
- .family = "SANDBOX1xx",
- .revision = "2.0",
- .data = NULL,
- },
- { /* sentinel */ }
- };
-
- static const struct soc_attr sb_soc_devices_nomatch[] = {
- {
- .family = "SANDBOX0xx",
- .revision = "1.0",
- .data = NULL,
- },
- {
- .family = "SANDBOX1xx",
- .revision = "2.0",
- .data = NULL,
- },
- { /* sentinel */ }
- };
-
- ut_assertok(soc_get(&dev));
-
- ut_assertok(soc_get_machine(dev, text, sizeof(text)));
- ut_assertok(strcmp(text, "SANDBOX123"));
-
- ut_assertok(soc_get_family(dev, text, sizeof(text)));
- ut_assertok(strcmp(text, "SANDBOX1xx"));
-
- ut_assertok(soc_get_revision(dev, text, sizeof(text)));
- ut_asserteq_str(text, "1.0");
-
- soc_data = soc_device_match(sb_soc_devices_full);
- ut_assert(soc_data);
-
- match_data = soc_data->data;
- ut_asserteq(match_data->param, 0x84848484);
-
- soc_data = soc_device_match(sb_soc_devices_partial);
- ut_assert(soc_data);
-
- match_data = soc_data->data;
- ut_asserteq(match_data->param, 0x91919191);
-
- soc_data = soc_device_match(sb_soc_devices_nomatch);
- ut_asserteq_ptr(soc_data, NULL);
-
- return 0;
-}
-
-DM_TEST(dm_test_soc, DM_TESTF_SCAN_FDT);
struct udevice *back, *dev, *dev2;
ut_assertok(uclass_find_first_device(UCLASS_PANEL_BACKLIGHT, &back));
- ut_assertnonnull(back);
ut_asserteq(-ENOENT, uclass_find_device_by_phandle(UCLASS_REGULATOR,
back, "missing", &dev));
ut_assertok(uclass_find_device_by_phandle(UCLASS_REGULATOR, back,
"power-supply", &dev));
- ut_assertnonnull(dev);
ut_asserteq(0, device_active(dev));
ut_asserteq_str("ldo1", dev->name);
ut_assertok(uclass_get_device_by_phandle(UCLASS_REGULATOR, back,
/* check probe success */
ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus));
- ut_assertnonnull(bus);
/* check the child virtio-blk device is bound */
ut_assertok(device_find_first_child(bus, &dev));
- ut_assertnonnull(dev);
ut_assertok(strcmp(dev->name, "virtio-blk#0"));
/* check driver status */
/* check probe success */
ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus));
- ut_assertnonnull(bus);
/* check the child virtio-blk device is bound */
ut_assertok(device_find_first_child(bus, &dev));
- ut_assertnonnull(dev);
/*
* fake the virtio device probe by filling in uc_priv->vdev
* which is used by virtio_find_vqs/virtio_del_vqs.
*/
uc_priv = dev_get_uclass_priv(bus);
- ut_assertnonnull(uc_priv);
uc_priv->vdev = dev;
/* test virtio_xxx APIs */
/* check probe success */
ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus));
- ut_assertnonnull(bus);
/* check the child virtio-blk device is bound */
ut_assertok(device_find_first_child(bus, &dev));
- ut_assertnonnull(dev);
/* set driver status to VIRTIO_CONFIG_S_DRIVER_OK */
ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK));
TOOLS_DIR=build-sandbox_spl/tools
run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
-run_test "patman" ./tools/patman/patman test
+run_test "patman" ./tools/patman/patman --test
run_test "buildman" ./tools/buildman/buildman -t ${skip}
run_test "fdt" ./tools/dtoc/test_fdt -t
-Entry: blob-ext: Entry containing an externally built binary blob
------------------------------------------------------------------
-
-Note: This should not be used by itself. It is normally used as a parent
-class by other entry types.
-
-If the file providing this blob is missing, binman can optionally ignore it
-and produce a broken image with a warning.
-
-See 'blob' for Properties / Entry arguments.
-
-
-
Entry: blob-named-by-arg: A blob entry which gets its filename property from its subclass
-----------------------------------------------------------------------------------------
-Entry: fit: Entry containing a FIT
-----------------------------------
-
-This calls mkimage to create a FIT (U-Boot Flat Image Tree) based on the
-input provided.
-
-Nodes for the FIT should be written out in the binman configuration just as
-they would be in a file passed to mkimage.
-
-For example, this creates an image containing a FIT with U-Boot SPL:
-
- binman {
- fit {
- description = "Test FIT";
-
- images {
- kernel@1 {
- description = "SPL";
- os = "u-boot";
- type = "rkspi";
- arch = "arm";
- compression = "none";
- load = <0>;
- entry = <0>;
-
- u-boot-spl {
- };
- };
- };
- };
- };
-
-Properties:
- fit,external-offset: Indicates that the contents of the FIT are external
- and provides the external offset. This is passsed to mkimage via
- the -E and -p flags.
-
-
-
-
Entry: fmap: An entry which contains an Fmap section
----------------------------------------------------
-Entry: mkimage: Entry containing a binary produced by mkimage
--------------------------------------------------------------
-
-Properties / Entry arguments:
- - datafile: Filename for -d argument
- - args: Other arguments to pass
-
-The data passed to mkimage is collected from subnodes of the mkimage node,
-e.g.:
-
- mkimage {
- args = "-n test -T imximage";
-
- u-boot-spl {
- };
- };
-
-This calls mkimage to create an imximage with u-boot-spl.bin as the input
-file. The output from mkimage then becomes part of the image produced by
-binman.
-
-
-
Entry: powerpc-mpc85xx-bootpg-resetvec: PowerPC mpc85xx bootpg + resetvec code for U-Boot
-----------------------------------------------------------------------------------------
help='Add a path to the list of directories to use for input files')
build_parser.add_argument('-m', '--map', action='store_true',
default=False, help='Output a map file for each image')
- build_parser.add_argument('-M', '--allow-missing', action='store_true',
- default=False, help='Allow external blobs to be missing')
build_parser.add_argument('-O', '--outdir', type=str,
action='store', help='Path to directory to use for intermediate and '
'output files')
def ProcessImage(image, update_fdt, write_map, get_contents=True,
- allow_resize=True, allow_missing=False):
+ allow_resize=True):
"""Perform all steps for this image, including checking and # writing it.
This means that errors found with a later image will be reported after
the contents is already present
allow_resize: True to allow entries to change size (this does a re-pack
of the entries), False to raise an exception
- allow_missing: Allow blob_ext objects to be missing
-
- Returns:
- True if one or more external blobs are missing, False if all are present
"""
if get_contents:
- image.SetAllowMissing(allow_missing)
image.GetEntryContents()
image.GetEntryOffsets()
image.BuildImage()
if write_map:
image.WriteMap()
- missing_list = []
- image.CheckMissing(missing_list)
- if missing_list:
- tout.Warning("Image '%s' is missing external blobs and is non-functional: %s" %
- (image.name, ' '.join([e.name for e in missing_list])))
- return bool(missing_list)
def Binman(args):
images = PrepareImagesAndDtbs(dtb_fname, args.image,
args.update_fdt)
- missing = False
for image in images.values():
- missing |= ProcessImage(image, args.update_fdt, args.map,
- allow_missing=args.allow_missing)
+ ProcessImage(image, args.update_fdt, args.map)
# Write the updated FDTs to our output files
for dtb_item in state.GetAllFdts():
tools.WriteFile(dtb_item._fname, dtb_item.GetContents())
- if missing:
- tout.Warning("Some images are invalid")
finally:
tools.FinaliseOutputDir()
finally:
self.image_pos = None
self._expand_size = False
self.compress = 'none'
- self.missing = False
@staticmethod
def Lookup(node_path, etype):
elif self == entries[-1]:
return 'end'
return 'middle'
-
- def SetAllowMissing(self, allow_missing):
- """Set whether a section allows missing external blobs
-
- Args:
- allow_missing: True if allowed, False if not allowed
- """
- # This is meaningless for anything other than sections
- pass
-
- def CheckMissing(self, missing_list):
- """Check if any entries in this section have missing external blobs
-
- If there are missing blobs, the entries are added to the list
-
- Args:
- missing_list: List of Entry objects to be added to
- """
- if self.missing:
- missing_list.append(self)
data type (generating an error)
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
def ReadNode(self):
- super().ReadNode()
+ Entry.ReadNode(self)
self.return_invalid_entry = fdt_util.GetBool(self._node,
'return-invalid-entry')
self.return_unknown_contents = fdt_util.GetBool(self._node,
'return-contents-once')
self.bad_update_contents_twice = fdt_util.GetBool(self._node,
'bad-update-contents-twice')
- self.return_contents_later = fdt_util.GetBool(self._node,
- 'return-contents-later')
# Set to True when the entry is ready to process the FDT.
self.process_fdt_ready = False
def ObtainContents(self):
if self.return_unknown_contents or not self.return_contents:
return False
- if self.return_contents_later:
- self.return_contents_later = False
- return False
self.data = self.contents
self.contents_size = len(self.data)
if self.return_contents_once:
data.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
self._filename = fdt_util.GetString(self._node, 'filename', self.etype)
self.compress = fdt_util.GetString(self._node, 'compress', 'none')
global state
from binman import state
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def ObtainContents(self):
"""Get the device-tree from the list held by the 'state' module"""
self._filename = self.GetDefaultFilename()
self._pathname, _ = state.GetFdtContents(self.GetFdtEtype())
- return super().ReadBlobContents()
+ return Entry_blob.ReadBlobContents(self)
def ProcessContents(self):
"""Re-read the DTB contents so that we get any calculated properties"""
return {self.GetFdtEtype(): [self, fname]}
def WriteData(self, data, decomp=True):
- ok = super().WriteData(data, decomp)
+ ok = Entry_blob.WriteData(self, data, decomp)
# Update the state module, since it has the authoritative record of the
# device trees used. If we don't do this, then state.GetFdtContents()
+++ /dev/null
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (c) 2016 Google, Inc
-# Written by Simon Glass <sjg@chromium.org>
-#
-# Entry-type module for external blobs, not built by U-Boot
-#
-
-import os
-
-from binman.etype.blob import Entry_blob
-from dtoc import fdt_util
-from patman import tools
-from patman import tout
-
-class Entry_blob_ext(Entry_blob):
- """Entry containing an externally built binary blob
-
- Note: This should not be used by itself. It is normally used as a parent
- class by other entry types.
-
- If the file providing this blob is missing, binman can optionally ignore it
- and produce a broken image with a warning.
-
- See 'blob' for Properties / Entry arguments.
- """
- def __init__(self, section, etype, node):
- Entry_blob.__init__(self, section, etype, node)
- self.external = True
-
- def ObtainContents(self):
- self._filename = self.GetDefaultFilename()
- self._pathname = tools.GetInputFilename(self._filename,
- self.section.GetAllowMissing())
- # Allow the file to be missing
- if not self._pathname:
- self.SetContents(b'')
- self.missing = True
- return True
- return super().ObtainContents()
See cros_ec_rw for an example of this.
"""
def __init__(self, section, etype, node, blob_fname):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
self._filename, = self.GetEntryArgsOrProps(
[EntryArg('%s-path' % blob_fname, str)])
global state
from binman import state
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
self._cbfs_arg = fdt_util.GetString(node, 'cbfs-arch', 'x86')
self._cbfs_entries = OrderedDict()
self._ReadSubnodes()
return True
def _ReadSubnodes(self):
- """Read the subnodes to find out what should go in this CBFS"""
+ """Read the subnodes to find out what should go in this IFWI"""
for node in self._node.subnodes:
entry = Entry.Create(self, node)
entry.ReadNode()
Args:
image_pos: Position of this entry in the image
"""
- super().SetImagePos(image_pos)
+ Entry.SetImagePos(self, image_pos)
# Now update the entries with info from the CBFS entries
for entry in self._cbfs_entries.values():
entry.uncomp_size = cfile.memlen
def AddMissingProperties(self):
- super().AddMissingProperties()
+ Entry.AddMissingProperties(self)
for entry in self._cbfs_entries.values():
entry.AddMissingProperties()
if entry._cbfs_compress:
def SetCalculatedProperties(self):
"""Set the value of device-tree properties calculated by binman"""
- super().SetCalculatedProperties()
+ Entry.SetCalculatedProperties(self)
for entry in self._cbfs_entries.values():
state.SetInt(entry._node, 'offset', entry.offset)
state.SetInt(entry._node, 'size', entry.size)
def ListEntries(self, entries, indent):
"""Override this method to list all files in the section"""
- super().ListEntries(entries, indent)
+ Entry.ListEntries(self, entries, indent)
for entry in self._cbfs_entries.values():
entry.ListEntries(entries, indent + 1)
return self._cbfs_entries
def ReadData(self, decomp=True):
- data = super().ReadData(True)
+ data = Entry.ReadData(self, True)
return data
def ReadChildData(self, child, decomp=True):
if not self.reader:
- data = super().ReadData(True)
+ data = Entry.ReadData(self, True)
self.reader = cbfs_util.CbfsReader(data)
reader = self.reader
cfile = reader.files.get(child.name)
updating the EC on startup via software sync.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node, 'cros-ec-rw')
- self.external = True
+ Entry_blob_named_by_arg.__init__(self, section, etype, node,
+ 'cros-ec-rw')
from binman import state
from dtoc.fdt import Fdt
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
def _GetFdtmap(self):
"""Build an FDT map from the entries in the current image
global state
from binman import state
- super().__init__(section, etype, node)
+ Entry_section.__init__(self, section, etype, node)
self._pattern = fdt_util.GetString(self._node, 'pattern')
if not self._pattern:
self.Raise("Missing 'pattern' property")
byte value of a region.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
def ReadNode(self):
- super().ReadNode()
+ Entry.ReadNode(self)
if self.size is None:
self.Raise("'fill' entry must have a size property")
self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
+++ /dev/null
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (c) 2016 Google, Inc
-# Written by Simon Glass <sjg@chromium.org>
-#
-# Entry-type module for producing a FIT
-#
-
-from collections import defaultdict, OrderedDict
-import libfdt
-
-from binman.entry import Entry
-from dtoc import fdt_util
-from dtoc.fdt import Fdt
-from patman import tools
-
-class Entry_fit(Entry):
- """Entry containing a FIT
-
- This calls mkimage to create a FIT (U-Boot Flat Image Tree) based on the
- input provided.
-
- Nodes for the FIT should be written out in the binman configuration just as
- they would be in a file passed to mkimage.
-
- For example, this creates an image containing a FIT with U-Boot SPL:
-
- binman {
- fit {
- description = "Test FIT";
-
- images {
- kernel@1 {
- description = "SPL";
- os = "u-boot";
- type = "rkspi";
- arch = "arm";
- compression = "none";
- load = <0>;
- entry = <0>;
-
- u-boot-spl {
- };
- };
- };
- };
- };
-
- Properties:
- fit,external-offset: Indicates that the contents of the FIT are external
- and provides the external offset. This is passsed to mkimage via
- the -E and -p flags.
-
- """
- def __init__(self, section, etype, node):
- """
- Members:
- _fit: FIT file being built
- _fit_content: dict:
- key: relative path to entry Node (from the base of the FIT)
- value: List of Entry objects comprising the contents of this
- node
- """
- super().__init__(section, etype, node)
- self._fit = None
- self._fit_content = defaultdict(list)
- self._fit_props = {}
-
- def ReadNode(self):
- self._ReadSubnodes()
- super().ReadNode()
-
- def _ReadSubnodes(self):
- def _AddNode(base_node, depth, node):
- """Add a node to the FIT
-
- Args:
- base_node: Base Node of the FIT (with 'description' property)
- depth: Current node depth (0 is the base node)
- node: Current node to process
-
- There are two cases to deal with:
- - hash and signature nodes which become part of the FIT
- - binman entries which are used to define the 'data' for each
- image
- """
- for pname, prop in node.props.items():
- if pname.startswith('fit,'):
- self._fit_props[pname] = prop
- else:
- fsw.property(pname, prop.bytes)
-
- rel_path = node.path[len(base_node.path):]
- has_images = depth == 2 and rel_path.startswith('/images/')
- for subnode in node.subnodes:
- if has_images and not (subnode.name.startswith('hash') or
- subnode.name.startswith('signature')):
- # This is a content node. We collect all of these together
- # and put them in the 'data' property. They do not appear
- # in the FIT.
- entry = Entry.Create(self.section, subnode)
- entry.ReadNode()
- self._fit_content[rel_path].append(entry)
- else:
- with fsw.add_node(subnode.name):
- _AddNode(base_node, depth + 1, subnode)
-
- # Build a new tree with all nodes and properties starting from the
- # entry node
- fsw = libfdt.FdtSw()
- fsw.finish_reservemap()
- with fsw.add_node(''):
- _AddNode(self._node, 0, self._node)
- fdt = fsw.as_fdt()
-
- # Pack this new FDT and scan it so we can add the data later
- fdt.pack()
- self._fdt = Fdt.FromData(fdt.as_bytearray())
- self._fdt.Scan()
-
- def ObtainContents(self):
- """Obtain the contents of the FIT
-
- This adds the 'data' properties to the input ITB (Image-tree Binary)
- then runs mkimage to process it.
- """
- data = self._BuildInput(self._fdt)
- if data == False:
- return False
- uniq = self.GetUniqueName()
- input_fname = tools.GetOutputFilename('%s.itb' % uniq)
- output_fname = tools.GetOutputFilename('%s.fit' % uniq)
- tools.WriteFile(input_fname, data)
- tools.WriteFile(output_fname, data)
-
- args = []
- ext_offset = self._fit_props.get('fit,external-offset')
- if ext_offset is not None:
- args += ['-E', '-p', '%x' % fdt_util.fdt32_to_cpu(ext_offset.value)]
- tools.Run('mkimage', '-t', '-F', output_fname, *args)
-
- self.SetContents(tools.ReadFile(output_fname))
- return True
-
- def _BuildInput(self, fdt):
- """Finish the FIT by adding the 'data' properties to it
-
- Arguments:
- fdt: FIT to update
-
- Returns:
- New fdt contents (bytes)
- """
- for path, entries in self._fit_content.items():
- node = fdt.GetNode(path)
- data = b''
- for entry in entries:
- if not entry.ObtainContents():
- return False
- data += entry.GetData()
- node.AddData('data', data)
-
- fdt.Sync(auto_resize=True)
- data = fdt.GetContents()
- return data
the sub-entries are ignored.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
def _GetFmap(self):
"""Build an FMAP from the entries in the current image
README.chromium for how to obtain the required keys and tools.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
self.hardware_id, self.keydir, self.bmpblk = self.GetEntryArgsOrProps(
[EntryArg('hardware-id', str),
EntryArg('keydir', str),
first/last in the entry list.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
self.location = fdt_util.GetString(self._node, 'location')
def _GetHeader(self):
else:
offset = image_size - IMAGE_HEADER_LEN
offset += self.section.GetStartOffset()
- return super().Pack(offset)
+ return Entry.Pack(self, offset)
def ProcessContents(self):
"""Write an updated version of the FDT map to this entry
# Entry-type module for Intel Chip Microcode binary blob
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_cmc(Entry_blob_ext):
+class Entry_intel_cmc(Entry_blob):
"""Entry containing an Intel Chipset Micro Code (CMC) file
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
import struct
from binman.entry import Entry
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.etype.blob import Entry_blob
FD_SIGNATURE = struct.pack('<L', 0x0ff0a55a)
MAX_REGIONS = 5
self.limit = ((val & 0x0fff0000) >> 4) | 0xfff
self.size = self.limit - self.base + 1
-class Entry_intel_descriptor(Entry_blob_ext):
+class Entry_intel_descriptor(Entry_blob):
"""Intel flash descriptor block (4KB)
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
self._regions = []
def Pack(self, offset):
"""Put this entry at the start of the image"""
if self.offset is None:
offset = self.section.GetStartOffset()
- return super().Pack(offset)
+ return Entry_blob.Pack(self, offset)
def GetOffsets(self):
- info = {}
- if self.missing:
- # Return zero offsets so that these entries get placed somewhere
- if self.HasSibling('intel-me'):
- info['intel-me'] = [0, None]
- return info
offset = self.data.find(FD_SIGNATURE)
if offset == -1:
self.Raise('Cannot find Intel Flash Descriptor (FD) signature')
# Set the offset for ME (Management Engine) and IFWI (Integrated
# Firmware Image), for now, since the others are not used.
+ info = {}
if self.HasSibling('intel-me'):
info['intel-me'] = [self._regions[REGION_ME].base,
self._regions[REGION_ME].size]
import struct
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.etype.blob import Entry_blob
-class Entry_intel_fit(Entry_blob_ext):
+class Entry_intel_fit(Entry_blob):
"""Intel Firmware Image Table (FIT)
This entry contains a dummy FIT as required by recent Intel CPUs. The FIT
At present binman only supports a basic FIT with no microcode.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def ReadNode(self):
"""Force 16-byte alignment as required by FIT pointer"""
- super().ReadNode()
+ Entry_blob.ReadNode(self)
self.align = 16
def ObtainContents(self):
import struct
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.etype.blob import Entry_blob
-class Entry_intel_fit_ptr(Entry_blob_ext):
+class Entry_intel_fit_ptr(Entry_blob):
"""Intel Firmware Image Table (FIT) pointer
This entry contains a pointer to the FIT. It is required to be at address
0xffffffc0 in the image.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
if self.HasSibling('intel-fit') is False:
self.Raise("'intel-fit-ptr' section must have an 'intel-fit' sibling")
def Pack(self, offset):
"""Special pack method to set the offset to the right place"""
- return super().Pack(0xffffffc0)
+ return Entry_blob.Pack(self, 0xffffffc0)
# Entry-type module for Intel Firmware Support Package binary blob
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_fsp(Entry_blob_ext):
+class Entry_intel_fsp(Entry_blob):
"""Entry containing an Intel Firmware Support Package (FSP) file
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
# Entry-type module for Intel Firmware Support Package binary blob (M section)
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_fsp_m(Entry_blob_ext):
+class Entry_intel_fsp_m(Entry_blob):
"""Entry containing Intel Firmware Support Package (FSP) memory init
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
# Entry-type module for Intel Firmware Support Package binary blob (S section)
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_fsp_s(Entry_blob_ext):
+class Entry_intel_fsp_s(Entry_blob):
"""Entry containing Intel Firmware Support Package (FSP) silicon init
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
# Entry-type module for Intel Firmware Support Package binary blob (T section)
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_fsp_t(Entry_blob_ext):
+class Entry_intel_fsp_t(Entry_blob):
"""Entry containing Intel Firmware Support Package (FSP) temp ram init
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
from collections import OrderedDict
from binman.entry import Entry
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.etype.blob import Entry_blob
from dtoc import fdt_util
from patman import tools
-class Entry_intel_ifwi(Entry_blob_ext):
+class Entry_intel_ifwi(Entry_blob):
"""Entry containing an Intel Integrated Firmware Image (IFWI) file
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
self._convert_fit = fdt_util.GetBool(self._node, 'convert-fit')
self._ifwi_entries = OrderedDict()
def ReadNode(self):
self._ReadSubnodes()
- super().ReadNode()
+ Entry_blob.ReadNode(self)
def _BuildIfwi(self):
"""Build the contents of the IFWI and write it to the 'data' property"""
return True
def ObtainContents(self):
- """Get the contents for the IFWI
+ """Get the contects for the IFWI
Unfortunately we cannot create anything from scratch here, as Intel has
tools which create precursor binaries with lots of data and settings,
After that we delete the OBBP sub-partition and add each of the files
that we want in the IFWI file, one for each sub-entry of the IWFI node.
"""
- self._pathname = tools.GetInputFilename(self._filename,
- self.section.GetAllowMissing())
- # Allow the file to be missing
- if not self._pathname:
- self.SetContents(b'')
- self.missing = True
- return True
+ self._pathname = tools.GetInputFilename(self._filename)
for entry in self._ifwi_entries.values():
if not entry.ObtainContents():
return False
return self._BuildIfwi()
def ProcessContents(self):
- if self.missing:
- return True
orig_data = self.data
self._BuildIfwi()
same = orig_data == self.data
def WriteSymbols(self, section):
"""Write symbol values into binary files for access at run time"""
- if not self.missing:
- for entry in self._ifwi_entries.values():
- entry.WriteSymbols(self)
+ for entry in self._ifwi_entries.values():
+ entry.WriteSymbols(self)
# Entry-type module for Intel Management Engine binary blob
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_me(Entry_blob_ext):
+class Entry_intel_me(Entry_blob):
"""Entry containing an Intel Management Engine (ME) file
Properties / Entry arguments:
This file contains code used by the SoC that is required to make it work.
The Management Engine is like a background task that runs things that are
- not clearly documented, but may include keyboard, display and network
+ not clearly documented, but may include keyboard, deplay and network
access. For platform that use ME it is not possible to disable it. U-Boot
does not directly execute code in the ME binary.
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
# Entry-type module for Intel Memory Reference Code binary blob
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_mrc(Entry_blob_ext):
+class Entry_intel_mrc(Entry_blob):
"""Entry containing an Intel Memory Reference Code (MRC) file
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'mrc.bin'
# Entry-type module for Intel Memory Reference Code binary blob
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_refcode(Entry_blob_ext):
+class Entry_intel_refcode(Entry_blob):
"""Entry containing an Intel Reference Code file
Properties / Entry arguments:
See README.x86 for information about x86 binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'refcode.bin'
# Entry-type module for Intel Video BIOS Table binary blob
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_vbt(Entry_blob_ext):
+class Entry_intel_vbt(Entry_blob):
"""Entry containing an Intel Video BIOS Table (VBT) file
Properties / Entry arguments:
See README.x86 for information about Intel binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
# Entry-type module for x86 VGA ROM binary blob
#
-from binman.etype.blob_ext import Entry_blob_ext
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
-class Entry_intel_vga(Entry_blob_ext):
+class Entry_intel_vga(Entry_blob):
"""Entry containing an Intel Video Graphics Adaptor (VGA) file
Properties / Entry arguments:
See README.x86 for information about Intel binary blobs.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
+++ /dev/null
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (c) 2016 Google, Inc
-# Written by Simon Glass <sjg@chromium.org>
-#
-# Entry-type module for producing an image using mkimage
-#
-
-from collections import OrderedDict
-
-from binman.entry import Entry
-from dtoc import fdt_util
-from patman import tools
-
-class Entry_mkimage(Entry):
- """Entry containing a binary produced by mkimage
-
- Properties / Entry arguments:
- - datafile: Filename for -d argument
- - args: Other arguments to pass
-
- The data passed to mkimage is collected from subnodes of the mkimage node,
- e.g.:
-
- mkimage {
- args = "-n test -T imximage";
-
- u-boot-spl {
- };
- };
-
- This calls mkimage to create an imximage with u-boot-spl.bin as the input
- file. The output from mkimage then becomes part of the image produced by
- binman.
- """
- def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
- self._args = fdt_util.GetString(self._node, 'args').split(' ')
- self._mkimage_entries = OrderedDict()
- self._ReadSubnodes()
-
- def ObtainContents(self):
- data = b''
- for entry in self._mkimage_entries.values():
- # First get the input data and put it in a file. If not available,
- # try later.
- if not entry.ObtainContents():
- return False
- data += entry.GetData()
- uniq = self.GetUniqueName()
- input_fname = tools.GetOutputFilename('mkimage.%s' % uniq)
- tools.WriteFile(input_fname, data)
- output_fname = tools.GetOutputFilename('mkimage-out.%s' % uniq)
- tools.Run('mkimage', '-d', input_fname, *self._args, output_fname)
- self.SetContents(tools.ReadFile(output_fname))
- return True
-
- def _ReadSubnodes(self):
- """Read the subnodes to find out what should go in this image"""
- for node in self._node.subnodes:
- entry = Entry.Create(self, node)
- entry.ReadNode()
- self._mkimage_entries[entry.name] = entry
# Entry-type module for the PowerPC mpc85xx bootpg and resetvec code for U-Boot
#
+from binman.entry import Entry
from binman.etype.blob import Entry_blob
class Entry_powerpc_mpc85xx_bootpg_resetvec(Entry_blob):
Properties / Entry arguments:
- filename: Filename of u-boot-br.bin (default 'u-boot-br.bin')
- This entry is valid for PowerPC mpc85xx cpus. This entry holds
+ This enrty is valid for PowerPC mpc85xx cpus. This entry holds
'bootpg + resetvec' code for PowerPC mpc85xx CPUs which needs to be
placed at offset 'RESET_VECTOR_ADDRESS - 0xffc'.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'u-boot-br.bin'
name-prefix: Adds a prefix to the name of every entry in the section
when writing out the map
- Properties:
- _allow_missing: True if this section permits external blobs to be
- missing their contents. The second will produce an image but of
- course it will not work.
-
Since a section is also an entry, it inherits all the properies of entries
too.
"""
def __init__(self, section, etype, node, test=False):
if not test:
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
self._entries = OrderedDict()
self._pad_byte = 0
self._sort = False
self._skip_at_start = None
self._end_4gb = False
- self._allow_missing = False
- self.missing = False
def ReadNode(self):
"""Read properties from the image node"""
- super().ReadNode()
+ Entry.ReadNode(self)
self._pad_byte = fdt_util.GetInt(self._node, 'pad-byte', 0)
self._sort = fdt_util.GetBool(self._node, 'sort-by-offset')
self._end_4gb = fdt_util.GetBool(self._node, 'end-at-4gb')
a section containing a list of files. Process these entries so that
this information is added to the device tree.
"""
- super().ExpandEntries()
+ Entry.ExpandEntries(self)
for entry in self._entries.values():
entry.ExpandEntries()
def AddMissingProperties(self):
"""Add new properties to the device tree as needed for this entry"""
- super().AddMissingProperties()
+ Entry.AddMissingProperties(self)
for entry in self._entries.values():
entry.AddMissingProperties()
def ResetForPack(self):
"""Reset offset/size fields so that packing can be done again"""
- super().ResetForPack()
+ Entry.ResetForPack(self)
for entry in self._entries.values():
entry.ResetForPack()
def Pack(self, offset):
"""Pack all entries into the section"""
self._PackEntries()
- return super().Pack(offset)
+ return Entry.Pack(self, offset)
def _PackEntries(self):
"""Pack all entries into the image"""
"at %#x (%d)" %
(entry.offset, entry.offset, self._skip_at_start,
self._skip_at_start))
- if entry.offset < offset and entry.size:
+ if entry.offset < offset:
entry.Raise("Offset %#x (%d) overlaps with previous entry '%s' "
"ending at %#x (%d)" %
(entry.offset, entry.offset, prev_name, offset, offset))
entry.WriteSymbols(self)
def SetCalculatedProperties(self):
- super().SetCalculatedProperties()
+ Entry.SetCalculatedProperties(self)
for entry in self._entries.values():
entry.SetCalculatedProperties()
def SetImagePos(self, image_pos):
- super().SetImagePos(image_pos)
+ Entry.SetImagePos(self, image_pos)
for entry in self._entries.values():
entry.SetImagePos(image_pos + self.offset)
if not entry:
self._Raise("Unable to set offset/size for unknown entry '%s'" %
name)
- entry.SetOffsetSize(self._skip_at_start + offset if offset is not None
- else None, size)
+ entry.SetOffsetSize(self._skip_at_start + offset if offset else None,
+ size)
def GetEntryOffsets(self):
"""Handle entries that want to set the offset/size of other entries
def WriteChildData(self, child):
return True
-
- def SetAllowMissing(self, allow_missing):
- """Set whether a section allows missing external blobs
-
- Args:
- allow_missing: True if allowed, False if not allowed
- """
- self._allow_missing = allow_missing
- for entry in self._entries.values():
- entry.SetAllowMissing(allow_missing)
-
- def GetAllowMissing(self):
- """Get whether a section allows missing external blobs
-
- Returns:
- True if allowed, False if not allowed
- """
- return self._allow_missing
-
- def CheckMissing(self, missing_list):
- """Check if any entries in this section have missing external blobs
-
- If there are missing blobs, the entries are added to the list
-
- Args:
- missing_list: List of Entry objects to be added to
- """
- for entry in self._entries.values():
- entry.CheckMissing(missing_list)
by setting the size of the entry to something larger than the text.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
value = fdt_util.GetString(self._node, 'text')
if value:
value = tools.ToBytes(value)
in the binman README for more information.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'u-boot.bin'
binman to know which entries contain a device tree.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob_dtb.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'u-boot.dtb'
global state
from binman import state
- super().__init__(section, etype, node)
+ Entry_blob_dtb.__init__(self, section, etype, node)
self.ucode_data = b''
self.collate = False
self.ucode_offset = None
def ObtainContents(self):
# Call the base class just in case it does something important.
- super().ObtainContents()
+ Entry_blob_dtb.ObtainContents(self)
if self.ucode and not self.collate:
for node in self.ucode.subnodes:
data_prop = node.props.get('data')
relocated to any address for execution.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
self._strip = fdt_util.GetBool(self._node, 'strip')
def ReadBlobContents(self):
tools.WriteFile(out_fname, tools.ReadFile(self._pathname))
tools.Run('strip', out_fname)
self._pathname = out_fname
- super().ReadBlobContents()
+ Entry_blob.ReadBlobContents(self)
return True
def GetDefaultFilename(self):
applications.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'u-boot.img'
U-Boot and the device tree).
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'u-boot-nodtb.bin'
binman uses that to look up symbols to write into the SPL binary.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
self.elf_fname = 'spl/u-boot-spl'
def GetDefaultFilename(self):
binman uses that to look up the BSS address.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def ObtainContents(self):
fname = tools.GetInputFilename('spl/u-boot-spl')
to activate.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob_dtb.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'spl/u-boot-spl.dtb'
be relocated to any address for execution.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'spl/u-boot-spl'
both SPL and the device tree).
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'spl/u-boot-spl-nodtb.bin'
process.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_u_boot_with_ucode_ptr.__init__(self, section, etype, node)
self.elf_fname = 'spl/u-boot-spl'
def GetDefaultFilename(self):
binman uses that to look up symbols to write into the TPL binary.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
self.elf_fname = 'tpl/u-boot-tpl'
def GetDefaultFilename(self):
to activate.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob_dtb.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'tpl/u-boot-tpl.dtb'
process.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_u_boot_dtb_with_ucode.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'tpl/u-boot-tpl.dtb'
be relocated to any address for execution.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'tpl/u-boot-tpl'
process.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_u_boot_with_ucode_ptr.__init__(self, section, etype, node)
self.elf_fname = 'tpl/u-boot-tpl'
def GetDefaultFilename(self):
contents of this entry.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def ObtainContents(self):
# If the section does not need microcode, there is nothing to do
complicated. Otherwise it is the same as the u_boot entry.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
self.elf_fname = 'u-boot'
self.target_offset = None
and kernel are genuine.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry.__init__(self, section, etype, node)
self.content = fdt_util.GetPhandleList(self._node, 'content')
if not self.content:
self.Raise("Vblock must have a 'content' property")
For 64-bit U-Boot, the 'x86_reset16_spl' entry type is used instead.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'u-boot-x86-reset16.bin'
For 32-bit U-Boot, the 'x86_reset_spl' entry type is used instead.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'spl/u-boot-x86-reset16-spl.bin'
For 32-bit U-Boot, the 'x86_reset_tpl' entry type is used instead.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'tpl/u-boot-x86-reset16-tpl.bin'
For 64-bit U-Boot, the 'x86_start16_spl' entry type is used instead.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'u-boot-x86-start16.bin'
For 32-bit U-Boot, the 'x86-start16' entry type is used instead.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'spl/u-boot-x86-start16-spl.bin'
may be used instead.
"""
def __init__(self, section, etype, node):
- super().__init__(section, etype, node)
+ Entry_blob.__init__(self, section, etype, node)
def GetDefaultFilename(self):
return 'tpl/u-boot-x86-start16-tpl.bin'
#
# python -m unittest func_test.TestFunctional.testHelp
-import collections
import gzip
import hashlib
from optparse import OptionParser
import os
-import re
import shutil
import struct
import sys
tools.ReadFile(cls.ElfTestFile('u_boot_ucode_ptr')))
# Intel flash descriptor file
- cls._SetupDescriptor()
+ with open(cls.TestFile('descriptor.bin'), 'rb') as fd:
+ TestFunctional._MakeInputFile('descriptor.bin', fd.read())
shutil.copytree(cls.TestFile('files'),
os.path.join(cls._indir, 'files'))
def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False,
entry_args=None, images=None, use_real_dtb=False,
- verbosity=None, allow_missing=False):
+ verbosity=None):
"""Run binman with a given test file
Args:
if entry_args:
for arg, value in entry_args.items():
args.append('-a%s=%s' % (arg, value))
- if allow_missing:
- args.append('-M')
if images:
for image in images:
args += ['-i', image]
TestFunctional._MakeInputFile('tpl/u-boot-tpl',
tools.ReadFile(cls.ElfTestFile(src_fname)))
- @classmethod
- def _SetupDescriptor(cls):
- with open(cls.TestFile('descriptor.bin'), 'rb') as fd:
- TestFunctional._MakeInputFile('descriptor.bin', fd.read())
-
@classmethod
def TestFile(cls, fname):
return os.path.join(cls._binman_dir, 'test', fname)
def testPackX86RomMeNoDesc(self):
"""Test that an invalid Intel descriptor entry is detected"""
- try:
- TestFunctional._MakeInputFile('descriptor.bin', b'')
- with self.assertRaises(ValueError) as e:
- self._DoTestFile('031_x86_rom_me.dts')
- self.assertIn("Node '/binman/intel-descriptor': Cannot find Intel Flash Descriptor (FD) signature",
- str(e.exception))
- finally:
- self._SetupDescriptor()
+ TestFunctional._MakeInputFile('descriptor.bin', b'')
+ with self.assertRaises(ValueError) as e:
+ self._DoTestFile('031_x86_rom_me.dts')
+ self.assertIn("Node '/binman/intel-descriptor': Cannot find Intel Flash Descriptor (FD) signature",
+ str(e.exception))
def testPackX86RomBadDesc(self):
"""Test that the Intel requires a descriptor entry"""
with test_util.capture_sys_output() as (stdout, stderr):
control.ReplaceEntries(updated_fname, None, outdir, [])
self.assertIn("Skipping entry '/u-boot' from missing file",
- stderr.getvalue())
+ stdout.getvalue())
def testReplaceCmdMap(self):
"""Test replacing a file fron an image on the command line"""
data = self._DoReadFile('154_intel_fsp_t.dts')
self.assertEqual(FSP_T_DATA, data[:len(FSP_T_DATA)])
- def testMkimage(self):
- """Test using mkimage to build an image"""
- data = self._DoReadFile('156_mkimage.dts')
-
- # Just check that the data appears in the file somewhere
- self.assertIn(U_BOOT_SPL_DATA, data)
-
- def testExtblob(self):
- """Test an image with an external blob"""
- data = self._DoReadFile('157_blob_ext.dts')
- self.assertEqual(REFCODE_DATA, data)
-
- def testExtblobMissing(self):
- """Test an image with a missing external blob"""
- with self.assertRaises(ValueError) as e:
- self._DoReadFile('158_blob_ext_missing.dts')
- self.assertIn("Filename 'missing-file' not found in input path",
- str(e.exception))
-
- def testExtblobMissingOk(self):
- """Test an image with an missing external blob that is allowed"""
- with test_util.capture_sys_output() as (stdout, stderr):
- self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True)
- err = stderr.getvalue()
- self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
-
- def testExtblobMissingOkSect(self):
- """Test an image with an missing external blob that is allowed"""
- with test_util.capture_sys_output() as (stdout, stderr):
- self._DoTestFile('159_blob_ext_missing_sect.dts',
- allow_missing=True)
- err = stderr.getvalue()
- self.assertRegex(err, "Image 'main-section'.*missing.*: "
- "blob-ext blob-ext2")
-
- def testPackX86RomMeMissingDesc(self):
- """Test that an missing Intel descriptor entry is allowed"""
- pathname = os.path.join(self._indir, 'descriptor.bin')
- os.remove(pathname)
- with test_util.capture_sys_output() as (stdout, stderr):
- self._DoTestFile('031_x86_rom_me.dts', allow_missing=True)
- err = stderr.getvalue()
- self.assertRegex(err,
- "Image 'main-section'.*missing.*: intel-descriptor")
-
- def testPackX86RomMissingIfwi(self):
- """Test that an x86 ROM with Integrated Firmware Image can be created"""
- self._SetupIfwi('fitimage.bin')
- pathname = os.path.join(self._indir, 'fitimage.bin')
- os.remove(pathname)
- with test_util.capture_sys_output() as (stdout, stderr):
- self._DoTestFile('111_x86_rom_ifwi.dts', allow_missing=True)
- err = stderr.getvalue()
- self.assertRegex(err, "Image 'main-section'.*missing.*: intel-ifwi")
-
- def testPackOverlap(self):
- """Test that zero-size overlapping regions are ignored"""
- self._DoTestFile('160_pack_overlap_zero.dts')
-
- def testSimpleFit(self):
- """Test an image with a FIT inside"""
- data = self._DoReadFile('161_fit.dts')
- self.assertEqual(U_BOOT_DATA, data[:len(U_BOOT_DATA)])
- self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):])
- fit_data = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)]
-
- # The data should be inside the FIT
- dtb = fdt.Fdt.FromData(fit_data)
- dtb.Scan()
- fnode = dtb.GetNode('/images/kernel')
- self.assertIn('data', fnode.props)
-
- fname = os.path.join(self._indir, 'fit_data.fit')
- tools.WriteFile(fname, fit_data)
- out = tools.Run('dumpimage', '-l', fname)
-
- # Check a few features to make sure the plumbing works. We don't need
- # to test the operation of mkimage or dumpimage here. First convert the
- # output into a dict where the keys are the fields printed by dumpimage
- # and the values are a list of values for each field
- lines = out.splitlines()
-
- # Converts "Compression: gzip compressed" into two groups:
- # 'Compression' and 'gzip compressed'
- re_line = re.compile(r'^ *([^:]*)(?:: *(.*))?$')
- vals = collections.defaultdict(list)
- for line in lines:
- mat = re_line.match(line)
- vals[mat.group(1)].append(mat.group(2))
-
- self.assertEquals('FIT description: test-desc', lines[0])
- self.assertIn('Created:', lines[1])
- self.assertIn('Image 0 (kernel)', vals)
- self.assertIn('Hash value', vals)
- data_sizes = vals.get('Data Size')
- self.assertIsNotNone(data_sizes)
- self.assertEqual(2, len(data_sizes))
- # Format is "4 Bytes = 0.00 KiB = 0.00 MiB" so take the first word
- self.assertEqual(len(U_BOOT_DATA), int(data_sizes[0].split()[0]))
- self.assertEqual(len(U_BOOT_SPL_DTB_DATA), int(data_sizes[1].split()[0]))
-
- def testFitExternal(self):
- """Test an image with an FIT"""
- data = self._DoReadFile('162_fit_external.dts')
- fit_data = data[len(U_BOOT_DATA):-2] # _testing is 2 bytes
-
- # The data should be outside the FIT
- dtb = fdt.Fdt.FromData(fit_data)
- dtb.Scan()
- fnode = dtb.GetNode('/images/kernel')
- self.assertNotIn('data', fnode.props)
if __name__ == "__main__":
unittest.main()
we create a section manually.
"""
def __init__(self, name, node, copy_to_orig=True, test=False):
- super().__init__(None, 'section', node, test=test)
+ section.Entry_section.__init__(self, None, 'section', node, test=test)
self.copy_to_orig = copy_to_orig
self.name = 'main-section'
self.image_name = name
self.ReadNode()
def ReadNode(self):
- super().ReadNode()
+ section.Entry_section.ReadNode(self)
filename = fdt_util.GetString(self._node, 'filename')
if filename:
self._filename = filename
def PackEntries(self):
"""Pack all entries into the image"""
- super().Pack(0)
+ section.Entry_section.Pack(self, 0)
def SetImagePos(self):
# This first section in the image so it starts at 0
- super().SetImagePos(0)
+ section.Entry_section.SetImagePos(self, 0)
def ProcessEntryContents(self):
"""Call the ProcessContents() method for each entry
def WriteSymbols(self):
"""Write symbol values into binary files for access at run time"""
- super().WriteSymbols(self)
+ section.Entry_section.WriteSymbols(self, self)
def BuildImage(self):
"""Write the image to a file"""
with open(fname, 'w') as fd:
print('%8s %8s %8s %s' % ('ImagePos', 'Offset', 'Size', 'Name'),
file=fd)
- super().WriteMap(fd, 0)
+ section.Entry_section.WriteMap(self, fd, 0)
return fname
def BuildEntryList(self):
# Bring in the libfdt module
sys.path.insert(2, 'scripts/dtc/pylibfdt')
-sys.path.insert(2, os.path.join(our_path, '../../scripts/dtc/pylibfdt'))
sys.path.insert(2, os.path.join(our_path,
'../../build-sandbox_spl/scripts/dtc/pylibfdt'))
for item in glob_list
if include_testing or '_testing' not in item])
-def RunTestCoverage(toolpath):
+def RunTestCoverage():
"""Run the tests and check that we get 100% coverage"""
glob_list = GetEntryModules(False)
all_set = set([os.path.splitext(os.path.basename(item))[0]
for item in glob_list if '_testing' not in item])
- extra_args = ''
- if toolpath:
- for path in toolpath:
- extra_args += ' --toolpath %s' % path
test_util.RunTestCoverage('tools/binman/binman', None,
['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*'],
- args.build_dir, all_set, extra_args or None)
+ args.build_dir, all_set)
def RunBinman(args):
"""Main entry point to binman once arguments are parsed
if not args.debug:
sys.tracebacklimit = 0
- # Provide a default toolpath in the hope of finding a mkimage built from
- # current source
- if not args.toolpath:
- args.toolpath = ['./tools', 'build-sandbox/tools']
-
if args.cmd == 'test':
if args.test_coverage:
- RunTestCoverage(args.toolpath)
+ RunTestCoverage()
else:
ret_code = RunTests(args.debug, args.verbosity, args.processes,
args.test_preserve_dirs, args.tests,
try:
ret_code = control.Binman(args)
except Exception as e:
- print('binman: %s' % e, file=sys.stderr)
+ print('binman: %s' % e)
if args.debug:
print()
traceback.print_exc()
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- binman {
- size = <0x80>;
-
- mkimage {
- args = "-n test -T script";
-
- u-boot-spl {
- };
-
- _testing {
- return-contents-later;
- };
- };
- };
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- binman {
- blob-ext {
- filename = "refcode.bin";
- };
- };
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- binman {
- size = <0x80>;
-
- blob-ext {
- filename = "missing-file";
- };
- };
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- binman {
- size = <0x80>;
-
- section {
- blob-ext {
- filename = "missing-file";
- };
- };
-
- blob-ext2 {
- type = "blob-ext";
- filename = "missing-file2";
- };
- };
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- binman {
- u-boot {
- };
-
- fill {
- size = <0>;
- offset = <3>;
- };
- };
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- binman {
- u-boot {
- };
- fit {
- description = "test-desc";
- #address-cells = <1>;
-
- images {
- kernel {
- description = "Vanilla Linux kernel";
- type = "kernel";
- arch = "ppc";
- os = "linux";
- compression = "gzip";
- load = <00000000>;
- entry = <00000000>;
- hash-1 {
- algo = "crc32";
- };
- hash-2 {
- algo = "sha1";
- };
- u-boot {
- };
- };
- fdt-1 {
- description = "Flattened Device Tree blob";
- type = "flat_dt";
- arch = "ppc";
- compression = "none";
- hash-1 {
- algo = "crc32";
- };
- hash-2 {
- algo = "sha1";
- };
- u-boot-spl-dtb {
- };
- };
- };
-
- configurations {
- default = "conf-1";
- conf-1 {
- description = "Boot Linux kernel with FDT blob";
- kernel = "kernel";
- fdt = "fdt-1";
- };
- };
- };
- u-boot-nodtb {
- };
- };
-};
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0+
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- binman {
- u-boot {
- };
- fit {
- fit,external-offset = <0>;
- description = "test-desc";
- #address-cells = <1>;
-
- images {
- kernel {
- description = "Vanilla Linux kernel";
- type = "kernel";
- arch = "ppc";
- os = "linux";
- compression = "gzip";
- load = <00000000>;
- entry = <00000000>;
- hash-1 {
- algo = "crc32";
- };
- hash-2 {
- algo = "sha1";
- };
- u-boot {
- };
- };
- fdt-1 {
- description = "Flattened Device Tree blob";
- type = "flat_dt";
- arch = "ppc";
- compression = "none";
- hash-1 {
- algo = "crc32";
- };
- hash-2 {
- algo = "sha1";
- };
- _testing {
- return-contents-later;
- };
- };
- };
-
- configurations {
- default = "conf-1";
- conf-1 {
- description = "Boot Linux kernel with FDT blob";
- kernel = "kernel";
- fdt = "fdt-1";
- };
- };
- };
- u-boot-nodtb {
- };
- };
-};
if auto_resize:
while fdt_obj.setprop(node.Offset(), self.name, self.bytes,
(libfdt.NOSPACE,)) == -libfdt.NOSPACE:
- fdt_obj.resize(fdt_obj.totalsize() + 1024 +
- len(self.bytes))
+ fdt_obj.resize(fdt_obj.totalsize() + 1024)
fdt_obj.setprop(node.Offset(), self.name, self.bytes)
else:
fdt_obj.setprop(node.Offset(), self.name, self.bytes)
val = val.encode('utf-8')
self._CheckProp(prop_name).props[prop_name].SetData(val + b'\0')
- def AddData(self, prop_name, val):
- """Add a new property to a node
-
- The device tree is marked dirty so that the value will be written to
- the blob on the next sync.
-
- Args:
- prop_name: Name of property to add
- val: Bytes value of property
- """
- self.props[prop_name] = Prop(self, None, prop_name, val)
-
def AddString(self, prop_name, val):
"""Add a new string property to a node
"""
if sys.version_info[0] >= 3: # pragma: no cover
val = bytes(val, 'utf-8')
- self.AddData(prop_name, val + b'\0')
+ self.props[prop_name] = Prop(self, None, prop_name, val + b'\0')
def AddSubnode(self, name):
"""Add a new subnode to the node
self.node.SetData('empty', b'123')
self.assertEqual(b'123', prop.bytes)
- # Trying adding a lot of data at once
- self.node.AddData('data', tools.GetBytes(65, 20000))
- self.dtb.Sync(auto_resize=True)
-
def testFromData(self):
dtb2 = fdt.Fdt.FromData(self.dtb.GetContents())
self.assertEqual(dtb2.GetContents(), self.dtb.GetContents())
}
/* for first image creation, add a timestamp at offset 0 i.e., root */
- if (params->datafile || params->reset_timestamp) {
+ if (params->datafile) {
time_t time = imagetool_get_source_date(params->cmdname,
sbuf.st_mtime);
ret = fit_set_timestamp(ptr, 0, time);
unsigned int external_offset; /* Add padding to external data */
int bl_len; /* Block length in byte for external data */
const char *engine_id; /* Engine to use for signing */
- bool reset_timestamp; /* Reset the timestamp on an existing image */
};
/*
int opt;
while ((opt = getopt(argc, argv,
- "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qstT:vVx")) != -1) {
+ "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) {
switch (opt) {
case 'a':
params.addr = strtoull(optarg, &ptr, 16);
case 's':
params.skipcpy = 1;
break;
- case 't':
- params.reset_timestamp = 1;
- break;
case 'T':
if (strcmp(optarg, "list") == 0) {
show_valid_options(IH_TYPE);
def CheckPatch(fname, verbose=False, show_types=False):
"""Run checkpatch.pl on a file.
- Args:
- fname: Filename to check
- verbose: True to print out every line of the checkpatch output as it is
- parsed
- show_types: Tell checkpatch to show the type (number) of each message
-
Returns:
namedtuple containing:
ok: False=failure, True=ok
# Copyright (c) 2011 The Chromium OS Authors.
#
-import collections
import re
# Separates a tag: at the beginning of the subject from the rest of it
notes: List of lines in the commit (not series) notes
change_id: the Change-Id: tag that was stripped from this commit
and can be used to generate the Message-Id.
- rtags: Response tags (e.g. Reviewed-by) collected by the commit, dict:
- key: rtag type (e.g. 'Reviewed-by')
- value: Set of people who gave that rtag, each a name/email string
"""
def __init__(self, hash):
self.hash = hash
self.signoff_set = set()
self.notes = []
self.change_id = None
- self.rtags = collections.defaultdict(set)
def AddChange(self, version, info):
"""Add a new change line to the change list for a version.
return False
self.signoff_set.add(signoff)
return True
-
- def AddRtag(self, rtag_type, who):
- """Add a response tag to a commit
-
- Args:
- key: rtag type (e.g. 'Reviewed-by')
- who: Person who gave that rtag, e.g. 'Fred Bloggs <fred@bloggs.org>'
- """
- self.rtags[rtag_type].add(who)
+++ /dev/null
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Copyright 2020 Google LLC
-#
-"""Handles the main control logic of patman
-
-This module provides various functions called by the main program to implement
-the features of patman.
-"""
-
-import os
-import sys
-
-from patman import checkpatch
-from patman import gitutil
-from patman import patchstream
-from patman import terminal
-
-def setup():
- """Do required setup before doing anything"""
- gitutil.Setup()
-
-def prepare_patches(col, branch, count, start, end, ignore_binary):
- """Figure out what patches to generate, then generate them
-
- The patch files are written to the current directory, e.g. 0001_xxx.patch
- 0002_yyy.patch
-
- Args:
- col (terminal.Color): Colour output object
- branch (str): Branch to create patches from (None = current)
- count (int): Number of patches to produce, or -1 to produce patches for
- the current branch back to the upstream commit
- start (int): Start partch to use (0=first / top of branch)
- end (int): End patch to use (0=last one in series, 1=one before that,
- etc.)
- ignore_binary (bool): Don't generate patches for binary files
-
- Returns:
- Tuple:
- Series object for this series (set of patches)
- Filename of the cover letter as a string (None if none)
- patch_files: List of patch filenames, each a string, e.g.
- ['0001_xxx.patch', '0002_yyy.patch']
- """
- if count == -1:
- # Work out how many patches to send if we can
- count = (gitutil.CountCommitsToBranch(branch) - start)
-
- if not count:
- str = 'No commits found to process - please use -c flag, or run:\n' \
- ' git branch --set-upstream-to remote/branch'
- sys.exit(col.Color(col.RED, str))
-
- # Read the metadata from the commits
- to_do = count - end
- series = patchstream.GetMetaData(branch, start, to_do)
- cover_fname, patch_files = gitutil.CreatePatches(
- branch, start, to_do, ignore_binary, series)
-
- # Fix up the patch files to our liking, and insert the cover letter
- patchstream.FixPatches(series, patch_files)
- if cover_fname and series.get('cover'):
- patchstream.InsertCoverLetter(cover_fname, series, to_do)
- return series, cover_fname, patch_files
-
-def check_patches(series, patch_files, run_checkpatch, verbose):
- """Run some checks on a set of patches
-
- This santiy-checks the patman tags like Series-version and runs the patches
- through checkpatch
-
- Args:
- series (Series): Series object for this series (set of patches)
- patch_files (list): List of patch filenames, each a string, e.g.
- ['0001_xxx.patch', '0002_yyy.patch']
- run_checkpatch (bool): True to run checkpatch.pl
- verbose (bool): True to print out every line of the checkpatch output as
- it is parsed
-
- Returns:
- bool: True if the patches had no errors, False if they did
- """
- # Do a few checks on the series
- series.DoChecks()
-
- # Check the patches, and run them through 'git am' just to be sure
- if run_checkpatch:
- ok = checkpatch.CheckPatches(verbose, patch_files)
- else:
- ok = True
- return ok
-
-
-def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
- ignore_bad_tags, add_maintainers, limit, dry_run, in_reply_to,
- thread, smtp_server):
- """Email patches to the recipients
-
- This emails out the patches and cover letter using 'git send-email'. Each
- patch is copied to recipients identified by the patch tag and output from
- the get_maintainer.pl script. The cover letter is copied to all recipients
- of any patch.
-
- To make this work a CC file is created holding the recipients for each patch
- and the cover letter. See the main program 'cc_cmd' for this logic.
-
- Args:
- col (terminal.Color): Colour output object
- series (Series): Series object for this series (set of patches)
- cover_fname (str): Filename of the cover letter as a string (None if
- none)
- patch_files (list): List of patch filenames, each a string, e.g.
- ['0001_xxx.patch', '0002_yyy.patch']
- process_tags (bool): True to process subject tags in each patch, e.g.
- for 'dm: spi: Add SPI support' this would be 'dm' and 'spi'. The
- tags are looked up in the configured sendemail.aliasesfile and also
- in ~/.patman (see README)
- its_a_go (bool): True if we are going to actually send the patches,
- False if the patches have errors and will not be sent unless
- @ignore_errors
- ignore_bad_tags (bool): True to just print a warning for unknown tags,
- False to halt with an error
- add_maintainers (bool): Run the get_maintainer.pl script for each patch
- limit (int): Limit on the number of people that can be cc'd on a single
- patch or the cover letter (None if no limit)
- dry_run (bool): Don't actually email the patches, just print out what
- would be sent
- in_reply_to (str): If not None we'll pass this to git as --in-reply-to.
- Should be a message ID that this is in reply to.
- thread (bool): True to add --thread to git send-email (make all patches
- reply to cover-letter or first patch in series)
- smtp_server (str): SMTP server to use to send patches (None for default)
- """
- cc_file = series.MakeCcFile(process_tags, cover_fname, not ignore_bad_tags,
- add_maintainers, limit)
-
- # Email the patches out (giving the user time to check / cancel)
- cmd = ''
- if its_a_go:
- cmd = gitutil.EmailPatches(
- series, cover_fname, patch_files, dry_run, not ignore_bad_tags,
- cc_file, in_reply_to=in_reply_to, thread=thread,
- smtp_server=smtp_server)
- else:
- print(col.Color(col.RED, "Not sending emails due to errors/warnings"))
-
- # For a dry run, just show our actions as a sanity check
- if dry_run:
- series.ShowActions(patch_files, cmd, process_tags)
- if not its_a_go:
- print(col.Color(col.RED, "Email would not be sent"))
-
- os.remove(cc_file)
-
-def send(args):
- """Create, check and send patches by email
-
- Args:
- args (argparse.Namespace): Arguments to patman
- """
- setup()
- col = terminal.Color()
- series, cover_fname, patch_files = prepare_patches(
- col, args.branch, args.count, args.start, args.end,
- args.ignore_binary)
- ok = check_patches(series, patch_files, args.check_patch,
- args.verbose)
-
- ok = ok and gitutil.CheckSuppressCCConfig()
-
- its_a_go = ok or args.ignore_errors
- if its_a_go:
- email_patches(
- col, series, cover_fname, patch_files, args.process_tags,
- its_a_go, args.ignore_bad_tags, args.add_maintainers,
- args.limit, args.dry_run, args.in_reply_to, args.thread,
- args.smtp_server)
from io import StringIO
-from patman import control
from patman import gitutil
from patman import patchstream
from patman import settings
-from patman import terminal
from patman import tools
-from patman.test_util import capture_sys_output
-
-try:
- import pygit2
- HAVE_PYGIT2= True
-except ModuleNotFoundError:
- HAVE_PYGIT2 = False
@contextlib.contextmanager
def capture():
+ import sys
oldout,olderr = sys.stdout, sys.stderr
try:
out=[StringIO(), StringIO()]
class TestFunctional(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix='patman.')
- self.gitdir = os.path.join(self.tmpdir, 'git')
- self.repo = None
def tearDown(self):
shutil.rmtree(self.tmpdir)
if expected:
expected = expected.splitlines()
self.assertEqual(expected, lines[start:(start+len(expected))])
-
- def make_commit_with_file(self, subject, body, fname, text):
- """Create a file and add it to the git repo with a new commit
-
- Args:
- subject (str): Subject for the commit
- body (str): Body text of the commit
- fname (str): Filename of file to create
- text (str): Text to put into the file
- """
- path = os.path.join(self.gitdir, fname)
- tools.WriteFile(path, text, binary=False)
- index = self.repo.index
- index.add(fname)
- author = pygit2.Signature('Test user', 'test@email.com')
- committer = author
- tree = index.write_tree()
- message = subject + '\n' + body
- self.repo.create_commit('HEAD', author, committer, message, tree,
- [self.repo.head.target])
-
- def make_git_tree(self):
- """Make a simple git tree suitable for testing
-
- It has three branches:
- 'base' has two commits: PCI, main
- 'first' has base as upstream and two more commits: I2C, SPI
- 'second' has base as upstream and three more: video, serial, bootm
-
- Returns:
- pygit2 repository
- """
- repo = pygit2.init_repository(self.gitdir)
- self.repo = repo
- new_tree = repo.TreeBuilder().write()
-
- author = pygit2.Signature('Test user', 'test@email.com')
- committer = author
- commit = repo.create_commit('HEAD', author, committer,
- 'Created master', new_tree, [])
-
- self.make_commit_with_file('Initial commit', '''
-Add a README
-
-''', 'README', '''This is the README file
-describing this project
-in very little detail''')
-
- self.make_commit_with_file('pci: PCI implementation', '''
-Here is a basic PCI implementation
-
-''', 'pci.c', '''This is a file
-it has some contents
-and some more things''')
- self.make_commit_with_file('main: Main program', '''
-Hello here is the second commit.
-''', 'main.c', '''This is the main file
-there is very little here
-but we can always add more later
-if we want to
-
-Series-to: u-boot
-Series-cc: Barry Crump <bcrump@whataroa.nz>
-''')
- base_target = repo.revparse_single('HEAD')
- self.make_commit_with_file('i2c: I2C things', '''
-This has some stuff to do with I2C
-''', 'i2c.c', '''And this is the file contents
-with some I2C-related things in it''')
- self.make_commit_with_file('spi: SPI fixes', '''
-SPI needs some fixes
-and here they are
-''', 'spi.c', '''Some fixes for SPI in this
-file to make SPI work
-better than before''')
- first_target = repo.revparse_single('HEAD')
-
- target = repo.revparse_single('HEAD~2')
- repo.reset(target.oid, pygit2.GIT_CHECKOUT_FORCE)
- self.make_commit_with_file('video: Some video improvements', '''
-Fix up the video so that
-it looks more purple. Purple is
-a very nice colour.
-''', 'video.c', '''More purple here
-Purple and purple
-Even more purple
-Could not be any more purple''')
- self.make_commit_with_file('serial: Add a serial driver', '''
-Here is the serial driver
-for my chip.
-
-Cover-letter:
-Series for my board
-This series implements support
-for my glorious board.
-END
-''', 'serial.c', '''The code for the
-serial driver is here''')
- self.make_commit_with_file('bootm: Make it boot', '''
-This makes my board boot
-with a fix to the bootm
-command
-''', 'bootm.c', '''Fix up the bootm
-command to make the code as
-complicated as possible''')
- second_target = repo.revparse_single('HEAD')
-
- repo.branches.local.create('first', first_target)
- repo.config.set_multivar('branch.first.remote', '', '.')
- repo.config.set_multivar('branch.first.merge', '', 'refs/heads/base')
-
- repo.branches.local.create('second', second_target)
- repo.config.set_multivar('branch.second.remote', '', '.')
- repo.config.set_multivar('branch.second.merge', '', 'refs/heads/base')
-
- repo.branches.local.create('base', base_target)
- return repo
-
- @unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
- def testBranch(self):
- """Test creating patches from a branch"""
- repo = self.make_git_tree()
- target = repo.lookup_reference('refs/heads/first')
- self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
- control.setup()
- try:
- orig_dir = os.getcwd()
- os.chdir(self.gitdir)
-
- # Check that it can detect the current branch
- self.assertEqual(2, gitutil.CountCommitsToBranch(None))
- col = terminal.Color()
- with capture_sys_output() as _:
- _, cover_fname, patch_files = control.prepare_patches(
- col, branch=None, count=-1, start=0, end=0,
- ignore_binary=False)
- self.assertIsNone(cover_fname)
- self.assertEqual(2, len(patch_files))
-
- # Check that it can detect a different branch
- self.assertEqual(3, gitutil.CountCommitsToBranch('second'))
- with capture_sys_output() as _:
- _, cover_fname, patch_files = control.prepare_patches(
- col, branch='second', count=-1, start=0, end=0,
- ignore_binary=False)
- self.assertIsNotNone(cover_fname)
- self.assertEqual(3, len(patch_files))
-
- # Check that it can skip patches at the end
- with capture_sys_output() as _:
- _, cover_fname, patch_files = control.prepare_patches(
- col, branch='second', count=-1, start=0, end=1,
- ignore_binary=False)
- self.assertIsNotNone(cover_fname)
- self.assertEqual(2, len(patch_files))
- finally:
- os.chdir(orig_dir)
cmd.append('--')
return cmd
-def CountCommitsToBranch(branch):
+def CountCommitsToBranch():
"""Returns number of commits between HEAD and the tracking branch.
This looks back to the tracking branch and works out the number of commits
since then.
- Args:
- branch: Branch to count from (None for current branch)
-
Return:
Number of patches that exist on top of the branch
"""
- if branch:
- us, msg = GetUpstream('.git', branch)
- rev_range = '%s..%s' % (us, branch)
- else:
- rev_range = '@{upstream}..'
- pipe = [LogCmd(rev_range, oneline=True), ['wc', '-l']]
+ pipe = [LogCmd('@{upstream}..', oneline=True),
+ ['wc', '-l']]
stdout = command.RunPipe(pipe, capture=True, oneline=True).stdout
patch_count = int(stdout)
return patch_count
if result.return_code != 0:
raise OSError('git fetch: %s' % result.stderr)
-def CreatePatches(branch, start, count, ignore_binary, series):
+def CreatePatches(start, count, ignore_binary, series):
"""Create a series of patches from the top of the current branch.
The patch files are written to the current directory using
git format-patch.
Args:
- branch: Branch to create patches from (None for current branch)
start: Commit to start from: 0=HEAD, 1=next one, etc.
count: number of commits to include
- ignore_binary: Don't generate patches for binary files
- series: Series object for this series (set of patches)
Return:
- Filename of cover letter (None if none)
+ Filename of cover letter
List of filenames of patch files
"""
if series.get('version'):
prefix = series.GetPatchPrefix()
if prefix:
cmd += ['--subject-prefix=%s' % prefix]
- brname = branch or 'HEAD'
- cmd += ['%s~%d..%s~%d' % (brname, start + count, brname, start)]
+ cmd += ['HEAD~%d..HEAD~%d' % (start + count, start)]
stdout = command.RunList(cmd)
files = stdout.splitlines()
return ['%s %s%s%s' % (tag, quote, email, quote) for email in result]
return result
-def CheckSuppressCCConfig():
- """Check if sendemail.suppresscc is configured correctly.
-
- Returns:
- True if the option is configured correctly, False otherwise.
- """
- suppresscc = command.OutputOneLine('git', 'config', 'sendemail.suppresscc',
- raise_on_error=False)
-
- # Other settings should be fine.
- if suppresscc == 'all' or suppresscc == 'cccmd':
- col = terminal.Color()
-
- print((col.Color(col.RED, "error") +
- ": git config sendemail.suppresscc set to %s\n" % (suppresscc)) +
- " patman needs --cc-cmd to be run to set the cc list.\n" +
- " Please run:\n" +
- " git config --unset sendemail.suppresscc\n" +
- " Or read the man page:\n" +
- " git send-email --help\n" +
- " and set an option that runs --cc-cmd\n")
- return False
-
- return True
-
def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname,
self_only=False, alias=None, in_reply_to=None, thread=False,
smtp_server=None):
"""See README for more information"""
-from argparse import ArgumentParser
+from optparse import OptionParser
import os
import re
import sys
-import traceback
import unittest
if __name__ == "__main__":
sys.path.append(os.path.join(our_path, '..'))
# Our modules
+from patman import checkpatch
from patman import command
-from patman import control
from patman import gitutil
+from patman import patchstream
from patman import project
from patman import settings
from patman import terminal
-from patman import test_util
from patman import test_checkpatch
-def AddCommonArgs(parser):
- parser.add_argument('-b', '--branch', type=str,
- help="Branch to process (by default, the current branch)")
- parser.add_argument('-c', '--count', dest='count', type=int,
- default=-1, help='Automatically create patches from top n commits')
- parser.add_argument('-e', '--end', type=int, default=0,
- help='Commits to skip at end of patch list')
- parser.add_argument('-D', '--debug', action='store_true',
- help='Enabling debugging (provides a full traceback on error)')
- parser.add_argument('-s', '--start', dest='start', type=int,
- default=0, help='Commit to start creating patches from (0 = HEAD)')
-
-epilog = '''Create patches from commits in a branch, check them and email them
-as specified by tags you place in the commits. Use -n to do a dry run first.'''
-
-parser = ArgumentParser(epilog=epilog)
-subparsers = parser.add_subparsers(dest='cmd')
-send = subparsers.add_parser('send')
-send.add_argument('-H', '--full-help', action='store_true', dest='full_help',
+
+parser = OptionParser()
+parser.add_option('-H', '--full-help', action='store_true', dest='full_help',
default=False, help='Display the README file')
-send.add_argument('-i', '--ignore-errors', action='store_true',
+parser.add_option('-c', '--count', dest='count', type='int',
+ default=-1, help='Automatically create patches from top n commits')
+parser.add_option('-i', '--ignore-errors', action='store_true',
dest='ignore_errors', default=False,
help='Send patches email even if patch errors are found')
-send.add_argument('-l', '--limit-cc', dest='limit', type=int, default=None,
- help='Limit the cc list to LIMIT entries [default: %(default)s]')
-send.add_argument('-m', '--no-maintainers', action='store_false',
+parser.add_option('-l', '--limit-cc', dest='limit', type='int',
+ default=None, help='Limit the cc list to LIMIT entries [default: %default]')
+parser.add_option('-m', '--no-maintainers', action='store_false',
dest='add_maintainers', default=True,
help="Don't cc the file maintainers automatically")
-send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
+parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
default=False, help="Do a dry run (create but don't email patches)")
-send.add_argument('-p', '--project', default=project.DetectProject(),
+parser.add_option('-p', '--project', default=project.DetectProject(),
help="Project name; affects default option values and "
- "aliases [default: %(default)s]")
-send.add_argument('-r', '--in-reply-to', type=str, action='store',
+ "aliases [default: %default]")
+parser.add_option('-r', '--in-reply-to', type='string', action='store',
help="Message ID that this series is in reply to")
-send.add_argument('-t', '--ignore-bad-tags', action='store_true',
+parser.add_option('-s', '--start', dest='start', type='int',
+ default=0, help='Commit to start creating patches from (0 = HEAD)')
+parser.add_option('-t', '--ignore-bad-tags', action='store_true',
default=False, help='Ignore bad tags / aliases')
-send.add_argument('-v', '--verbose', action='store_true', dest='verbose',
+parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
default=False, help='Verbose output of errors and warnings')
-send.add_argument('-T', '--thread', action='store_true', dest='thread',
+parser.add_option('-T', '--thread', action='store_true', dest='thread',
default=False, help='Create patches as a single thread')
-send.add_argument('--cc-cmd', dest='cc_cmd', type=str, action='store',
+parser.add_option('--cc-cmd', dest='cc_cmd', type='string', action='store',
default=None, help='Output cc list for patch file (used by git)')
-send.add_argument('--no-binary', action='store_true', dest='ignore_binary',
+parser.add_option('--no-binary', action='store_true', dest='ignore_binary',
default=False,
help="Do not output contents of changes in binary files")
-send.add_argument('--no-check', action='store_false', dest='check_patch',
+parser.add_option('--no-check', action='store_false', dest='check_patch',
default=True,
help="Don't check for patch compliance")
-send.add_argument('--no-tags', action='store_false', dest='process_tags',
+parser.add_option('--no-tags', action='store_false', dest='process_tags',
default=True, help="Don't process subject tags as aliases")
-send.add_argument('--smtp-server', type=str,
+parser.add_option('--smtp-server', type='str',
help="Specify the SMTP server to 'git send-email'")
-AddCommonArgs(send)
+parser.add_option('--test', action='store_true', dest='test',
+ default=False, help='run tests')
+
+parser.usage += """
-send.add_argument('patchfiles', nargs='*')
+Create patches from commits in a branch, check them and email them as
+specified by tags you place in the commits. Use -n to do a dry run first."""
-test_parser = subparsers.add_parser('test', help='Run tests')
-AddCommonArgs(test_parser)
# Parse options twice: first to get the project and second to handle
# defaults properly (which depends on project).
-argv = sys.argv[1:]
-if len(argv) < 1 or argv[0].startswith('-'):
- argv = ['send'] + argv
-args = parser.parse_args(argv)
-if hasattr(args, 'project'):
- settings.Setup(gitutil, send, args.project, '')
- args = parser.parse_args(argv)
+(options, args) = parser.parse_args()
+settings.Setup(gitutil, parser, options.project, '')
+(options, args) = parser.parse_args()
if __name__ != "__main__":
pass
-if not args.debug:
- sys.tracebacklimit = 0
-
# Run our meagre tests
-if args.cmd == 'test':
+elif options.test:
import doctest
from patman import func_test
suite = doctest.DocTestSuite(module)
suite.run(result)
- sys.exit(test_util.ReportResult('patman', None, result))
+ # TODO: Surely we can just 'print' result?
+ print(result)
+ for test, err in result.errors:
+ print(err)
+ for test, err in result.failures:
+ print(err)
+
+# Called from git with a patch filename as argument
+# Printout a list of additional CC recipients for this patch
+elif options.cc_cmd:
+ fd = open(options.cc_cmd, 'r')
+ re_line = re.compile('(\S*) (.*)')
+ for line in fd.readlines():
+ match = re_line.match(line)
+ if match and match.group(1) == args[0]:
+ for cc in match.group(2).split('\0'):
+ cc = cc.strip()
+ if cc:
+ print(cc)
+ fd.close()
+
+elif options.full_help:
+ pager = os.getenv('PAGER')
+ if not pager:
+ pager = 'more'
+ fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
+ 'README')
+ command.Run(pager, fname)
# Process commits, produce patches files, check them, email them
-elif args.cmd == 'send':
- # Called from git with a patch filename as argument
- # Printout a list of additional CC recipients for this patch
- if args.cc_cmd:
- fd = open(args.cc_cmd, 'r')
- re_line = re.compile('(\S*) (.*)')
- for line in fd.readlines():
- match = re_line.match(line)
- if match and match.group(1) == args.patchfiles[0]:
- for cc in match.group(2).split('\0'):
- cc = cc.strip()
- if cc:
- print(cc)
- fd.close()
-
- elif args.full_help:
- pager = os.getenv('PAGER')
- if not pager:
- pager = 'more'
- fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
- 'README')
- command.Run(pager, fname)
-
+else:
+ gitutil.Setup()
+
+ if options.count == -1:
+ # Work out how many patches to send if we can
+ options.count = gitutil.CountCommitsToBranch() - options.start
+
+ col = terminal.Color()
+ if not options.count:
+ str = 'No commits found to process - please use -c flag'
+ sys.exit(col.Color(col.RED, str))
+
+ # Read the metadata from the commits
+ if options.count:
+ series = patchstream.GetMetaData(options.start, options.count)
+ cover_fname, args = gitutil.CreatePatches(options.start, options.count,
+ options.ignore_binary, series)
+
+ # Fix up the patch files to our liking, and insert the cover letter
+ patchstream.FixPatches(series, args)
+ if cover_fname and series.get('cover'):
+ patchstream.InsertCoverLetter(cover_fname, series, options.count)
+
+ # Do a few checks on the series
+ series.DoChecks()
+
+ # Check the patches, and run them through 'git am' just to be sure
+ if options.check_patch:
+ ok = checkpatch.CheckPatches(options.verbose, args)
else:
- control.send(args)
+ ok = True
+
+ cc_file = series.MakeCcFile(options.process_tags, cover_fname,
+ not options.ignore_bad_tags,
+ options.add_maintainers, options.limit)
+
+ # Email the patches out (giving the user time to check / cancel)
+ cmd = ''
+ its_a_go = ok or options.ignore_errors
+ if its_a_go:
+ cmd = gitutil.EmailPatches(series, cover_fname, args,
+ options.dry_run, not options.ignore_bad_tags, cc_file,
+ in_reply_to=options.in_reply_to, thread=options.thread,
+ smtp_server=options.smtp_server)
+ else:
+ print(col.Color(col.RED, "Not sending emails due to errors/warnings"))
+
+ # For a dry run, just show our actions as a sanity check
+ if options.dry_run:
+ series.ShowActions(args, cmd, options.process_tags)
+ if not its_a_go:
+ print(col.Color(col.RED, "Email would not be sent"))
+
+ os.remove(cc_file)
re_commit_tag = re.compile('^Commit-([a-z-]*): *(.*)')
# Commit tags that we want to collect and keep
-re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc|Fixes): (.*)')
+re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc): (.*)')
# The start of a new commit in the git log
re_commit = re.compile('^commit ([0-9a-f]*)$')
self.in_section = 'commit-' + name
self.skip_blank = False
- def AddCommitRtag(self, rtag_type, who):
- """Add a response tag to the current commit
-
- Args:
- key: rtag type (e.g. 'Reviewed-by')
- who: Person who gave that rtag, e.g. 'Fred Bloggs <fred@bloggs.org>'
- """
- self.commit.AddRtag(rtag_type, who)
-
def CloseCommit(self):
"""Save the current commit into our commit list, and reset our state"""
if self.commit and self.is_log:
else:
self.section.append(line)
- # If we are not in a section, it is an unexpected END
- elif line == 'END':
- raise ValueError("'END' wihout section")
-
# Detect the commit subject
elif not is_blank and self.state == STATE_PATCH_SUBJECT:
self.commit.subject = line
elif name == 'changes':
self.in_change = 'Commit'
self.change_version = self.ParseVersion(value, line)
- else:
- self.warn.append('Line %d: Ignoring Commit-%s' %
- (self.linenum, name))
# Detect the start of a new commit
elif commit_match:
# Detect tags in the commit message
elif tag_match:
- rtag_type, who = tag_match.groups()
- self.AddCommitRtag(rtag_type, who)
# Remove Tested-by self, since few will take much notice
- if (rtag_type == 'Tested-by' and
- who.find(os.getenv('USER') + '@') != -1):
+ if (tag_match.group(1) == 'Tested-by' and
+ tag_match.group(2).find(os.getenv('USER') + '@') != -1):
self.warn.append("Ignoring %s" % line)
- elif rtag_type == 'Patch-cc':
- self.commit.AddCc(who.split(','))
+ elif tag_match.group(1) == 'Patch-cc':
+ self.commit.AddCc(tag_match.group(2).split(','))
else:
out = [line]
ps.Finalize()
return series
-def GetMetaData(branch, start, count):
+def GetMetaData(start, count):
"""Reads out patch series metadata from the commits
This does a 'git log' on the relevant commits and pulls out the tags we
are interested in.
Args:
- branch: Branch to use (None for current branch)
- start: Commit to start from: 0=branch HEAD, 1=next one, etc.
+ start: Commit to start from: 0=HEAD, 1=next one, etc.
count: Number of commits to list
"""
- return GetMetaDataForList('%s~%d' % (branch if branch else 'HEAD', start),
- None, count)
+ return GetMetaDataForList('HEAD~%d' % start, None, count)
def GetMetaDataForTest(text):
"""Process metadata from a file containing a git log. Used for tests
add_maintainers: Either:
True/False to call the get_maintainers to CC maintainers
List of maintainers to include (for testing)
- limit: Limit the length of the Cc list (None if no limit)
+ limit: Limit the length of the Cc list
Return:
Filename of temp file created
"""
config: An instance of _ProjectConfigParser that we will query
for settings.
"""
- defaults = parser.parse_known_args()[0]
- defaults = vars(defaults)
+ defaults = parser.get_default_values()
for name, val in config.items('settings'):
- if name in defaults:
- default_val = defaults[name]
+ if hasattr(defaults, name):
+ default_val = getattr(defaults, name)
if isinstance(default_val, bool):
val = config.getboolean('settings', name)
elif isinstance(default_val, int):
val = config.getint('settings', name)
- defaults[name] = val
+ parser.set_default(name, val)
else:
print("WARNING: Unknown setting %s" % name)
- parser.set_defaults(**defaults)
def _ReadAliasFile(fname):
"""Read in the U-Boot git alias file if it exists.
return out
-def Print(text='', newline=True, colour=None, limit_to_line=False, bright=True):
+def Print(text='', newline=True, colour=None, limit_to_line=False):
"""Handle a line of output to the terminal.
In test mode this is recorded in a list. Otherwise it is output to the
else:
if colour:
col = Color()
- text = col.Color(colour, text, bright=bright)
+ text = col.Color(colour, text)
if newline:
print(text)
last_print_len = None
use_concurrent = True
try:
- from concurrencytest.concurrencytest import ConcurrentTestSuite
- from concurrencytest.concurrencytest import fork_for_tests
+ from concurrencytest import ConcurrentTestSuite, fork_for_tests
except:
use_concurrent = False
-def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None,
- extra_args=None):
+def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
"""Run tests and check that we get 100% coverage
Args:
calculation
build_dir: Build directory, used to locate libfdt.py
required: List of modules which must be in the coverage report
- extra_args (str): Extra arguments to pass to the tool before the -t/test
- arg
Raises:
ValueError if the code coverage is not 100%
glob_list = []
glob_list += exclude_list
glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*']
- glob_list += ['*concurrencytest*']
- test_cmd = 'test' if 'binman' in prog or 'patman' in prog else '-t'
+ test_cmd = 'test' if 'binman' in prog else '-t'
prefix = ''
if build_dir:
prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir
cmd = ('%spython3-coverage run '
- '--omit "%s" %s %s %s -P1' % (prefix, ','.join(glob_list),
- prog, extra_args or '', test_cmd))
+ '--omit "%s" %s %s -P1' % (prefix, ','.join(glob_list),
+ prog, test_cmd))
os.system(cmd)
stdout = command.Output('python3-coverage', 'report')
lines = stdout.splitlines()
for test, err in result.failures:
print(err, result.failures)
if result.skipped:
- print('%d %s test%s SKIPPED:' % (len(result.skipped), toolname,
- 's' if len(result.skipped) > 1 else ''))
+ print('%d binman test%s SKIPPED:' %
+ (len(result.skipped), 's' if len(result.skipped) > 1 else ''))
for skip_info in result.skipped:
print('%s: %s' % (skip_info[0], skip_info[1]))
if result.errors or result.failures:
- print('%s tests FAILED' % toolname)
+ print('binman tests FAILED')
return 1
return 0
indir = dirname
tout.Debug("Using input directories %s" % indir)
-def GetInputFilename(fname, allow_missing=False):
+def GetInputFilename(fname):
"""Return a filename for use as input.
Args:
fname: Filename to use for new file
- allow_missing: True if the filename can be missing
Returns:
- The full path of the filename, within the input directory, or
- None on error
+ The full path of the filename, within the input directory
"""
if not indir or fname[:1] == '/':
return fname
if os.path.exists(pathname):
return pathname
- if allow_missing:
- return None
raise ValueError("Filename '%s' not found in input path (%s) (cwd='%s')" %
(fname, ','.join(indir), os.getcwd()))
#(fname, len(data), len(data)))
return data
-def WriteFile(fname, data, binary=True):
+def WriteFile(fname, data):
"""Write data into a file.
Args:
"""
#self._out.Info("Write file '%s' size %d (%#0x)" %
#(fname, len(data), len(data)))
- with open(Filename(fname), binary and 'wb' or 'w') as fd:
+ with open(Filename(fname), 'wb') as fd:
fd.write(data)
def GetBytes(byte, size):
ClearProgress()
if color:
msg = _color.Color(color, msg)
- if level < NOTICE:
- print(msg, file=sys.stderr)
- else:
- print(msg)
+ print(msg)
def DoOutput(level, msg):
"""Output a message to the terminal.
# TODO(sjg): Move this into Chromite libraries when we have them
stdout_is_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
- stderr_is_tty = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()
def Uninit():
ClearProgress()