Commit a21e282a authored by Vitaly Bordug's avatar Vitaly Bordug Committed by Kumar Gala

[POWERPC] fsl_soc: add support to gianfar for fixed-link property

fixed-link says: register new "Fixed/emulated PHY", i.e. PHY that
not connected to the real MDIO bus.
Signed-off-by: default avatarVitaly Bordug <vitb@kernel.crashing.org>
Signed-off-by: default avatarAnton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
parent e3000765
...@@ -1257,6 +1257,10 @@ platforms are moved over to use the flattened-device-tree model. ...@@ -1257,6 +1257,10 @@ platforms are moved over to use the flattened-device-tree model.
services interrupts for this device. services interrupts for this device.
- phy-handle : The phandle for the PHY connected to this ethernet - phy-handle : The phandle for the PHY connected to this ethernet
controller. controller.
- fixed-link : <a b c d e> where a is emulated phy id - choose any,
but unique to the all specified fixed-links, b is duplex - 0 half,
1 full, c is link speed - d#10/d#100/d#1000, d is pause - 0 no
pause, 1 pause, e is asym_pause - 0 no asym_pause, 1 asym_pause.
Recommended properties: Recommended properties:
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phy_fixed.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/fsl_devices.h> #include <linux/fsl_devices.h>
#include <linux/fs_enet_pd.h> #include <linux/fs_enet_pd.h>
...@@ -130,6 +131,37 @@ u32 get_baudrate(void) ...@@ -130,6 +131,37 @@ u32 get_baudrate(void)
EXPORT_SYMBOL(get_baudrate); EXPORT_SYMBOL(get_baudrate);
#endif /* CONFIG_CPM2 */ #endif /* CONFIG_CPM2 */
#ifdef CONFIG_FIXED_PHY
static int __init of_add_fixed_phys(void)
{
int ret;
struct device_node *np;
u32 *fixed_link;
struct fixed_phy_status status = {};
for_each_node_by_name(np, "ethernet") {
fixed_link = (u32 *)of_get_property(np, "fixed-link", NULL);
if (!fixed_link)
continue;
status.link = 1;
status.duplex = fixed_link[1];
status.speed = fixed_link[2];
status.pause = fixed_link[3];
status.asym_pause = fixed_link[4];
ret = fixed_phy_add(PHY_POLL, fixed_link[0], &status);
if (ret) {
of_node_put(np);
return ret;
}
}
return 0;
}
arch_initcall(of_add_fixed_phys);
#endif /* CONFIG_FIXED_PHY */
static int __init gfar_mdio_of_init(void) static int __init gfar_mdio_of_init(void)
{ {
struct device_node *np = NULL; struct device_node *np = NULL;
...@@ -198,7 +230,6 @@ static const char *gfar_tx_intr = "tx"; ...@@ -198,7 +230,6 @@ static const char *gfar_tx_intr = "tx";
static const char *gfar_rx_intr = "rx"; static const char *gfar_rx_intr = "rx";
static const char *gfar_err_intr = "error"; static const char *gfar_err_intr = "error";
static int __init gfar_of_init(void) static int __init gfar_of_init(void)
{ {
struct device_node *np; struct device_node *np;
...@@ -282,6 +313,19 @@ static int __init gfar_of_init(void) ...@@ -282,6 +313,19 @@ static int __init gfar_of_init(void)
gfar_data.interface = PHY_INTERFACE_MODE_MII; gfar_data.interface = PHY_INTERFACE_MODE_MII;
ph = of_get_property(np, "phy-handle", NULL); ph = of_get_property(np, "phy-handle", NULL);
if (ph == NULL) {
u32 *fixed_link;
fixed_link = (u32 *)of_get_property(np, "fixed-link",
NULL);
if (!fixed_link) {
ret = -ENODEV;
goto unreg;
}
gfar_data.bus_id = 0;
gfar_data.phy_id = fixed_link[0];
} else {
phy = of_find_node_by_phandle(*ph); phy = of_find_node_by_phandle(*ph);
if (phy == NULL) { if (phy == NULL) {
...@@ -304,6 +348,7 @@ static int __init gfar_of_init(void) ...@@ -304,6 +348,7 @@ static int __init gfar_of_init(void)
of_node_put(phy); of_node_put(phy);
of_node_put(mdio); of_node_put(mdio);
}
ret = ret =
platform_device_add_data(gfar_dev, &gfar_data, platform_device_add_data(gfar_dev, &gfar_data,
......
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