Skip to content

Commit

Permalink
Merge branch 'hns-acpi'
Browse files Browse the repository at this point in the history
Kejian Yan says:

====================
net: hns: add support of ACPI

This series adds HNS support of acpi. The routine will call some ACPI
helper functions, like acpi_dev_found() and acpi_evaluate_dsm(), which
are not included in other cases. In order to make system compile
successfully in other cases except ACPI, it needs to add relative stub
functions to linux/acpi.h. And we use device property functions instead
of serial helper functions to suport both DT and ACPI cases. And then
add the supports of ACPI for HNS.

change log:
 v3->v4:
  mii-id gets from dev-name instead of address

 v2->v3:
 1. add Review-by: Andy Shevchenko
 2. fix the potential memory leak

 v1 -> v2:
 1. use acpi_dev_found() instead of acpi_match_device_ids() to check if
it is a acpi node.
 2. use is_of_node() instead of IS_ENABLED() to check if it is a DT node.
 3. split the patch("add support of acpi for hns-mdio") into two patches:
    3.1 Move to use fwnode_handle
    3.2 Add ACPI
 4. add the patch which subject is dsaf misc operation method
 5. fix the comments by Andy Shevchenko
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 5, 2016
2 parents 169fbdc + 6343488 commit b1c6a3a
Show file tree
Hide file tree
Showing 18 changed files with 706 additions and 262 deletions.
18 changes: 12 additions & 6 deletions drivers/net/ethernet/hisilicon/hns/hnae.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,22 @@ static int __ae_match(struct device *dev, const void *data)
{
struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);

return hdev->dev->of_node == data;
if (dev_of_node(hdev->dev))
return (data == &hdev->dev->of_node->fwnode);
else if (is_acpi_node(hdev->dev->fwnode))
return (data == hdev->dev->fwnode);

dev_err(dev, "__ae_match cannot read cfg data from OF or acpi\n");
return 0;
}

static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
static struct hnae_ae_dev *find_ae(const struct fwnode_handle *fwnode)
{
struct device *dev;

WARN_ON(!ae_node);
WARN_ON(!fwnode);

dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
dev = class_find_device(hnae_class, NULL, fwnode, __ae_match);

return dev ? cls_to_ae_dev(dev) : NULL;
}
Expand Down Expand Up @@ -312,7 +318,7 @@ EXPORT_SYMBOL(hnae_reinit_handle);
* return handle ptr or ERR_PTR
*/
struct hnae_handle *hnae_get_handle(struct device *owner_dev,
const struct device_node *ae_node,
const struct fwnode_handle *fwnode,
u32 port_id,
struct hnae_buf_ops *bops)
{
Expand All @@ -321,7 +327,7 @@ struct hnae_handle *hnae_get_handle(struct device *owner_dev,
int i, j;
int ret;

dev = find_ae(ae_node);
dev = find_ae(fwnode);
if (!dev)
return ERR_PTR(-ENODEV);

Expand Down
5 changes: 3 additions & 2 deletions drivers/net/ethernet/hisilicon/hns/hnae.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* "cb" means control block
*/

#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/module.h>
Expand Down Expand Up @@ -512,7 +513,7 @@ struct hnae_ae_dev {
struct hnae_handle {
struct device *owner_dev; /* the device which make use of this handle */
struct hnae_ae_dev *dev; /* the device who provides this handle */
struct device_node *phy_node;
struct phy_device *phy_dev;
phy_interface_t phy_if;
u32 if_support;
int q_num;
Expand All @@ -528,7 +529,7 @@ struct hnae_handle {
#define ring_to_dev(ring) ((ring)->q->dev->dev)

struct hnae_handle *hnae_get_handle(struct device *owner_dev,
const struct device_node *ae_node,
const struct fwnode_handle *fwnode,
u32 port_id,
struct hnae_buf_ops *bops);

Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev *dev,
vf_cb->mac_cb = dsaf_dev->mac_cb[port_id];

ae_handle->phy_if = vf_cb->mac_cb->phy_if;
ae_handle->phy_node = vf_cb->mac_cb->phy_node;
ae_handle->phy_dev = vf_cb->mac_cb->phy_dev;
ae_handle->if_support = vf_cb->mac_cb->if_support;
ae_handle->port_type = vf_cb->mac_cb->mac_type;
ae_handle->dport_id = port_id;
Expand Down Expand Up @@ -637,13 +637,15 @@ static int hns_ae_config_loopback(struct hnae_handle *handle,
int ret;
struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);
struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);
struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev;

switch (loop) {
case MAC_INTERNALLOOP_PHY:
ret = 0;
break;
case MAC_INTERNALLOOP_SERDES:
ret = hns_mac_config_sds_loopback(vf_cb->mac_cb, en);
ret = dsaf_dev->misc_op->cfg_serdes_loopback(vf_cb->mac_cb,
!!en);
break;
case MAC_INTERNALLOOP_MAC:
ret = hns_mac_config_mac_loopback(vf_cb->mac_cb, loop, en);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void hns_gmac_free(void *mac_drv)

u32 mac_id = drv->mac_id;

hns_dsaf_ge_srst_by_port(dsaf_dev, mac_id, 0);
dsaf_dev->misc_op->ge_srst(dsaf_dev, mac_id, 0);
}

static void hns_gmac_set_tx_auto_pause_frames(void *mac_drv, u16 newval)
Expand Down Expand Up @@ -317,9 +317,9 @@ static void hns_gmac_init(void *mac_drv)

port = drv->mac_id;

hns_dsaf_ge_srst_by_port(dsaf_dev, port, 0);
dsaf_dev->misc_op->ge_srst(dsaf_dev, port, 0);
mdelay(10);
hns_dsaf_ge_srst_by_port(dsaf_dev, port, 1);
dsaf_dev->misc_op->ge_srst(dsaf_dev, port, 1);
mdelay(10);
hns_gmac_disable(mac_drv, MAC_COMM_MODE_RX_AND_TX);
hns_gmac_tx_loop_pkt_dis(mac_drv);
Expand Down
Loading

0 comments on commit b1c6a3a

Please sign in to comment.