Merge branch 'next' of git://git.denx.de/u-boot-usb into next
[oweals/u-boot.git] / drivers / firmware / ti_sci.c
index 1fd29f2cdf55f9f0faa14b8ae36d08a6d6fc9533..c3f95b252f24f3969d7cf5838e6304f7fe36c805 100644 (file)
 #include <dm.h>
 #include <errno.h>
 #include <mailbox.h>
+#include <malloc.h>
 #include <dm/device.h>
+#include <dm/device_compat.h>
+#include <dm/devres.h>
 #include <linux/compat.h>
 #include <linux/err.h>
 #include <linux/soc/ti/k3-sec-proxy.h>
@@ -2361,82 +2364,6 @@ fail:
        return ret;
 }
 
-/**
- * ti_sci_cmd_ring_get_config() - get RA ring configuration
- * @handle:    pointer to TI SCI handle
- * @nav_id: Device ID of Navigator Subsystem from which the ring is allocated
- * @index: Ring index.
- * @addr_lo: returns ring's base address lo 32 bits
- * @addr_hi: returns ring's base address hi 32 bits
- * @count: returns number of ring elements.
- * @mode: returns mode of the ring
- * @size: returns ring element size.
- * @order_id: returns ring's bus order ID.
- *
- * Return: 0 if all went well, else returns appropriate error value.
- *
- * See @ti_sci_msg_rm_ring_get_cfg_req for more info.
- */
-static int ti_sci_cmd_ring_get_config(const struct ti_sci_handle *handle,
-                                     u32 nav_id, u32 index, u8 *mode,
-                                     u32 *addr_lo, u32 *addr_hi,
-                                     u32 *count, u8 *size, u8 *order_id)
-{
-       struct ti_sci_msg_rm_ring_get_cfg_resp *resp;
-       struct ti_sci_msg_rm_ring_get_cfg_req req;
-       struct ti_sci_xfer *xfer;
-       struct ti_sci_info *info;
-       int ret = 0;
-
-       if (IS_ERR(handle))
-               return PTR_ERR(handle);
-       if (!handle)
-               return -EINVAL;
-
-       info = handle_to_ti_sci_info(handle);
-
-       xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_RM_RING_GET_CFG,
-                                    TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
-                                    (u32 *)&req, sizeof(req), sizeof(*resp));
-       if (IS_ERR(xfer)) {
-               ret = PTR_ERR(xfer);
-               dev_err(info->dev,
-                       "RM_RA:Message get config failed(%d)\n", ret);
-               return ret;
-       }
-       req.nav_id = nav_id;
-       req.index = index;
-
-       ret = ti_sci_do_xfer(info, xfer);
-       if (ret) {
-               dev_err(info->dev, "RM_RA:Mbox get config send fail %d\n", ret);
-               goto fail;
-       }
-
-       resp = (struct ti_sci_msg_rm_ring_get_cfg_resp *)xfer->tx_message.buf;
-
-       if (!ti_sci_is_response_ack(resp)) {
-               ret = -ENODEV;
-       } else {
-               if (mode)
-                       *mode = resp->mode;
-               if (addr_lo)
-                       *addr_lo = resp->addr_lo;
-               if (addr_hi)
-                       *addr_hi = resp->addr_hi;
-               if (count)
-                       *count = resp->count;
-               if (size)
-                       *size = resp->size;
-               if (order_id)
-                       *order_id = resp->order_id;
-       };
-
-fail:
-       dev_dbg(info->dev, "RM_RA:get config ring %u ret:%d\n", index, ret);
-       return ret;
-}
-
 static int ti_sci_cmd_rm_psil_pair(const struct ti_sci_handle *handle,
                                   u32 nav_id, u32 src_thread, u32 dst_thread)
 {
@@ -2945,7 +2872,6 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
        pops->proc_shutdown_no_wait = ti_sci_cmd_proc_shutdown_no_wait;
 
        rops->config = ti_sci_cmd_ring_config;
-       rops->get_config = ti_sci_cmd_ring_get_config;
 
        psilops->pair = ti_sci_cmd_rm_psil_pair;
        psilops->unpair = ti_sci_cmd_rm_psil_unpair;
@@ -3170,6 +3096,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
        u32 resource_subtype;
        u16 resource_type;
        struct ti_sci_resource *res;
+       bool valid_set = false;
        int sets, i, ret;
        u32 *temp;
 
@@ -3209,12 +3136,15 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
                                                        &res->desc[i].start,
                                                        &res->desc[i].num);
                if (ret) {
-                       dev_err(dev, "type %d subtype %d not allocated for host %d\n",
+                       dev_dbg(dev, "type %d subtype %d not allocated for host %d\n",
                                resource_type, resource_subtype,
                                handle_to_ti_sci_info(handle)->host_id);
-                       return ERR_PTR(ret);
+                       res->desc[i].start = 0;
+                       res->desc[i].num = 0;
+                       continue;
                }
 
+               valid_set = true;
                dev_dbg(dev, "res type = %d, subtype = %d, start = %d, num = %d\n",
                        resource_type, resource_subtype, res->desc[i].start,
                        res->desc[i].num);
@@ -3226,7 +3156,10 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
                        return ERR_PTR(-ENOMEM);
        }
 
-       return res;
+       if (valid_set)
+               return res;
+
+       return ERR_PTR(-EINVAL);
 }
 
 /* Description for K2G */