Merge git://git.denx.de/u-boot-dm

This commit is contained in:
Tom Rini 2018-01-21 20:13:29 -05:00
commit 485c13c753
12 changed files with 212 additions and 136 deletions

View file

@ -6,21 +6,21 @@
#
obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o clk_fixed_rate.o
obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
obj-$(CONFIG_SANDBOX) += clk_sandbox.o
obj-$(CONFIG_SANDBOX) += clk_sandbox_test.o
obj-$(CONFIG_MACH_PIC32) += clk_pic32.o
obj-$(CONFIG_CLK_RENESAS) += renesas/
obj-$(CONFIG_CLK_ZYNQ) += clk_zynq.o
obj-$(CONFIG_CLK_ZYNQMP) += clk_zynqmp.o
obj-y += tegra/
obj-$(CONFIG_CLK_UNIPHIER) += uniphier/
obj-$(CONFIG_CLK_EXYNOS) += exynos/
obj-$(CONFIG_ARCH_ASPEED) += aspeed/
obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
obj-$(CONFIG_CLK_AT91) += at91/
obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o
obj-$(CONFIG_CLK_BOSTON) += clk_boston.o
obj-$(CONFIG_CLK_EXYNOS) += exynos/
obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o
obj-$(CONFIG_ARCH_ASPEED) += aspeed/
obj-$(CONFIG_CLK_RENESAS) += renesas/
obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o
obj-$(CONFIG_CLK_UNIPHIER) += uniphier/
obj-$(CONFIG_CLK_ZYNQ) += clk_zynq.o
obj-$(CONFIG_CLK_ZYNQMP) += clk_zynqmp.o
obj-$(CONFIG_MACH_PIC32) += clk_pic32.o
obj-$(CONFIG_SANDBOX) += clk_sandbox.o
obj-$(CONFIG_SANDBOX) += clk_sandbox_test.o
obj-$(CONFIG_STM32H7) += clk_stm32h7.o

View file

@ -13,11 +13,9 @@
#include <dt-structs.h>
#include <errno.h>
DECLARE_GLOBAL_DATA_PTR;
static inline struct clk_ops *clk_dev_ops(struct udevice *dev)
static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)
{
return (struct clk_ops *)dev->driver->ops;
return (const struct clk_ops *)dev->driver->ops;
}
#if CONFIG_IS_ENABLED(OF_CONTROL)
@ -60,7 +58,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
int ret;
struct ofnode_phandle_args args;
struct udevice *dev_clk;
struct clk_ops *ops;
const struct clk_ops *ops;
debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
@ -68,7 +66,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
clk->dev = NULL;
ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0,
index, &args);
index, &args);
if (ret) {
debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n",
__func__, ret);
@ -142,7 +140,7 @@ int clk_release_all(struct clk *clk, int count)
int clk_request(struct udevice *dev, struct clk *clk)
{
struct clk_ops *ops = clk_dev_ops(dev);
const struct clk_ops *ops = clk_dev_ops(dev);
debug("%s(dev=%p, clk=%p)\n", __func__, dev, clk);
@ -156,7 +154,7 @@ int clk_request(struct udevice *dev, struct clk *clk)
int clk_free(struct clk *clk)
{
struct clk_ops *ops = clk_dev_ops(clk->dev);
const struct clk_ops *ops = clk_dev_ops(clk->dev);
debug("%s(clk=%p)\n", __func__, clk);
@ -168,7 +166,7 @@ int clk_free(struct clk *clk)
ulong clk_get_rate(struct clk *clk)
{
struct clk_ops *ops = clk_dev_ops(clk->dev);
const struct clk_ops *ops = clk_dev_ops(clk->dev);
debug("%s(clk=%p)\n", __func__, clk);
@ -180,7 +178,7 @@ ulong clk_get_rate(struct clk *clk)
ulong clk_set_rate(struct clk *clk, ulong rate)
{
struct clk_ops *ops = clk_dev_ops(clk->dev);
const struct clk_ops *ops = clk_dev_ops(clk->dev);
debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate);
@ -192,7 +190,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
int clk_enable(struct clk *clk)
{
struct clk_ops *ops = clk_dev_ops(clk->dev);
const struct clk_ops *ops = clk_dev_ops(clk->dev);
debug("%s(clk=%p)\n", __func__, clk);
@ -204,7 +202,7 @@ int clk_enable(struct clk *clk)
int clk_disable(struct clk *clk)
{
struct clk_ops *ops = clk_dev_ops(clk->dev);
const struct clk_ops *ops = clk_dev_ops(clk->dev);
debug("%s(clk=%p)\n", __func__, clk);

View file

@ -8,8 +8,6 @@
#include <clk-uclass.h>
#include <dm.h>
DECLARE_GLOBAL_DATA_PTR;
struct clk_fixed_rate {
unsigned long fixed_rate;
};
@ -31,8 +29,8 @@ const struct clk_ops clk_fixed_rate_ops = {
static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
{
#if !CONFIG_IS_ENABLED(OF_PLATDATA)
to_clk_fixed_rate(dev)->fixed_rate = dev_read_u32_default(dev,
"clock-frequency", 0);
to_clk_fixed_rate(dev)->fixed_rate =
dev_read_u32_default(dev, "clock-frequency", 0);
#endif
return 0;

View file

@ -17,6 +17,7 @@
#include <dm/device.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/of_access.h>
#include <dm/pinctrl.h>
#include <dm/platdata.h>
#include <dm/read.h>
@ -703,8 +704,12 @@ int device_set_name(struct udevice *dev, const char *name)
bool device_is_compatible(struct udevice *dev, const char *compat)
{
const void *fdt = gd->fdt_blob;
ofnode node = dev_ofnode(dev);
return !fdt_node_check_compatible(fdt, dev_of_offset(dev), compat);
if (ofnode_is_np(node))
return of_device_is_compatible(ofnode_to_np(node), compat, NULL, NULL);
else
return !fdt_node_check_compatible(fdt, ofnode_to_offset(node), compat);
}
bool of_machine_is_compatible(const char *compat)

View file

@ -205,8 +205,13 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
&flags);
if (!prop_val)
return FDT_ADDR_T_NONE;
na = of_n_addr_cells(ofnode_to_np(node));
return of_read_number(prop_val, na);
if (IS_ENABLED(CONFIG_OF_TRANSLATE)) {
return of_translate_address(ofnode_to_np(node), prop_val);
} else {
na = of_n_addr_cells(ofnode_to_np(node));
return of_read_number(prop_val, na);
}
} else {
return fdt_get_base_address(gd->fdt_blob,
ofnode_to_offset(node));
@ -296,7 +301,8 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
int ret;
ret = of_parse_phandle_with_args(ofnode_to_np(node),
list_name, cells_name, index, &args);
list_name, cells_name, index,
&args);
if (ret)
return ret;
ofnode_from_of_phandle_args(&args, out_args);
@ -305,8 +311,9 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
int ret;
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob,
ofnode_to_offset(node), list_name, cells_name,
cell_count, index, &args);
ofnode_to_offset(node),
list_name, cells_name,
cell_count, index, &args);
if (ret)
return ret;
ofnode_from_fdtdec_phandle_args(&args, out_args);
@ -534,10 +541,10 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
addr->phys_mid = fdt32_to_cpu(cell[1]);
addr->phys_lo = fdt32_to_cpu(cell[1]);
break;
} else {
cell += (FDT_PCI_ADDR_CELLS +
FDT_PCI_SIZE_CELLS);
}
cell += (FDT_PCI_ADDR_CELLS +
FDT_PCI_SIZE_CELLS);
}
if (i == num) {
@ -546,10 +553,10 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
}
return 0;
} else {
ret = -EINVAL;
}
ret = -EINVAL;
fail:
debug("(not found)\n");
return ret;
@ -642,3 +649,11 @@ int ofnode_read_resource_byname(ofnode node, const char *name,
return ofnode_read_resource(node, index, res);
}
u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr)
{
if (ofnode_is_np(node))
return of_translate_address(ofnode_to_np(node), in_addr);
else
return fdt_translate_address(gd->fdt_blob, ofnode_to_offset(node), in_addr);
}

View file

@ -66,7 +66,7 @@ void *dev_read_addr_ptr(struct udevice *dev)
}
fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property,
fdt_size_t *sizep)
fdt_size_t *sizep)
{
return ofnode_get_addr_size(dev_ofnode(dev), property, sizep);
}
@ -77,7 +77,7 @@ const char *dev_read_name(struct udevice *dev)
}
int dev_read_stringlist_search(struct udevice *dev, const char *property,
const char *string)
const char *string)
{
return ofnode_stringlist_search(dev_ofnode(dev), property, string);
}
@ -94,9 +94,8 @@ int dev_read_string_count(struct udevice *dev, const char *propname)
}
int dev_read_phandle_with_args(struct udevice *dev, const char *list_name,
const char *cells_name, int cell_count,
int index,
struct ofnode_phandle_args *out_args)
const char *cells_name, int cell_count,
int index, struct ofnode_phandle_args *out_args)
{
return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name,
cells_name, cell_count, index,
@ -196,3 +195,8 @@ int dev_read_resource_byname(struct udevice *dev, const char *name,
{
return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
}
u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
{
return ofnode_translate_address(dev_ofnode(dev), in_addr);
}

View file

@ -652,4 +652,17 @@ int ofnode_read_resource_byname(ofnode node, const char *name,
ofnode_valid(node); \
node = ofnode_next_subnode(node))
/**
* ofnode_translate_address() - Tranlate a device-tree address
*
* Translate an address from the device-tree into a CPU physical address. This
* function walks up the tree and applies the various bus mappings along the
* way.
*
* @ofnode: Device tree node giving the context in which to translate the
* address
* @in_addr: pointer to the address to translate
* @return the translated address; OF_BAD_ADDR on error
*/
u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr);
#endif

View file

@ -137,6 +137,12 @@ struct pinctrl_ops {
/**
* Generic pin configuration paramters
*
* enum pin_config_param - possible pin configuration parameters
* @PIN_CONFIG_BIAS_BUS_HOLD: the pin will be set to weakly latch so that it
* weakly drives the last value on a tristate bus, also known as a "bus
* holder", "bus keeper" or "repeater". This allows another device on the
* bus to change the value by driving the bus high or low and switching to
* tristate. The argument is ignored.
* @PIN_CONFIG_BIAS_DISABLE: disable any pin bias on the pin, a
* transition from say pull-up to pull-down implies that you disable
* pull-up in the process, this setting disables all biasing.
@ -146,14 +152,6 @@ struct pinctrl_ops {
* if for example some other pin is going to drive the signal connected
* to it for a while. Pins used for input are usually always high
* impedance.
* @PIN_CONFIG_BIAS_BUS_HOLD: the pin will be set to weakly latch so that it
* weakly drives the last value on a tristate bus, also known as a "bus
* holder", "bus keeper" or "repeater". This allows another device on the
* bus to change the value by driving the bus high or low and switching to
* tristate. The argument is ignored.
* @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high
* impedance to VDD). If the argument is != 0 pull-up is enabled,
* if it is 0, pull-up is total, i.e. the pin is connected to VDD.
* @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high
* impedance to GROUND). If the argument is != 0 pull-down is enabled,
* if it is 0, pull-down is total, i.e. the pin is connected to GROUND.
@ -165,10 +163,9 @@ struct pinctrl_ops {
* If the argument is != 0 pull up/down is enabled, if it is 0, the
* configuration is ignored. The proper way to disable it is to use
* @PIN_CONFIG_BIAS_DISABLE.
* @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and
* low, this is the most typical case and is typically achieved with two
* active transistors on the output. Setting this config will enable
* push-pull mode, the argument is ignored.
* @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high
* impedance to VDD). If the argument is != 0 pull-up is enabled,
* if it is 0, pull-up is total, i.e. the pin is connected to VDD.
* @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open
* collector) which means it is usually wired with other output ports
* which are then pulled up with an external resistor. Setting this
@ -176,59 +173,82 @@ struct pinctrl_ops {
* @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source
* (open emitter). Setting this config will enable open source mode, the
* argument is ignored.
* @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and
* low, this is the most typical case and is typically achieved with two
* active transistors on the output. Setting this config will enable
* push-pull mode, the argument is ignored.
* @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current
* passed as argument. The argument is in mA.
* @PIN_CONFIG_INPUT_ENABLE: enable the pin's input. Note that this does not
* affect the pin's ability to drive output. 1 enables input, 0 disables
* input.
* @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin.
* If the argument != 0, schmitt-trigger mode is enabled. If it's 0,
* schmitt-trigger mode is disabled.
* @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in
* schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis,
* the threshold value is given on a custom format as argument when
* setting pins to this mode.
* @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode,
* which means it will wait for signals to settle when reading inputs. The
* argument gives the debounce time in usecs. Setting the
* argument to zero turns debouncing off.
* @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power
* supplies, the argument to this parameter (on a custom format) tells
* the driver which alternative power source to use.
* @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to
* this parameter (on a custom format) tells the driver which alternative
* slew rate to use.
* @PIN_CONFIG_INPUT_ENABLE: enable the pin's input. Note that this does not
* affect the pin's ability to drive output. 1 enables input, 0 disables
* input.
* @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in
* schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis,
* the threshold value is given on a custom format as argument when
* setting pins to this mode.
* @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin.
* If the argument != 0, schmitt-trigger mode is enabled. If it's 0,
* schmitt-trigger mode is disabled.
* @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power
* operation, if several modes of operation are supported these can be
* passed in the argument on a custom form, else just use argument 1
* to indicate low power mode, argument 0 turns low power mode off.
* @PIN_CONFIG_OUTPUT: this will configure the pin as an output. Use argument
* 1 to indicate high level, argument 0 to indicate low level. (Please
* see Documentation/pinctrl.txt, section "GPIO mode pitfalls" for a
* discussion around this parameter.)
* @PIN_CONFIG_OUTPUT_ENABLE: this will enable the pin's output mode
* without driving a value there. For most platforms this reduces to
* enable the output buffers and then let the pin controller current
* configuration (eg. the currently selected mux function) drive values on
* the line. Use argument 1 to enable output mode, argument 0 to disable
* it.
* @PIN_CONFIG_OUTPUT: this will configure the pin as an output and drive a
* value on the line. Use argument 1 to indicate high level, argument 0 to
* indicate low level. (Please see Documentation/driver-api/pinctl.rst,
* section "GPIO mode pitfalls" for a discussion around this parameter.)
* @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power
* supplies, the argument to this parameter (on a custom format) tells
* the driver which alternative power source to use.
* @PIN_CONFIG_SLEEP_HARDWARE_STATE: indicate this is sleep related state.
* @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to
* this parameter (on a custom format) tells the driver which alternative
* slew rate to use.
* @PIN_CONFIG_SKEW_DELAY: if the pin has programmable skew rate (on inputs)
* or latch delay (on outputs) this parameter (in a custom format)
* specifies the clock skew or latch delay. It typically controls how
* many double inverters are put in front of the line.
* @PIN_CONFIG_END: this is the last enumerator for pin configurations, if
* you need to pass in custom configurations to the pin controller, use
* PIN_CONFIG_END+1 as the base offset.
* @PIN_CONFIG_MAX: this is the maximum configuration value that can be
* presented using the packed format.
*/
#define PIN_CONFIG_BIAS_DISABLE 0
#define PIN_CONFIG_BIAS_HIGH_IMPEDANCE 1
#define PIN_CONFIG_BIAS_BUS_HOLD 2
#define PIN_CONFIG_BIAS_PULL_UP 3
#define PIN_CONFIG_BIAS_PULL_DOWN 4
#define PIN_CONFIG_BIAS_PULL_PIN_DEFAULT 5
#define PIN_CONFIG_DRIVE_PUSH_PULL 6
#define PIN_CONFIG_DRIVE_OPEN_DRAIN 7
#define PIN_CONFIG_DRIVE_OPEN_SOURCE 8
#define PIN_CONFIG_DRIVE_STRENGTH 9
#define PIN_CONFIG_INPUT_ENABLE 10
#define PIN_CONFIG_INPUT_SCHMITT_ENABLE 11
#define PIN_CONFIG_INPUT_SCHMITT 12
#define PIN_CONFIG_INPUT_DEBOUNCE 13
#define PIN_CONFIG_POWER_SOURCE 14
#define PIN_CONFIG_SLEW_RATE 15
#define PIN_CONFIG_LOW_POWER_MODE 16
#define PIN_CONFIG_OUTPUT 17
#define PIN_CONFIG_END 0x7FFF
enum pin_config_param {
PIN_CONFIG_BIAS_BUS_HOLD,
PIN_CONFIG_BIAS_DISABLE,
PIN_CONFIG_BIAS_HIGH_IMPEDANCE,
PIN_CONFIG_BIAS_PULL_DOWN,
PIN_CONFIG_BIAS_PULL_PIN_DEFAULT,
PIN_CONFIG_BIAS_PULL_UP,
PIN_CONFIG_DRIVE_OPEN_DRAIN,
PIN_CONFIG_DRIVE_OPEN_SOURCE,
PIN_CONFIG_DRIVE_PUSH_PULL,
PIN_CONFIG_DRIVE_STRENGTH,
PIN_CONFIG_INPUT_DEBOUNCE,
PIN_CONFIG_INPUT_ENABLE,
PIN_CONFIG_INPUT_SCHMITT,
PIN_CONFIG_INPUT_SCHMITT_ENABLE,
PIN_CONFIG_LOW_POWER_MODE,
PIN_CONFIG_OUTPUT_ENABLE,
PIN_CONFIG_OUTPUT,
PIN_CONFIG_POWER_SOURCE,
PIN_CONFIG_SLEEP_HARDWARE_STATE,
PIN_CONFIG_SLEW_RATE,
PIN_CONFIG_SKEW_DELAY,
PIN_CONFIG_END = 0x7F,
PIN_CONFIG_MAX = 0xFF,
};
#if CONFIG_IS_ENABLED(PINCTRL_GENERIC)
/**

View file

@ -410,6 +410,18 @@ int dev_read_resource(struct udevice *dev, uint index, struct resource *res);
int dev_read_resource_byname(struct udevice *dev, const char *name,
struct resource *res);
/**
* dev_translate_address() - Tranlate a device-tree address
*
* Translate an address from the device-tree into a CPU physical address. This
* function walks up the tree and applies the various bus mappings along the
* way.
*
* @dev: device giving the context in which to translate the address
* @in_addr: pointer to the address to translate
* @return the translated address; OF_BAD_ADDR on error
*/
u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr);
#else /* CONFIG_DM_DEV_READ_INLINE is enabled */
static inline int dev_read_u32_default(struct udevice *dev,
@ -582,6 +594,11 @@ static inline int dev_read_resource_byname(struct udevice *dev,
return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
}
static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
{
return ofnode_translate_address(dev_ofnode(dev), in_addr);
}
#endif /* CONFIG_DM_DEV_READ_INLINE */
/**

View file

@ -72,11 +72,11 @@ struct udevice;
* then this will be automatically allocated.
* @per_child_auto_alloc_size: Each child device (of a parent in this
* uclass) can hold parent data for the device/uclass. This value is only
* used as a falback if this member is 0 in the driver.
* used as a fallback if this member is 0 in the driver.
* @per_child_platdata_auto_alloc_size: A bus likes to store information about
* its children. If non-zero this is the size of this data, to be allocated
* in the child device's parent_platdata pointer. This value is only used as
* a falback if this member is 0 in the driver.
* a fallback if this member is 0 in the driver.
* @ops: Uclass operations, providing the consistent interface to devices
* within the uclass.
* @flags: Flags for this uclass (DM_UC_...)

View file

@ -83,8 +83,9 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id)
}
fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
const char *prop_name, int index, int na, int ns,
fdt_size_t *sizep, bool translate)
const char *prop_name, int index, int na,
int ns, fdt_size_t *sizep,
bool translate)
{
const fdt32_t *prop, *prop_end;
const fdt32_t *prop_addr, *prop_size, *prop_after_size;
@ -138,8 +139,9 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
}
fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent,
int node, const char *prop_name, int index, fdt_size_t *sizep,
bool translate)
int node, const char *prop_name,
int index, fdt_size_t *sizep,
bool translate)
{
int na, ns;
@ -164,8 +166,9 @@ fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent,
}
fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node,
const char *prop_name, int index, fdt_size_t *sizep,
bool translate)
const char *prop_name, int index,
fdt_size_t *sizep,
bool translate)
{
int parent;
@ -182,7 +185,7 @@ fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node,
}
fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
const char *prop_name, fdt_size_t *sizep)
const char *prop_name, fdt_size_t *sizep)
{
int ns = sizep ? (sizeof(fdt_size_t) / sizeof(fdt32_t)) : 0;
@ -191,15 +194,14 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
ns, sizep, false);
}
fdt_addr_t fdtdec_get_addr(const void *blob, int node,
const char *prop_name)
fdt_addr_t fdtdec_get_addr(const void *blob, int node, const char *prop_name)
{
return fdtdec_get_addr_size(blob, node, prop_name, NULL);
}
#if defined(CONFIG_PCI) && defined(CONFIG_DM_PCI)
int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
const char *prop_name, struct fdt_pci_addr *addr)
const char *prop_name, struct fdt_pci_addr *addr)
{
const u32 *cell;
int len;
@ -231,10 +233,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
addr->phys_mid = fdt32_to_cpu(cell[1]);
addr->phys_lo = fdt32_to_cpu(cell[1]);
break;
} else {
cell += (FDT_PCI_ADDR_CELLS +
FDT_PCI_SIZE_CELLS);
}
cell += (FDT_PCI_ADDR_CELLS +
FDT_PCI_SIZE_CELLS);
}
if (i == num) {
@ -243,10 +245,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
}
return 0;
} else {
ret = -EINVAL;
}
ret = -EINVAL;
fail:
debug("(not found)\n");
return ret;
@ -263,11 +265,9 @@ int fdtdec_get_pci_vendev(const void *blob, int node, u16 *vendor, u16 *device)
end = list + len;
while (list < end) {
char *s;
len = strlen(list);
if (len >= strlen("pciVVVV,DDDD")) {
s = strstr(list, "pci");
char *s = strstr(list, "pci");
/*
* check if the string is something like pciVVVV,DDDD.RR
@ -297,7 +297,7 @@ int fdtdec_get_pci_bar32(struct udevice *dev, struct fdt_pci_addr *addr,
/* extract the bar number from fdt_pci_addr */
barnum = addr->phys_hi & 0xff;
if ((barnum < PCI_BASE_ADDRESS_0) || (barnum > PCI_CARDBUS_CIS))
if (barnum < PCI_BASE_ADDRESS_0 || barnum > PCI_CARDBUS_CIS)
return -EINVAL;
barnum = (barnum - PCI_BASE_ADDRESS_0) / 4;
@ -308,7 +308,7 @@ int fdtdec_get_pci_bar32(struct udevice *dev, struct fdt_pci_addr *addr,
#endif
uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
uint64_t default_val)
uint64_t default_val)
{
const uint64_t *cell64;
int length;
@ -333,7 +333,7 @@ int fdtdec_get_is_enabled(const void *blob, int node)
*/
cell = fdt_getprop(blob, node, "status", NULL);
if (cell)
return 0 == strcmp(cell, "okay");
return strcmp(cell, "okay") == 0;
return 1;
}
@ -343,20 +343,19 @@ enum fdt_compat_id fdtdec_lookup(const void *blob, int node)
/* Search our drivers */
for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++)
if (0 == fdt_node_check_compatible(blob, node,
compat_names[id]))
if (fdt_node_check_compatible(blob, node,
compat_names[id]) == 0)
return id;
return COMPAT_UNKNOWN;
}
int fdtdec_next_compatible(const void *blob, int node,
enum fdt_compat_id id)
int fdtdec_next_compatible(const void *blob, int node, enum fdt_compat_id id)
{
return fdt_node_offset_by_compatible(blob, node, compat_names[id]);
}
int fdtdec_next_compatible_subnode(const void *blob, int node,
enum fdt_compat_id id, int *depthp)
enum fdt_compat_id id, int *depthp)
{
do {
node = fdt_next_node(blob, node, depthp);
@ -370,8 +369,8 @@ int fdtdec_next_compatible_subnode(const void *blob, int node,
return -FDT_ERR_NOTFOUND;
}
int fdtdec_next_alias(const void *blob, const char *name,
enum fdt_compat_id id, int *upto)
int fdtdec_next_alias(const void *blob, const char *name, enum fdt_compat_id id,
int *upto)
{
#define MAX_STR_LEN 20
char str[MAX_STR_LEN + 20];
@ -393,7 +392,8 @@ int fdtdec_next_alias(const void *blob, const char *name,
}
int fdtdec_find_aliases_for_id(const void *blob, const char *name,
enum fdt_compat_id id, int *node_list, int maxcount)
enum fdt_compat_id id, int *node_list,
int maxcount)
{
memset(node_list, '\0', sizeof(*node_list) * maxcount);
@ -402,7 +402,8 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name,
/* TODO: Can we tighten this code up a little? */
int fdtdec_add_aliases_for_id(const void *blob, const char *name,
enum fdt_compat_id id, int *node_list, int maxcount)
enum fdt_compat_id id, int *node_list,
int maxcount)
{
int name_len = strlen(name);
int nodes[maxcount];
@ -429,7 +430,7 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name,
}
if (node >= 0)
debug("%s: warning: maxcount exceeded with alias '%s'\n",
__func__, name);
__func__, name);
/* Now find all the aliases */
for (offset = fdt_first_property_offset(blob, alias_node);
@ -452,7 +453,7 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name,
number = simple_strtoul(path + name_len, NULL, 10);
if (number < 0 || number >= maxcount) {
debug("%s: warning: alias '%s' is out of range\n",
__func__, path);
__func__, path);
continue;
}
@ -498,7 +499,7 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name,
if (!node_list[i]) {
for (; j < maxcount; j++)
if (nodes[j] &&
fdtdec_get_is_enabled(blob, nodes[j]))
fdtdec_get_is_enabled(blob, nodes[j]))
break;
/* Have we run out of nodes to add? */
@ -641,7 +642,8 @@ int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name)
* @return pointer to cell, which is only valid if err == 0
*/
static const void *get_prop_check_min_len(const void *blob, int node,
const char *prop_name, int min_len, int *err)
const char *prop_name, int min_len,
int *err)
{
const void *cell;
int len;
@ -658,15 +660,17 @@ static const void *get_prop_check_min_len(const void *blob, int node,
}
int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
u32 *array, int count)
u32 *array, int count)
{
const u32 *cell;
int i, err = 0;
int err = 0;
debug("%s: %s\n", __func__, prop_name);
cell = get_prop_check_min_len(blob, node, prop_name,
sizeof(u32) * count, &err);
if (!err) {
int i;
for (i = 0; i < count; i++)
array[i] = fdt32_to_cpu(cell[i]);
}
@ -850,7 +854,7 @@ int fdtdec_get_child_count(const void *blob, int node)
}
int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
u8 *array, int count)
u8 *array, int count)
{
const u8 *cell;
int err;
@ -862,7 +866,7 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
}
const u8 *fdtdec_locate_byte_array(const void *blob, int node,
const char *prop_name, int count)
const char *prop_name, int count)
{
const u8 *cell;
int err;
@ -874,7 +878,7 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
}
int fdtdec_get_config_int(const void *blob, const char *prop_name,
int default_val)
int default_val)
{
int config_node;
@ -971,7 +975,8 @@ int fdt_get_resource(const void *fdt, int node, const char *property,
while (ptr + na + ns <= end) {
if (i == index) {
res->start = res->end = fdtdec_get_number(ptr, na);
res->start = fdtdec_get_number(ptr, na);
res->end = res->start;
res->end += fdtdec_get_number(&ptr[na], ns) - 1;
return 0;
}

View file

@ -44,4 +44,5 @@ def GetMaintainer(fname, verbose=False):
return []
stdout = command.Output(get_maintainer, '--norolestats', fname)
return stdout.splitlines()
lines = stdout.splitlines()
return [ x.replace('"', '') for x in lines ]