summaryrefslogtreecommitdiff
path: root/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
diff options
context:
space:
mode:
authorSalil <salil.mehta@huawei.com>2016-08-24 04:44:50 +0800
committerDoug Ledford <dledford@redhat.com>2016-08-25 10:05:10 -0400
commit528f1deb16e5b82e9fe161ebd8caa5983766f0f0 (patch)
treee491e9ea31baec5c606cc0f5bf69b2bfcbf6f857 /drivers/infiniband/hw/hns/hns_roce_hw_v1.c
parentd605916b76593417340397fe281acd2e8a953706 (diff)
IB/hns: Add support of ACPI to the Hisilicon RoCE driver
This patch is meant to add support of ACPI to the Hisilicon RoCE driver. Changes done are primarily meant to detect the type and then either use DT specific or ACPI spcific functions. Where ever possible, this patch tries to make use of Unified Device Property Interface APIs to support both DT and ACPI through single interface. This patch depends upon HNS ethernet driver to Reset RoCE. This function within HNS ethernet driver has also been enhanced to support ACPI and is part of other accompanying patch with this patch-set. NOTE: The changes in this patch are done over below branch, https://github.com/dledford/linux/tree/hns-roce Signed-off-by: Salil Mehta <salil.mehta@huawei.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/hns/hns_roce_hw_v1.c')
-rw-r--r--drivers/infiniband/hw/hns/hns_roce_hw_v1.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index b52f3badf855..399f5dedaf2d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -31,6 +31,7 @@
*/
#include <linux/platform_device.h>
+#include <linux/acpi.h>
#include <rdma/ib_umem.h>
#include "hns_roce_common.h"
#include "hns_roce_device.h"
@@ -794,29 +795,47 @@ static void hns_roce_port_enable(struct hns_roce_dev *hr_dev, int enable_flag)
* @enable: true -- drop reset, false -- reset
* return 0 - success , negative --fail
*/
-int hns_roce_v1_reset(struct hns_roce_dev *hr_dev, bool enable)
+int hns_roce_v1_reset(struct hns_roce_dev *hr_dev, bool dereset)
{
struct device_node *dsaf_node;
struct device *dev = &hr_dev->pdev->dev;
struct device_node *np = dev->of_node;
+ struct fwnode_handle *fwnode;
int ret;
- dsaf_node = of_parse_phandle(np, "dsaf-handle", 0);
- if (!dsaf_node) {
- dev_err(dev, "Unable to get dsaf node by dsaf-handle!\n");
- return -EINVAL;
+ /* check if this is DT/ACPI case */
+ if (dev_of_node(dev)) {
+ dsaf_node = of_parse_phandle(np, "dsaf-handle", 0);
+ if (!dsaf_node) {
+ dev_err(dev, "could not find dsaf-handle\n");
+ return -EINVAL;
+ }
+ fwnode = &dsaf_node->fwnode;
+ } else if (is_acpi_device_node(dev->fwnode)) {
+ struct acpi_reference_args args;
+
+ ret = acpi_node_get_property_reference(dev->fwnode,
+ "dsaf-handle", 0, &args);
+ if (ret) {
+ dev_err(dev, "could not find dsaf-handle\n");
+ return ret;
+ }
+ fwnode = acpi_fwnode_handle(args.adev);
+ } else {
+ dev_err(dev, "cannot read data from DT or ACPI\n");
+ return -ENXIO;
}
- ret = hns_dsaf_roce_reset(&dsaf_node->fwnode, false);
+ ret = hns_dsaf_roce_reset(fwnode, false);
if (ret)
return ret;
- if (enable) {
+ if (dereset) {
msleep(SLEEP_TIME_INTERVAL);
- return hns_dsaf_roce_reset(&dsaf_node->fwnode, true);
+ ret = hns_dsaf_roce_reset(fwnode, true);
}
- return 0;
+ return ret;
}
void hns_roce_v1_profile(struct hns_roce_dev *hr_dev)