[PATCH v4 net-next 10/13] net: hns: dsaf adds support of acpi

2016-06-02 Thread Yisen Zhuang
From: Kejian Yan 

Dsaf needs to get configuration parameter by ACPI, so this patch add
support of ACPI.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2:
  1. use dev_of_node() instead of IS_ENABLED() to check if it is in
DT case,
  2. split a new patch to implement misc operation method,
  3. use acpi_dev_found() instead of acpi_match_device_ids() to
check which hw version it is,
  4. use is_acpi_node instead of ACPI_COMPANION to check if it is
work in ACPI case.

 v1: first submit
  link: https://lkml.org/lkml/2016/5/13/108
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 80 ++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 85 +++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 32 
 3 files changed, 114 insertions(+), 83 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 2ebf14a..3ef0c9b 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -689,9 +689,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
return 0;
}
 
-   if (!is_of_node(mac_cb->fw_port))
-   return -EINVAL;
-
+   if (is_of_node(mac_cb->fw_port)) {
/* parse property from port subnode in dsaf */
np = of_parse_phandle(to_of_node(mac_cb->fw_port), "phy-handle", 0);
mac_cb->phy_dev = of_phy_find_device(np);
@@ -701,47 +699,49 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
mac_cb->mac_id, np->name);
}
 
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(to_of_node(mac_cb->fw_port),
-"serdes-syscon", 0));
-   if (IS_ERR_OR_NULL(syscon)) {
-   dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
-   return -EINVAL;
-   }
-   mac_cb->serdes_ctrl = syscon;
-
-   ret = fwnode_property_read_u32(mac_cb->fw_port,
-  "port-rst-offset",
-  _cb->port_rst_off);
-   if (ret) {
-   dev_dbg(mac_cb->dev,
-   "mac%d port-rst-offset not found, use default value.\n",
-   mac_cb->mac_id);
-   }
+   syscon = syscon_node_to_regmap(
+   of_parse_phandle(to_of_node(mac_cb->fw_port),
+"serdes-syscon", 0));
+   if (IS_ERR_OR_NULL(syscon)) {
+   dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
+   return -EINVAL;
+   }
+   mac_cb->serdes_ctrl = syscon;
 
-   ret = fwnode_property_read_u32(mac_cb->fw_port,
-  "port-mode-offset",
-  _cb->port_mode_off);
-   if (ret) {
-   dev_dbg(mac_cb->dev,
-   "mac%d port-mode-offset not found, use default 
value.\n",
-   mac_cb->mac_id);
-   }
+   ret = fwnode_property_read_u32(mac_cb->fw_port,
+  "port-rst-offset",
+  _cb->port_rst_off);
+   if (ret) {
+   dev_dbg(mac_cb->dev,
+   "mac%d port-rst-offset not found, use default 
value.\n",
+   mac_cb->mac_id);
+   }
 
-   ret = of_parse_phandle_with_fixed_args(to_of_node(mac_cb->fw_port),
-  "cpld-syscon", 1, 0, _args);
-   if (ret) {
-   dev_dbg(mac_cb->dev, "mac%d no cpld-syscon found.\n",
-   mac_cb->mac_id);
-   mac_cb->cpld_ctrl = NULL;
-   } else {
-   syscon = syscon_node_to_regmap(cpld_args.np);
-   if (IS_ERR_OR_NULL(syscon)) {
-   dev_dbg(mac_cb->dev, "no cpld-syscon found!\n");
+   ret = fwnode_property_read_u32(mac_cb->fw_port,
+  "port-mode-offset",
+  _cb->port_mode_off);
+   if (ret) {
+   dev_dbg(mac_cb->dev,
+   "mac%d port-mode-offset not found, use default 
value.\n",
+   mac_cb->mac_id);
+   }
+
+   ret = of_parse_phandle_with_fixed_args(
+   to_of_node(mac_cb->fw_port), "cpld-syscon", 1, 0,
+   _args);
+   if (ret) {
+   dev_dbg(mac_cb->dev, "mac%d no cpld-syscon found.\n",
+   mac_cb->mac_id);
mac_cb->cpld_ctrl = NULL;
  

[PATCH v4 net-next 10/13] net: hns: dsaf adds support of acpi

2016-06-02 Thread Yisen Zhuang
From: Kejian Yan 

Dsaf needs to get configuration parameter by ACPI, so this patch add
support of ACPI.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2:
  1. use dev_of_node() instead of IS_ENABLED() to check if it is in
DT case,
  2. split a new patch to implement misc operation method,
  3. use acpi_dev_found() instead of acpi_match_device_ids() to
check which hw version it is,
  4. use is_acpi_node instead of ACPI_COMPANION to check if it is
work in ACPI case.

 v1: first submit
  link: https://lkml.org/lkml/2016/5/13/108
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 80 ++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 85 +++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 32 
 3 files changed, 114 insertions(+), 83 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 2ebf14a..3ef0c9b 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -689,9 +689,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
return 0;
}
 
-   if (!is_of_node(mac_cb->fw_port))
-   return -EINVAL;
-
+   if (is_of_node(mac_cb->fw_port)) {
/* parse property from port subnode in dsaf */
np = of_parse_phandle(to_of_node(mac_cb->fw_port), "phy-handle", 0);
mac_cb->phy_dev = of_phy_find_device(np);
@@ -701,47 +699,49 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
mac_cb->mac_id, np->name);
}
 
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(to_of_node(mac_cb->fw_port),
-"serdes-syscon", 0));
-   if (IS_ERR_OR_NULL(syscon)) {
-   dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
-   return -EINVAL;
-   }
-   mac_cb->serdes_ctrl = syscon;
-
-   ret = fwnode_property_read_u32(mac_cb->fw_port,
-  "port-rst-offset",
-  _cb->port_rst_off);
-   if (ret) {
-   dev_dbg(mac_cb->dev,
-   "mac%d port-rst-offset not found, use default value.\n",
-   mac_cb->mac_id);
-   }
+   syscon = syscon_node_to_regmap(
+   of_parse_phandle(to_of_node(mac_cb->fw_port),
+"serdes-syscon", 0));
+   if (IS_ERR_OR_NULL(syscon)) {
+   dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
+   return -EINVAL;
+   }
+   mac_cb->serdes_ctrl = syscon;
 
-   ret = fwnode_property_read_u32(mac_cb->fw_port,
-  "port-mode-offset",
-  _cb->port_mode_off);
-   if (ret) {
-   dev_dbg(mac_cb->dev,
-   "mac%d port-mode-offset not found, use default 
value.\n",
-   mac_cb->mac_id);
-   }
+   ret = fwnode_property_read_u32(mac_cb->fw_port,
+  "port-rst-offset",
+  _cb->port_rst_off);
+   if (ret) {
+   dev_dbg(mac_cb->dev,
+   "mac%d port-rst-offset not found, use default 
value.\n",
+   mac_cb->mac_id);
+   }
 
-   ret = of_parse_phandle_with_fixed_args(to_of_node(mac_cb->fw_port),
-  "cpld-syscon", 1, 0, _args);
-   if (ret) {
-   dev_dbg(mac_cb->dev, "mac%d no cpld-syscon found.\n",
-   mac_cb->mac_id);
-   mac_cb->cpld_ctrl = NULL;
-   } else {
-   syscon = syscon_node_to_regmap(cpld_args.np);
-   if (IS_ERR_OR_NULL(syscon)) {
-   dev_dbg(mac_cb->dev, "no cpld-syscon found!\n");
+   ret = fwnode_property_read_u32(mac_cb->fw_port,
+  "port-mode-offset",
+  _cb->port_mode_off);
+   if (ret) {
+   dev_dbg(mac_cb->dev,
+   "mac%d port-mode-offset not found, use default 
value.\n",
+   mac_cb->mac_id);
+   }
+
+   ret = of_parse_phandle_with_fixed_args(
+   to_of_node(mac_cb->fw_port), "cpld-syscon", 1, 0,
+   _args);
+   if (ret) {
+   dev_dbg(mac_cb->dev, "mac%d no cpld-syscon found.\n",
+   mac_cb->mac_id);
mac_cb->cpld_ctrl = NULL;
} else {
-   mac_cb->cpld_ctrl =