]> git.sur5r.net Git - u-boot/commitdiff
Merge git://git.denx.de/u-boot-dm
authorTom Rini <trini@konsulko.com>
Fri, 12 Aug 2016 20:00:50 +0000 (16:00 -0400)
committerTom Rini <trini@konsulko.com>
Fri, 12 Aug 2016 20:00:50 +0000 (16:00 -0400)
14 files changed:
common/fdt_support.c
drivers/core/device.c
drivers/gpio/mpc85xx_gpio.c
drivers/i2c/fsl_i2c.c
drivers/misc/misc-uclass.c
drivers/mmc/msm_sdhci.c
drivers/net/cpsw.c
drivers/power/pmic/act8846.c
drivers/power/regulator/act8846.c
drivers/spmi/spmi-msm.c
include/fdt_support.h
include/fdtdec.h
include/misc.h
lib/fdtdec.c

index 5d8eb12f10737a5eedf4d814a0406611284e7fb8..202058621ae2016f4457160ef6079b6c539b6608 100644 (file)
@@ -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");
 }
index 5bb1d7793dd687a9fed5475409b382e32effab92..b737f1c78907ada6e7538ed9262f2a49d9246386 100644 (file)
@@ -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)
index 3754a8215c3630db7c33cc50a13eff8959fa6b04..168c696c4dc00a435669281d419c2cbbb0bd119e 100644 (file)
@@ -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;
index 407c4a7b10b86c9b38eeac3b0f76527cbf4e7024..c3f826d68c7591e4318ecb5754a9312f960a6b1f 100644 (file)
@@ -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);
 
index 13a6ea508b14a37c83c99131c4eefbd1460c6fd0..d9eea3dac5c0a06503dcb7e55d368bba9719eb71 100644 (file)
@@ -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",
index a8cb9e249df91ef9f90f95893d148305a00497e4..8d4399e96758b038b36528177a0207cb228dabbd 100644 (file)
@@ -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;
index 511a965c9b0c0e50265a505cccb6fbb15c690441..81ccc61a60dcece58db7f99f37282dae0d9cedc4 100644 (file)
@@ -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)
index ff096b3a9ccb5475e233d5259bf240aec3b2f7be..e8164bfd08afab318252a10a6da0f8582ed8815d 100644 (file)
@@ -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;
        }
 
index 255f8b096e1dd79523752f1f68c2082800a5fb21..d506165120865e1b760b6c1671772518b544792e 100644 (file)
@@ -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;
 
index 0cef505e37d0f44440d4314651300174ec471780..48bc15759645835760ee7730e0e458372aae9201 100644 (file)
@@ -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)
index 731809874f480158feb6d4baa96d9d52dbb898cc..e9f3497ab64216a0aaf396e7e64e42535de2ccc9 100644 (file)
@@ -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);
index 70ea0bfc0bae28ebd74f395e79e56cca26a35a83..aeb6bab1c4c6f2b53f8acd56dccfa72f83a31c85 100644 (file)
@@ -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.
index 2b788143b54cc975e2e86d0af92f29ec72e90374..03ef55cdc8870c7a2914581fefcaaf790f68f012 100644 (file)
@@ -37,6 +37,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
  *
@@ -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_ */
index 462a24f96a97f3bdf364cb0164d0cca52d764678..e638ca5d6a337acd2d32f9e18850b0e732d279b7 100644 (file)
@@ -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,