/* Two references have been taken in of_find_device_by_node() * and fman_bind(). Release one of them here. The second one * will be released in mac_remove().
*/
put_device(mac_dev->fman_dev);
of_node_put(dev_node);
dev_node = NULL;
/* Get the address of the memory mapped registers */
mac_dev->res = platform_get_mem_or_io(_of_dev, 0); if (!mac_dev->res) {
dev_err(dev, "could not get registers\n");
err = -EINVAL; goto _return_dev_put;
}
err = devm_request_resource(dev, fman_get_mem_region(priv->fman),
mac_dev->res); if (err) {
dev_err_probe(dev, err, "could not request resource\n"); goto _return_dev_put;
}
if (!of_device_is_available(mac_node)) {
err = -ENODEV; goto _return_dev_put;
}
/* Get the cell-index */
err = of_property_read_u32(mac_node, "cell-index", &val); if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
err = -EINVAL; goto _return_dev_put;
} if (val >= MAX_NUM_OF_MACS) {
dev_err(dev, "cell-index value is too big for %pOF\n", mac_node);
err = -EINVAL; goto _return_dev_put;
}
priv->cell_index = (u8)val;
/* Get the MAC address */
err = of_get_mac_address(mac_node, mac_dev->addr); if (err)
dev_warn(dev, "of_get_mac_address(%pOF) failed\n", mac_node);
/* Get the port handles */
nph = of_count_phandle_with_args(mac_node, "fsl,fman-ports", NULL); if (unlikely(nph < 0)) {
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
mac_node);
err = nph; goto _return_dev_put;
}
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",
mac_node);
err = -EINVAL; goto _return_dev_put;
}
/* PORT_NUM determines the size of the port array */ for (i = 0; i < PORT_NUM; i++) { /* Find the port node */
dev_node = of_parse_phandle(mac_node, "fsl,fman-ports", i); if (!dev_node) {
dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n",
mac_node);
err = -EINVAL; goto _return_dev_arr_put;
}
mac_dev->port[i] = fman_port_bind(mac_dev->fman_port_devs[i]); if (!mac_dev->port[i]) {
dev_err(dev, "dev_get_drvdata(%pOF) failed\n",
dev_node);
err = -EINVAL; goto _return_dev_arr_put;
} /* Two references have been taken in of_find_device_by_node() * and fman_port_bind(). Release one of them here. The second * one will be released in mac_remove().
*/
put_device(mac_dev->fman_port_devs[i]);
of_node_put(dev_node);
dev_node = NULL;
}
/* Get the PHY connection type */
err = of_get_phy_mode(mac_node, &phy_if); if (err) {
dev_warn(dev, "of_get_phy_mode() for %pOF failed. Defaulting to SGMII\n",
mac_node);
phy_if = PHY_INTERFACE_MODE_SGMII;
}
mac_dev->phy_if = phy_if;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.