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_$(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-y += tegra/
obj-$(CONFIG_CLK_UNIPHIER) += uniphier/ obj-$(CONFIG_ARCH_ASPEED) += aspeed/
obj-$(CONFIG_CLK_EXYNOS) += exynos/ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
obj-$(CONFIG_CLK_AT91) += at91/ obj-$(CONFIG_CLK_AT91) += at91/
obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o
obj-$(CONFIG_CLK_BOSTON) += clk_boston.o obj-$(CONFIG_CLK_BOSTON) += clk_boston.o
obj-$(CONFIG_CLK_EXYNOS) += exynos/
obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o 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_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 obj-$(CONFIG_STM32H7) += clk_stm32h7.o

View File

@ -13,11 +13,9 @@
#include <dt-structs.h> #include <dt-structs.h>
#include <errno.h> #include <errno.h>
DECLARE_GLOBAL_DATA_PTR; static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)
static inline 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) #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; int ret;
struct ofnode_phandle_args args; struct ofnode_phandle_args args;
struct udevice *dev_clk; 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); debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
@ -142,7 +140,7 @@ int clk_release_all(struct clk *clk, int count)
int clk_request(struct udevice *dev, struct clk *clk) 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); 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) 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); debug("%s(clk=%p)\n", __func__, clk);
@ -168,7 +166,7 @@ int clk_free(struct clk *clk)
ulong clk_get_rate(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); 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) 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); 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) 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); debug("%s(clk=%p)\n", __func__, clk);
@ -204,7 +202,7 @@ int clk_enable(struct clk *clk)
int clk_disable(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); debug("%s(clk=%p)\n", __func__, clk);

View File

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

View File

@ -17,6 +17,7 @@
#include <dm/device.h> #include <dm/device.h>
#include <dm/device-internal.h> #include <dm/device-internal.h>
#include <dm/lists.h> #include <dm/lists.h>
#include <dm/of_access.h>
#include <dm/pinctrl.h> #include <dm/pinctrl.h>
#include <dm/platdata.h> #include <dm/platdata.h>
#include <dm/read.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) bool device_is_compatible(struct udevice *dev, const char *compat)
{ {
const void *fdt = gd->fdt_blob; 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) 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); &flags);
if (!prop_val) if (!prop_val)
return FDT_ADDR_T_NONE; return FDT_ADDR_T_NONE;
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)); na = of_n_addr_cells(ofnode_to_np(node));
return of_read_number(prop_val, na); return of_read_number(prop_val, na);
}
} else { } else {
return fdt_get_base_address(gd->fdt_blob, return fdt_get_base_address(gd->fdt_blob,
ofnode_to_offset(node)); ofnode_to_offset(node));
@ -296,7 +301,8 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
int ret; int ret;
ret = of_parse_phandle_with_args(ofnode_to_np(node), ret = of_parse_phandle_with_args(ofnode_to_np(node),
list_name, cells_name, index, &args); list_name, cells_name, index,
&args);
if (ret) if (ret)
return ret; return ret;
ofnode_from_of_phandle_args(&args, out_args); ofnode_from_of_phandle_args(&args, out_args);
@ -305,7 +311,8 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
int ret; int ret;
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, ret = fdtdec_parse_phandle_with_args(gd->fdt_blob,
ofnode_to_offset(node), list_name, cells_name, ofnode_to_offset(node),
list_name, cells_name,
cell_count, index, &args); cell_count, index, &args);
if (ret) if (ret)
return ret; return ret;
@ -534,11 +541,11 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
addr->phys_mid = fdt32_to_cpu(cell[1]); addr->phys_mid = fdt32_to_cpu(cell[1]);
addr->phys_lo = fdt32_to_cpu(cell[1]); addr->phys_lo = fdt32_to_cpu(cell[1]);
break; break;
} else { }
cell += (FDT_PCI_ADDR_CELLS + cell += (FDT_PCI_ADDR_CELLS +
FDT_PCI_SIZE_CELLS); FDT_PCI_SIZE_CELLS);
} }
}
if (i == num) { if (i == num) {
ret = -ENXIO; ret = -ENXIO;
@ -546,10 +553,10 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
} }
return 0; return 0;
} else {
ret = -EINVAL;
} }
ret = -EINVAL;
fail: fail:
debug("(not found)\n"); debug("(not found)\n");
return ret; return ret;
@ -642,3 +649,11 @@ int ofnode_read_resource_byname(ofnode node, const char *name,
return ofnode_read_resource(node, index, res); 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

@ -95,8 +95,7 @@ int dev_read_string_count(struct udevice *dev, const char *propname)
int dev_read_phandle_with_args(struct udevice *dev, const char *list_name, int dev_read_phandle_with_args(struct udevice *dev, const char *list_name,
const char *cells_name, int cell_count, const char *cells_name, int cell_count,
int index, int index, struct ofnode_phandle_args *out_args)
struct ofnode_phandle_args *out_args)
{ {
return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name, return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name,
cells_name, cell_count, index, 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); 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); \ ofnode_valid(node); \
node = ofnode_next_subnode(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 #endif

View File

@ -137,6 +137,12 @@ struct pinctrl_ops {
/** /**
* Generic pin configuration paramters * 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 * @PIN_CONFIG_BIAS_DISABLE: disable any pin bias on the pin, a
* transition from say pull-up to pull-down implies that you disable * transition from say pull-up to pull-down implies that you disable
* pull-up in the process, this setting disables all biasing. * 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 * 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 * to it for a while. Pins used for input are usually always high
* impedance. * 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 * @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, * 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. * 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 * 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 * configuration is ignored. The proper way to disable it is to use
* @PIN_CONFIG_BIAS_DISABLE. * @PIN_CONFIG_BIAS_DISABLE.
* @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high
* low, this is the most typical case and is typically achieved with two * impedance to VDD). If the argument is != 0 pull-up is enabled,
* active transistors on the output. Setting this config will enable * if it is 0, pull-up is total, i.e. the pin is connected to VDD.
* push-pull mode, the argument is ignored.
* @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open * @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 * collector) which means it is usually wired with other output ports
* which are then pulled up with an external resistor. Setting this * 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 * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source
* (open emitter). Setting this config will enable open source mode, the * (open emitter). Setting this config will enable open source mode, the
* argument is ignored. * 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 * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current
* passed as argument. The argument is in mA. * 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, * @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 * which means it will wait for signals to settle when reading inputs. The
* argument gives the debounce time in usecs. Setting the * argument gives the debounce time in usecs. Setting the
* argument to zero turns debouncing off. * argument to zero turns debouncing off.
* @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power * @PIN_CONFIG_INPUT_ENABLE: enable the pin's input. Note that this does not
* supplies, the argument to this parameter (on a custom format) tells * affect the pin's ability to drive output. 1 enables input, 0 disables
* the driver which alternative power source to use. * input.
* @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to * @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in
* this parameter (on a custom format) tells the driver which alternative * schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis,
* slew rate to use. * 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 * @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power
* operation, if several modes of operation are supported these can be * operation, if several modes of operation are supported these can be
* passed in the argument on a custom form, else just use argument 1 * 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. * 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 * @PIN_CONFIG_OUTPUT_ENABLE: this will enable the pin's output mode
* 1 to indicate high level, argument 0 to indicate low level. (Please * without driving a value there. For most platforms this reduces to
* see Documentation/pinctrl.txt, section "GPIO mode pitfalls" for a * enable the output buffers and then let the pin controller current
* discussion around this parameter.) * 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 * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if
* you need to pass in custom configurations to the pin controller, use * you need to pass in custom configurations to the pin controller, use
* PIN_CONFIG_END+1 as the base offset. * 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 enum pin_config_param {
#define PIN_CONFIG_BIAS_HIGH_IMPEDANCE 1 PIN_CONFIG_BIAS_BUS_HOLD,
#define PIN_CONFIG_BIAS_BUS_HOLD 2 PIN_CONFIG_BIAS_DISABLE,
#define PIN_CONFIG_BIAS_PULL_UP 3 PIN_CONFIG_BIAS_HIGH_IMPEDANCE,
#define PIN_CONFIG_BIAS_PULL_DOWN 4 PIN_CONFIG_BIAS_PULL_DOWN,
#define PIN_CONFIG_BIAS_PULL_PIN_DEFAULT 5 PIN_CONFIG_BIAS_PULL_PIN_DEFAULT,
#define PIN_CONFIG_DRIVE_PUSH_PULL 6 PIN_CONFIG_BIAS_PULL_UP,
#define PIN_CONFIG_DRIVE_OPEN_DRAIN 7 PIN_CONFIG_DRIVE_OPEN_DRAIN,
#define PIN_CONFIG_DRIVE_OPEN_SOURCE 8 PIN_CONFIG_DRIVE_OPEN_SOURCE,
#define PIN_CONFIG_DRIVE_STRENGTH 9 PIN_CONFIG_DRIVE_PUSH_PULL,
#define PIN_CONFIG_INPUT_ENABLE 10 PIN_CONFIG_DRIVE_STRENGTH,
#define PIN_CONFIG_INPUT_SCHMITT_ENABLE 11 PIN_CONFIG_INPUT_DEBOUNCE,
#define PIN_CONFIG_INPUT_SCHMITT 12 PIN_CONFIG_INPUT_ENABLE,
#define PIN_CONFIG_INPUT_DEBOUNCE 13 PIN_CONFIG_INPUT_SCHMITT,
#define PIN_CONFIG_POWER_SOURCE 14 PIN_CONFIG_INPUT_SCHMITT_ENABLE,
#define PIN_CONFIG_SLEW_RATE 15 PIN_CONFIG_LOW_POWER_MODE,
#define PIN_CONFIG_LOW_POWER_MODE 16 PIN_CONFIG_OUTPUT_ENABLE,
#define PIN_CONFIG_OUTPUT 17 PIN_CONFIG_OUTPUT,
#define PIN_CONFIG_END 0x7FFF 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) #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, int dev_read_resource_byname(struct udevice *dev, const char *name,
struct resource *res); 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 */ #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
static inline int dev_read_u32_default(struct udevice *dev, 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); 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 */ #endif /* CONFIG_DM_DEV_READ_INLINE */
/** /**

View File

@ -72,11 +72,11 @@ struct udevice;
* then this will be automatically allocated. * then this will be automatically allocated.
* @per_child_auto_alloc_size: Each child device (of a parent in this * @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 * 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 * @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 * its children. If non-zero this is the size of this data, to be allocated
* in the child device's parent_platdata pointer. This value is only used as * in the child device's parent_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 * @ops: Uclass operations, providing the consistent interface to devices
* within the uclass. * within the uclass.
* @flags: Flags for this uclass (DM_UC_...) * @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, fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
const char *prop_name, int index, int na, int ns, const char *prop_name, int index, int na,
fdt_size_t *sizep, bool translate) int ns, fdt_size_t *sizep,
bool translate)
{ {
const fdt32_t *prop, *prop_end; const fdt32_t *prop, *prop_end;
const fdt32_t *prop_addr, *prop_size, *prop_after_size; const fdt32_t *prop_addr, *prop_size, *prop_after_size;
@ -138,7 +139,8 @@ 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, 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, int node, const char *prop_name,
int index, fdt_size_t *sizep,
bool translate) bool translate)
{ {
int na, ns; int na, ns;
@ -164,7 +166,8 @@ 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, fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node,
const char *prop_name, int index, fdt_size_t *sizep, const char *prop_name, int index,
fdt_size_t *sizep,
bool translate) bool translate)
{ {
int parent; int parent;
@ -191,8 +194,7 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
ns, sizep, false); ns, sizep, false);
} }
fdt_addr_t fdtdec_get_addr(const void *blob, int node, fdt_addr_t fdtdec_get_addr(const void *blob, int node, const char *prop_name)
const char *prop_name)
{ {
return fdtdec_get_addr_size(blob, node, prop_name, NULL); return fdtdec_get_addr_size(blob, node, prop_name, NULL);
} }
@ -231,11 +233,11 @@ 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_mid = fdt32_to_cpu(cell[1]);
addr->phys_lo = fdt32_to_cpu(cell[1]); addr->phys_lo = fdt32_to_cpu(cell[1]);
break; break;
} else { }
cell += (FDT_PCI_ADDR_CELLS + cell += (FDT_PCI_ADDR_CELLS +
FDT_PCI_SIZE_CELLS); FDT_PCI_SIZE_CELLS);
} }
}
if (i == num) { if (i == num) {
ret = -ENXIO; ret = -ENXIO;
@ -243,10 +245,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
} }
return 0; return 0;
} else {
ret = -EINVAL;
} }
ret = -EINVAL;
fail: fail:
debug("(not found)\n"); debug("(not found)\n");
return ret; return ret;
@ -263,11 +265,9 @@ int fdtdec_get_pci_vendev(const void *blob, int node, u16 *vendor, u16 *device)
end = list + len; end = list + len;
while (list < end) { while (list < end) {
char *s;
len = strlen(list); len = strlen(list);
if (len >= strlen("pciVVVV,DDDD")) { if (len >= strlen("pciVVVV,DDDD")) {
s = strstr(list, "pci"); char *s = strstr(list, "pci");
/* /*
* check if the string is something like pciVVVV,DDDD.RR * 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 */ /* extract the bar number from fdt_pci_addr */
barnum = addr->phys_hi & 0xff; 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; return -EINVAL;
barnum = (barnum - PCI_BASE_ADDRESS_0) / 4; barnum = (barnum - PCI_BASE_ADDRESS_0) / 4;
@ -333,7 +333,7 @@ int fdtdec_get_is_enabled(const void *blob, int node)
*/ */
cell = fdt_getprop(blob, node, "status", NULL); cell = fdt_getprop(blob, node, "status", NULL);
if (cell) if (cell)
return 0 == strcmp(cell, "okay"); return strcmp(cell, "okay") == 0;
return 1; return 1;
} }
@ -343,14 +343,13 @@ enum fdt_compat_id fdtdec_lookup(const void *blob, int node)
/* Search our drivers */ /* Search our drivers */
for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++) for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++)
if (0 == fdt_node_check_compatible(blob, node, if (fdt_node_check_compatible(blob, node,
compat_names[id])) compat_names[id]) == 0)
return id; return id;
return COMPAT_UNKNOWN; return COMPAT_UNKNOWN;
} }
int fdtdec_next_compatible(const void *blob, int node, int fdtdec_next_compatible(const void *blob, int node, enum fdt_compat_id id)
enum fdt_compat_id id)
{ {
return fdt_node_offset_by_compatible(blob, node, compat_names[id]); return fdt_node_offset_by_compatible(blob, node, compat_names[id]);
} }
@ -370,8 +369,8 @@ int fdtdec_next_compatible_subnode(const void *blob, int node,
return -FDT_ERR_NOTFOUND; return -FDT_ERR_NOTFOUND;
} }
int fdtdec_next_alias(const void *blob, const char *name, int fdtdec_next_alias(const void *blob, const char *name, enum fdt_compat_id id,
enum fdt_compat_id id, int *upto) int *upto)
{ {
#define MAX_STR_LEN 20 #define MAX_STR_LEN 20
char str[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, 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); 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? */ /* TODO: Can we tighten this code up a little? */
int fdtdec_add_aliases_for_id(const void *blob, const char *name, 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 name_len = strlen(name);
int nodes[maxcount]; int nodes[maxcount];
@ -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 * @return pointer to cell, which is only valid if err == 0
*/ */
static const void *get_prop_check_min_len(const void *blob, int node, 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; const void *cell;
int len; int len;
@ -661,12 +663,14 @@ 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; const u32 *cell;
int i, err = 0; int err = 0;
debug("%s: %s\n", __func__, prop_name); debug("%s: %s\n", __func__, prop_name);
cell = get_prop_check_min_len(blob, node, prop_name, cell = get_prop_check_min_len(blob, node, prop_name,
sizeof(u32) * count, &err); sizeof(u32) * count, &err);
if (!err) { if (!err) {
int i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
array[i] = fdt32_to_cpu(cell[i]); array[i] = fdt32_to_cpu(cell[i]);
} }
@ -971,7 +975,8 @@ int fdt_get_resource(const void *fdt, int node, const char *property,
while (ptr + na + ns <= end) { while (ptr + na + ns <= end) {
if (i == index) { 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; res->end += fdtdec_get_number(&ptr[na], ns) - 1;
return 0; return 0;
} }

View File

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