Commit 9ea4742a authored by Sean Anderson's avatar Sean Anderson Committed by Jakub Kicinski

net: fman: Configure fixed link in memac_initialization

memac is the only mac which parses fixed links. Move the
parsing/configuring to its initialization function.
Signed-off-by: default avatarSean Anderson <sean.anderson@seco.com>
Acked-by: default avatarCamelia Groza <camelia.groza@nxp.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7bd63966
...@@ -34,7 +34,6 @@ struct mac_priv_s { ...@@ -34,7 +34,6 @@ struct mac_priv_s {
/* List of multicast addresses */ /* List of multicast addresses */
struct list_head mc_addr_list; struct list_head mc_addr_list;
struct platform_device *eth_dev; struct platform_device *eth_dev;
struct fixed_phy_status *fixed_link;
u16 speed; u16 speed;
u16 max_speed; u16 max_speed;
}; };
...@@ -391,6 +390,7 @@ static int memac_initialization(struct mac_device *mac_dev, ...@@ -391,6 +390,7 @@ static int memac_initialization(struct mac_device *mac_dev,
int err; int err;
struct mac_priv_s *priv; struct mac_priv_s *priv;
struct fman_mac_params params; struct fman_mac_params params;
struct fixed_phy_status *fixed_link;
priv = mac_dev->priv; priv = mac_dev->priv;
mac_dev->set_promisc = memac_set_promiscuous; mac_dev->set_promisc = memac_set_promiscuous;
...@@ -429,21 +429,52 @@ static int memac_initialization(struct mac_device *mac_dev, ...@@ -429,21 +429,52 @@ static int memac_initialization(struct mac_device *mac_dev,
if (err < 0) if (err < 0)
goto _return_fm_mac_free; goto _return_fm_mac_free;
err = memac_cfg_fixed_link(mac_dev->fman_mac, priv->fixed_link); if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
if (err < 0) struct phy_device *phy;
goto _return_fm_mac_free;
err = of_phy_register_fixed_link(mac_node);
if (err)
goto _return_fm_mac_free;
fixed_link = kzalloc(sizeof(*fixed_link), GFP_KERNEL);
if (!fixed_link) {
err = -ENOMEM;
goto _return_fm_mac_free;
}
mac_dev->phy_node = of_node_get(mac_node);
phy = of_phy_find_device(mac_dev->phy_node);
if (!phy) {
err = -EINVAL;
of_node_put(mac_dev->phy_node);
goto _return_fixed_link_free;
}
fixed_link->link = phy->link;
fixed_link->speed = phy->speed;
fixed_link->duplex = phy->duplex;
fixed_link->pause = phy->pause;
fixed_link->asym_pause = phy->asym_pause;
put_device(&phy->mdio.dev);
err = memac_cfg_fixed_link(mac_dev->fman_mac, fixed_link);
if (err < 0)
goto _return_fixed_link_free;
}
err = memac_init(mac_dev->fman_mac); err = memac_init(mac_dev->fman_mac);
if (err < 0) if (err < 0)
goto _return_fm_mac_free; goto _return_fixed_link_free;
dev_info(mac_dev->dev, "FMan MEMAC\n"); dev_info(mac_dev->dev, "FMan MEMAC\n");
goto _return; goto _return;
_return_fixed_link_free:
kfree(fixed_link);
_return_fm_mac_free: _return_fm_mac_free:
memac_free(mac_dev->fman_mac); memac_free(mac_dev->fman_mac);
_return: _return:
return err; return err;
} }
...@@ -570,7 +601,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -570,7 +601,7 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "of_get_parent(%pOF) failed\n", dev_err(dev, "of_get_parent(%pOF) failed\n",
mac_node); mac_node);
err = -EINVAL; err = -EINVAL;
goto _return_of_get_parent; goto _return_of_node_put;
} }
of_dev = of_find_device_by_node(dev_node); of_dev = of_find_device_by_node(dev_node);
...@@ -604,7 +635,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -604,7 +635,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err < 0) { if (err < 0) {
dev_err(dev, "of_address_to_resource(%pOF) = %d\n", dev_err(dev, "of_address_to_resource(%pOF) = %d\n",
mac_node, err); mac_node, err);
goto _return_of_get_parent; goto _return_of_node_put;
} }
mac_dev->res = __devm_request_region(dev, mac_dev->res = __devm_request_region(dev,
...@@ -614,7 +645,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -614,7 +645,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!mac_dev->res) { if (!mac_dev->res) {
dev_err(dev, "__devm_request_mem_region(mac) failed\n"); dev_err(dev, "__devm_request_mem_region(mac) failed\n");
err = -EBUSY; err = -EBUSY;
goto _return_of_get_parent; goto _return_of_node_put;
} }
priv->vaddr = devm_ioremap(dev, mac_dev->res->start, priv->vaddr = devm_ioremap(dev, mac_dev->res->start,
...@@ -622,12 +653,12 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -622,12 +653,12 @@ static int mac_probe(struct platform_device *_of_dev)
if (!priv->vaddr) { if (!priv->vaddr) {
dev_err(dev, "devm_ioremap() failed\n"); dev_err(dev, "devm_ioremap() failed\n");
err = -EIO; err = -EIO;
goto _return_of_get_parent; goto _return_of_node_put;
} }
if (!of_device_is_available(mac_node)) { if (!of_device_is_available(mac_node)) {
err = -ENODEV; err = -ENODEV;
goto _return_of_get_parent; goto _return_of_node_put;
} }
/* Get the cell-index */ /* Get the cell-index */
...@@ -635,7 +666,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -635,7 +666,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err) { if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node); dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
err = -EINVAL; err = -EINVAL;
goto _return_of_get_parent; goto _return_of_node_put;
} }
priv->cell_index = (u8)val; priv->cell_index = (u8)val;
...@@ -650,14 +681,14 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -650,14 +681,14 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n", dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
mac_node); mac_node);
err = nph; err = nph;
goto _return_of_get_parent; goto _return_of_node_put;
} }
if (nph != ARRAY_SIZE(mac_dev->port)) { if (nph != ARRAY_SIZE(mac_dev->port)) {
dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n", dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n",
mac_node); mac_node);
err = -EINVAL; err = -EINVAL;
goto _return_of_get_parent; goto _return_of_node_put;
} }
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
...@@ -716,42 +747,12 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -716,42 +747,12 @@ static int mac_probe(struct platform_device *_of_dev)
/* Get the rest of the PHY information */ /* Get the rest of the PHY information */
mac_dev->phy_node = of_parse_phandle(mac_node, "phy-handle", 0); mac_dev->phy_node = of_parse_phandle(mac_node, "phy-handle", 0);
if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
struct phy_device *phy;
err = of_phy_register_fixed_link(mac_node);
if (err)
goto _return_of_get_parent;
priv->fixed_link = kzalloc(sizeof(*priv->fixed_link),
GFP_KERNEL);
if (!priv->fixed_link) {
err = -ENOMEM;
goto _return_of_get_parent;
}
mac_dev->phy_node = of_node_get(mac_node);
phy = of_phy_find_device(mac_dev->phy_node);
if (!phy) {
err = -EINVAL;
of_node_put(mac_dev->phy_node);
goto _return_of_get_parent;
}
priv->fixed_link->link = phy->link;
priv->fixed_link->speed = phy->speed;
priv->fixed_link->duplex = phy->duplex;
priv->fixed_link->pause = phy->pause;
priv->fixed_link->asym_pause = phy->asym_pause;
put_device(&phy->mdio.dev);
}
err = init(mac_dev, mac_node); err = init(mac_dev, mac_node);
if (err < 0) { if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err); dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(mac_dev->phy_node); of_node_put(mac_dev->phy_node);
goto _return_of_get_parent; goto _return_of_node_put;
} }
/* pause frame autonegotiation enabled */ /* pause frame autonegotiation enabled */
...@@ -782,8 +783,6 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -782,8 +783,6 @@ static int mac_probe(struct platform_device *_of_dev)
_return_of_node_put: _return_of_node_put:
of_node_put(dev_node); of_node_put(dev_node);
_return_of_get_parent:
kfree(priv->fixed_link);
_return: _return:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment