net: hns: net: hns: enet adds support of acpi
Enet needs to get configration parameter by acpi. This patch adds support of ACPI for enet. The configuration parameter will be configed in BIOS. Signed-off-by: Kejian Yan <yankejian@huawei.com> Signed-off-by: Yisen Zhuang <Yisen.Zhuang@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f00ef863da
commit
63434888aa
@ -132,6 +132,13 @@ static void fill_v2_desc(struct hnae_ring *ring, void *priv,
|
|||||||
ring_ptr_move_fw(ring, next_to_use);
|
ring_ptr_move_fw(ring, next_to_use);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct acpi_device_id hns_enet_acpi_match[] = {
|
||||||
|
{ "HISI00C1", 0 },
|
||||||
|
{ "HISI00C2", 0 },
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(acpi, hns_enet_acpi_match);
|
||||||
|
|
||||||
static void fill_desc(struct hnae_ring *ring, void *priv,
|
static void fill_desc(struct hnae_ring *ring, void *priv,
|
||||||
int size, dma_addr_t dma, int frag_end,
|
int size, dma_addr_t dma, int frag_end,
|
||||||
int buf_num, enum hns_desc_type type, int mtu)
|
int buf_num, enum hns_desc_type type, int mtu)
|
||||||
@ -1870,7 +1877,6 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
|
|||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
struct hns_nic_priv *priv;
|
struct hns_nic_priv *priv;
|
||||||
struct device_node *ae_node;
|
|
||||||
u32 port_id;
|
u32 port_id;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -1884,7 +1890,11 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
|
|||||||
priv->dev = dev;
|
priv->dev = dev;
|
||||||
priv->netdev = ndev;
|
priv->netdev = ndev;
|
||||||
|
|
||||||
if (of_device_is_compatible(dev->of_node, "hisilicon,hns-nic-v1"))
|
if (dev_of_node(dev)) {
|
||||||
|
struct device_node *ae_node;
|
||||||
|
|
||||||
|
if (of_device_is_compatible(dev->of_node,
|
||||||
|
"hisilicon,hns-nic-v1"))
|
||||||
priv->enet_ver = AE_VERSION_1;
|
priv->enet_ver = AE_VERSION_1;
|
||||||
else
|
else
|
||||||
priv->enet_ver = AE_VERSION_2;
|
priv->enet_ver = AE_VERSION_2;
|
||||||
@ -1896,8 +1906,29 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
|
|||||||
goto out_read_prop_fail;
|
goto out_read_prop_fail;
|
||||||
}
|
}
|
||||||
priv->fwnode = &ae_node->fwnode;
|
priv->fwnode = &ae_node->fwnode;
|
||||||
|
} else if (is_acpi_node(dev->fwnode)) {
|
||||||
|
struct acpi_reference_args args;
|
||||||
|
|
||||||
|
if (acpi_dev_found(hns_enet_acpi_match[0].id))
|
||||||
|
priv->enet_ver = AE_VERSION_1;
|
||||||
|
else if (acpi_dev_found(hns_enet_acpi_match[1].id))
|
||||||
|
priv->enet_ver = AE_VERSION_2;
|
||||||
|
else
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
/* try to find port-idx-in-ae first */
|
/* try to find port-idx-in-ae first */
|
||||||
|
ret = acpi_node_get_property_reference(dev->fwnode,
|
||||||
|
"ae-handle", 0, &args);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "not find ae-handle\n");
|
||||||
|
goto out_read_prop_fail;
|
||||||
|
}
|
||||||
|
priv->fwnode = acpi_fwnode_handle(args.adev);
|
||||||
|
} else {
|
||||||
|
dev_err(dev, "cannot read cfg data from OF or acpi\n");
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
ret = device_property_read_u32(dev, "port-idx-in-ae", &port_id);
|
ret = device_property_read_u32(dev, "port-idx-in-ae", &port_id);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* only for old code compatible */
|
/* only for old code compatible */
|
||||||
@ -2014,6 +2045,7 @@ static struct platform_driver hns_nic_dev_driver = {
|
|||||||
.driver = {
|
.driver = {
|
||||||
.name = "hns-nic",
|
.name = "hns-nic",
|
||||||
.of_match_table = hns_enet_of_match,
|
.of_match_table = hns_enet_of_match,
|
||||||
|
.acpi_match_table = ACPI_PTR(hns_enet_acpi_match),
|
||||||
},
|
},
|
||||||
.probe = hns_nic_dev_probe,
|
.probe = hns_nic_dev_probe,
|
||||||
.remove = hns_nic_dev_remove,
|
.remove = hns_nic_dev_remove,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user