summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/fdt_support.c21
-rw-r--r--drivers/core/device.c2
-rw-r--r--drivers/gpio/mpc85xx_gpio.c2
-rw-r--r--drivers/i2c/fsl_i2c.c2
-rw-r--r--drivers/misc/misc-uclass.c11
-rw-r--r--drivers/mmc/msm_sdhci.c3
-rw-r--r--drivers/net/cpsw.c3
-rw-r--r--drivers/power/pmic/act8846.c4
-rw-r--r--drivers/power/regulator/act8846.c4
-rw-r--r--drivers/spmi/spmi-msm.c5
-rw-r--r--include/fdt_support.h5
-rw-r--r--include/fdtdec.h14
-rw-r--r--include/misc.h35
-rw-r--r--lib/fdtdec.c22
14 files changed, 100 insertions, 33 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 5d8eb12..2020586 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -997,8 +997,8 @@ static void of_dump_addr(const char *s, const fdt32_t *addr, int na) { }
struct of_bus {
const char *name;
const char *addresses;
- int (*match)(void *blob, int parentoffset);
- void (*count_cells)(void *blob, int parentoffset,
+ int (*match)(const void *blob, int parentoffset);
+ void (*count_cells)(const void *blob, int parentoffset,
int *addrc, int *sizec);
u64 (*map)(fdt32_t *addr, const fdt32_t *range,
int na, int ns, int pna);
@@ -1006,7 +1006,7 @@ struct of_bus {
};
/* Default translator (generic bus) */
-void of_bus_default_count_cells(void *blob, int parentoffset,
+void of_bus_default_count_cells(const void *blob, int parentoffset,
int *addrc, int *sizec)
{
const fdt32_t *prop;
@@ -1055,7 +1055,7 @@ static int of_bus_default_translate(fdt32_t *addr, u64 offset, int na)
#ifdef CONFIG_OF_ISA_BUS
/* ISA bus translator */
-static int of_bus_isa_match(void *blob, int parentoffset)
+static int of_bus_isa_match(const void *blob, int parentoffset)
{
const char *name;
@@ -1066,7 +1066,7 @@ static int of_bus_isa_match(void *blob, int parentoffset)
return !strcmp(name, "isa");
}
-static void of_bus_isa_count_cells(void *blob, int parentoffset,
+static void of_bus_isa_count_cells(const void *blob, int parentoffset,
int *addrc, int *sizec)
{
if (addrc)
@@ -1126,7 +1126,7 @@ static struct of_bus of_busses[] = {
},
};
-static struct of_bus *of_match_bus(void *blob, int parentoffset)
+static struct of_bus *of_match_bus(const void *blob, int parentoffset)
{
struct of_bus *bus;
@@ -1148,7 +1148,7 @@ static struct of_bus *of_match_bus(void *blob, int parentoffset)
return NULL;
}
-static int of_translate_one(void * blob, int parent, struct of_bus *bus,
+static int of_translate_one(const void *blob, int parent, struct of_bus *bus,
struct of_bus *pbus, fdt32_t *addr,
int na, int ns, int pna, const char *rprop)
{
@@ -1211,8 +1211,8 @@ static int of_translate_one(void * blob, int parent, struct of_bus *bus,
* that can be mapped to a cpu physical address). This is not really specified
* that way, but this is traditionally the way IBM at least do things
*/
-static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in_addr,
- const char *rprop)
+static u64 __of_translate_address(const void *blob, int node_offset,
+ const fdt32_t *in_addr, const char *rprop)
{
int parent;
struct of_bus *bus, *pbus;
@@ -1284,7 +1284,8 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in
return result;
}
-u64 fdt_translate_address(void *blob, int node_offset, const fdt32_t *in_addr)
+u64 fdt_translate_address(const void *blob, int node_offset,
+ const fdt32_t *in_addr)
{
return __of_translate_address(blob, node_offset, in_addr, "ranges");
}
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 5bb1d77..b737f1c 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -671,7 +671,7 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
dev->parent->of_offset,
dev->of_offset, "reg",
- index, NULL);
+ index, NULL, false);
if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
if (device_get_uclass_id(dev->parent) ==
UCLASS_SIMPLE_BUS)
diff --git a/drivers/gpio/mpc85xx_gpio.c b/drivers/gpio/mpc85xx_gpio.c
index 3754a82..168c696 100644
--- a/drivers/gpio/mpc85xx_gpio.c
+++ b/drivers/gpio/mpc85xx_gpio.c
@@ -170,7 +170,7 @@ static int mpc85xx_gpio_ofdata_to_platdata(struct udevice *dev) {
fdt_size_t size;
addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset,
- "reg", 0, &size);
+ "reg", 0, &size, false);
plat->addr = addr;
plat->size = size;
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index 407c4a7..c3f826d 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -587,7 +587,7 @@ static int fsl_i2c_ofdata_to_platdata(struct udevice *bus)
fdt_size_t size;
addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, bus->of_offset,
- "reg", 0, &size);
+ "reg", 0, &size, false);
dev->base = map_sysmem(CONFIG_SYS_IMMR + addr, size);
diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c
index 13a6ea5..d9eea3d 100644
--- a/drivers/misc/misc-uclass.c
+++ b/drivers/misc/misc-uclass.c
@@ -45,6 +45,17 @@ int misc_ioctl(struct udevice *dev, unsigned long request, void *buf)
return ops->ioctl(dev, request, buf);
}
+int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
+ void *rx_msg, int rx_size)
+{
+ const struct misc_ops *ops = device_get_ops(dev);
+
+ if (!ops->call)
+ return -ENOSYS;
+
+ return ops->call(dev, msgid, tx_msg, tx_size, rx_msg, rx_size);
+}
+
UCLASS_DRIVER(misc) = {
.id = UCLASS_MISC,
.name = "misc",
diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
index a8cb9e2..8d4399e 100644
--- a/drivers/mmc/msm_sdhci.c
+++ b/drivers/mmc/msm_sdhci.c
@@ -178,7 +178,8 @@ static int msm_ofdata_to_platdata(struct udevice *dev)
priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
parent->of_offset,
dev->of_offset,
- "reg", 1, NULL);
+ "reg", 1, NULL,
+ false);
if (priv->base == (void *)FDT_ADDR_T_NONE ||
host->ioaddr == (void *)FDT_ADDR_T_NONE)
return -EINVAL;
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 511a965..81ccc61 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -1146,7 +1146,8 @@ static const struct eth_ops cpsw_eth_ops = {
static inline fdt_addr_t cpsw_get_addr_by_node(const void *fdt, int node)
{
- return fdtdec_get_addr_size_auto_noparent(fdt, node, "reg", 0, NULL);
+ return fdtdec_get_addr_size_auto_noparent(fdt, node, "reg", 0, NULL,
+ false);
}
static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
diff --git a/drivers/power/pmic/act8846.c b/drivers/power/pmic/act8846.c
index ff096b3..e8164bf 100644
--- a/drivers/power/pmic/act8846.c
+++ b/drivers/power/pmic/act8846.c
@@ -29,7 +29,7 @@ static int act8846_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
if (dm_i2c_write(dev, reg, buff, len)) {
- debug("write error to device: %p register: %#x!", dev, reg);
+ debug("write error to device: %p register: %#x!\n", dev, reg);
return -EIO;
}
@@ -39,7 +39,7 @@ static int act8846_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int act8846_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
if (dm_i2c_read(dev, reg, buff, len)) {
- debug("read error from device: %p register: %#x!", dev, reg);
+ debug("read error from device: %p register: %#x!\n", dev, reg);
return -EIO;
}
diff --git a/drivers/power/regulator/act8846.c b/drivers/power/regulator/act8846.c
index 255f8b0..d506165 100644
--- a/drivers/power/regulator/act8846.c
+++ b/drivers/power/regulator/act8846.c
@@ -88,7 +88,7 @@ static int reg_get_value(struct udevice *dev)
int reg = dev->driver_data;
int ret;
- ret = pmic_reg_read(dev->parent, reg);
+ ret = pmic_reg_read(dev->parent, addr_vol[reg]);
if (ret < 0)
return ret;
@@ -120,7 +120,7 @@ static bool reg_get_enable(struct udevice *dev)
int reg = dev->driver_data;
int ret;
- ret = pmic_reg_read(dev->parent, reg);
+ ret = pmic_reg_read(dev->parent, addr_ctl[reg]);
if (ret < 0)
return ret;
diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c
index 0cef505..48bc157 100644
--- a/drivers/spmi/spmi-msm.c
+++ b/drivers/spmi/spmi-msm.c
@@ -153,11 +153,12 @@ static int msm_spmi_probe(struct udevice *dev)
priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
parent->of_offset,
dev->of_offset,
- "reg", 1, NULL);
+ "reg", 1, NULL,
+ false);
priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
parent->of_offset,
dev->of_offset, "reg",
- 2, NULL);
+ 2, NULL, false);
if (priv->arb_chnl == FDT_ADDR_T_NONE ||
priv->spmi_core == FDT_ADDR_T_NONE ||
priv->spmi_obs == FDT_ADDR_T_NONE)
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 7318098..e9f3497 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -180,7 +180,8 @@ static inline void fdt_fixup_mtdparts(void *fdt, void *node_info,
#endif
void fdt_del_node_and_alias(void *blob, const char *alias);
-u64 fdt_translate_address(void *blob, int node_offset, const __be32 *in_addr);
+u64 fdt_translate_address(const void *blob, int node_offset,
+ const __be32 *in_addr);
int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
phys_addr_t compat_off);
int fdt_alloc_phandle(void *blob);
@@ -239,7 +240,7 @@ static inline u64 of_read_number(const fdt32_t *cell, int size)
return r;
}
-void of_bus_default_count_cells(void *blob, int parentoffset,
+void of_bus_default_count_cells(const void *blob, int parentoffset,
int *addrc, int *sizec);
int ft_verify_fdt(void *fdt);
int arch_fixup_memory_node(void *blob);
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 70ea0bf..aeb6bab 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -297,11 +297,13 @@ int fdtdec_next_compatible_subnode(const void *blob, int node,
* @param na the number of cells used to represent an address
* @param ns the number of cells used to represent a size
* @param sizep a pointer to store the size into. Use NULL if not required
+ * @param translate Indicates whether to translate the returned value
+ * using the parent node's ranges property.
* @return address, if found, or FDT_ADDR_T_NONE if not
*/
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);
+ fdt_size_t *sizep, bool translate);
/*
* Look up an address property in a node and return the parsed address, and
@@ -317,10 +319,13 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
* @param prop_name name of property to find
* @param index which address to retrieve from a list of addresses. Often 0.
* @param sizep a pointer to store the size into. Use NULL if not required
+ * @param translate Indicates whether to translate the returned value
+ * using the parent node's ranges property.
* @return address, if found, or FDT_ADDR_T_NONE if not
*/
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);
/*
* Look up an address property in a node and return the parsed address, and
@@ -340,10 +345,13 @@ fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent,
* @param prop_name name of property to find
* @param index which address to retrieve from a list of addresses. Often 0.
* @param sizep a pointer to store the size into. Use NULL if not required
+ * @param translate Indicates whether to translate the returned value
+ * using the parent node's ranges property.
* @return address, if found, or FDT_ADDR_T_NONE if not
*/
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);
/*
* Look up an address property in a node and return the parsed address.
diff --git a/include/misc.h b/include/misc.h
index 2b78814..03ef55c 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -38,6 +38,27 @@ int misc_write(struct udevice *dev, int offset, void *buf, int size);
int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
/*
+ * Send a message to the device and wait for a response.
+ *
+ * The caller provides the message type/ID and payload to be sent.
+ * The callee constructs any message header required, transmits it to the
+ * target, waits for a response, checks any error code in the response,
+ * strips any message header from the response, and returns the error code
+ * (or a parsed version of it) and the response message payload.
+ *
+ * @dev: the device.
+ * @msgid: the message ID/number to send.
+ * tx_msg: the request/transmit message payload.
+ * tx_size: the size of the buffer pointed at by tx_msg.
+ * rx_msg: the buffer to receive the response message payload. May be NULL if
+ * the caller only cares about the error code.
+ * rx_size: the size of the buffer pointed at by rx_msg.
+ * @return the response message size if OK, -ve on error
+ */
+int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
+ void *rx_msg, int rx_size);
+
+/*
* struct misc_ops - Driver model Misc operations
*
* The uclass interface is implemented by all miscellaneous devices which
@@ -74,6 +95,20 @@ struct misc_ops {
* @return: 0 if OK, -ve on error
*/
int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
+ /*
+ * Send a message to the device and wait for a response.
+ *
+ * @dev: the device
+ * @msgid: the message ID/number to send
+ * tx_msg: the request/transmit message payload
+ * tx_size: the size of the buffer pointed at by tx_msg
+ * rx_msg: the buffer to receive the response message payload. May be
+ * NULL if the caller only cares about the error code.
+ * rx_size: the size of the buffer pointed at by rx_msg
+ * @return the response message size if OK, -ve on error
+ */
+ int (*call)(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
+ void *rx_msg, int rx_size);
};
#endif /* _MISC_H_ */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 462a24f..e638ca5 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -9,6 +9,7 @@
#include <errno.h>
#include <serial.h>
#include <libfdt.h>
+#include <fdt_support.h>
#include <fdtdec.h>
#include <asm/sections.h>
#include <linux/ctype.h>
@@ -77,7 +78,7 @@ 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)
+ fdt_size_t *sizep, bool translate)
{
const fdt32_t *prop, *prop_end;
const fdt32_t *prop_addr, *prop_size, *prop_after_size;
@@ -112,7 +113,12 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
return FDT_ADDR_T_NONE;
}
- addr = fdtdec_get_number(prop_addr, na);
+#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_OF_LIBFDT)
+ if (translate)
+ addr = fdt_translate_address(blob, node, prop_addr);
+ else
+#endif
+ addr = fdtdec_get_number(prop_addr, na);
if (sizep) {
*sizep = fdtdec_get_number(prop_size, ns);
@@ -126,7 +132,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,
- 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)
{
int na, ns;
@@ -147,11 +154,12 @@ fdt_addr_t fdtdec_get_addr_size_auto_parent(const void *blob, int parent,
debug("na=%d, ns=%d, ", na, ns);
return fdtdec_get_addr_size_fixed(blob, node, prop_name, index, na,
- ns, sizep);
+ ns, sizep, translate);
}
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)
{
int parent;
@@ -164,7 +172,7 @@ fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node,
}
return fdtdec_get_addr_size_auto_parent(blob, parent, node, prop_name,
- index, sizep);
+ index, sizep, translate);
}
fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
@@ -174,7 +182,7 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
return fdtdec_get_addr_size_fixed(blob, node, prop_name, 0,
sizeof(fdt_addr_t) / sizeof(fdt32_t),
- ns, sizep);
+ ns, sizep, false);
}
fdt_addr_t fdtdec_get_addr(const void *blob, int node,