Commit 3d125f9c authored by Stefan Agner's avatar Stefan Agner Committed by David S. Miller

net: fec: fix MDIO bus assignement for dual fec SoC's

On i.MX28, the MDIO bus is shared between the two FEC instances.
The driver makes sure that the second FEC uses the MDIO bus of the
first FEC. This is done conditionally if FEC_QUIRK_ENET_MAC is set.
However, in newer designs, such as Vybrid or i.MX6SX, each FEC MAC
has its own MDIO bus. Simply removing the quirk FEC_QUIRK_ENET_MAC
is not an option since other logic, triggered by this quirk, is
still needed.

Furthermore, there are board designs which use the same MDIO bus
for both PHY's even though the second bus would be available on the
SoC side. Such layout are popular since it saves pins on SoC side.
Due to the above quirk, those boards currently do work fine. The
boards in the mainline tree with such a layout are:
- Freescale Vybrid Tower with TWR-SER2 (vf610-twr.dts)
- Freescale i.MX6 SoloX SDB Board (imx6sx-sdb.dts)

This patch adds a new quirk FEC_QUIRK_SINGLE_MDIO for i.MX28, which
makes sure that the MDIO bus of the first FEC is used in any case.

However, the boards above do have a SoC with a MDIO bus for each FEC
instance. But the PHY's are not connected in a 1:1 configuration. A
proper device tree description is needed to allow the driver to
figure out where to find its PHY. This patch fixes that shortcoming
by adding a MDIO bus child node to the first FEC instance, along
with the two PHY's on that bus, and making use of the phy-handle
property to add a reference to the PHY's.
Acked-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarStefan Agner <stefan@agner.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 900e1833
...@@ -159,13 +159,28 @@ &fec1 { ...@@ -159,13 +159,28 @@ &fec1 {
pinctrl-0 = <&pinctrl_enet1>; pinctrl-0 = <&pinctrl_enet1>;
phy-supply = <&reg_enet_3v3>; phy-supply = <&reg_enet_3v3>;
phy-mode = "rgmii"; phy-mode = "rgmii";
phy-handle = <&ethphy1>;
status = "okay"; status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethphy1: ethernet-phy@0 {
reg = <0>;
};
ethphy2: ethernet-phy@1 {
reg = <1>;
};
};
}; };
&fec2 { &fec2 {
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet2>; pinctrl-0 = <&pinctrl_enet2>;
phy-mode = "rgmii"; phy-mode = "rgmii";
phy-handle = <&ethphy2>;
status = "okay"; status = "okay";
}; };
......
...@@ -129,13 +129,28 @@ &esdhc1 { ...@@ -129,13 +129,28 @@ &esdhc1 {
&fec0 { &fec0 {
phy-mode = "rmii"; phy-mode = "rmii";
phy-handle = <&ethphy0>;
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fec0>; pinctrl-0 = <&pinctrl_fec0>;
status = "okay"; status = "okay";
mdio {
#address-cells = <1>;
#size-cells = <0>;
ethphy0: ethernet-phy@0 {
reg = <0>;
};
ethphy1: ethernet-phy@1 {
reg = <1>;
};
};
}; };
&fec1 { &fec1 {
phy-mode = "rmii"; phy-mode = "rmii";
phy-handle = <&ethphy1>;
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fec1>; pinctrl-0 = <&pinctrl_fec1>;
status = "okay"; status = "okay";
......
...@@ -424,6 +424,8 @@ struct bufdesc_ex { ...@@ -424,6 +424,8 @@ struct bufdesc_ex {
* (40ns * 6). * (40ns * 6).
*/ */
#define FEC_QUIRK_BUG_CAPTURE (1 << 10) #define FEC_QUIRK_BUG_CAPTURE (1 << 10)
/* Controller has only one MDIO bus */
#define FEC_QUIRK_SINGLE_MDIO (1 << 11)
struct fec_enet_priv_tx_q { struct fec_enet_priv_tx_q {
int index; int index;
......
...@@ -91,7 +91,8 @@ static struct platform_device_id fec_devtype[] = { ...@@ -91,7 +91,8 @@ static struct platform_device_id fec_devtype[] = {
.driver_data = 0, .driver_data = 0,
}, { }, {
.name = "imx28-fec", .name = "imx28-fec",
.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME, .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
FEC_QUIRK_SINGLE_MDIO,
}, { }, {
.name = "imx6q-fec", .name = "imx6q-fec",
.driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT | .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
...@@ -1937,7 +1938,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -1937,7 +1938,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
int err = -ENXIO, i; int err = -ENXIO, i;
/* /*
* The dual fec interfaces are not equivalent with enet-mac. * The i.MX28 dual fec interfaces are not equal.
* Here are the differences: * Here are the differences:
* *
* - fec0 supports MII & RMII modes while fec1 only supports RMII * - fec0 supports MII & RMII modes while fec1 only supports RMII
...@@ -1952,7 +1953,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -1952,7 +1953,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
* mdio interface in board design, and need to be configured by * mdio interface in board design, and need to be configured by
* fec0 mii_bus. * fec0 mii_bus.
*/ */
if ((fep->quirks & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) { if ((fep->quirks & FEC_QUIRK_SINGLE_MDIO) && fep->dev_id > 0) {
/* fec1 uses fec0 mii_bus */ /* fec1 uses fec0 mii_bus */
if (mii_cnt && fec0_mii_bus) { if (mii_cnt && fec0_mii_bus) {
fep->mii_bus = fec0_mii_bus; fep->mii_bus = fec0_mii_bus;
...@@ -2015,7 +2016,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) ...@@ -2015,7 +2016,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
mii_cnt++; mii_cnt++;
/* save fec0 mii_bus */ /* save fec0 mii_bus */
if (fep->quirks & FEC_QUIRK_ENET_MAC) if (fep->quirks & FEC_QUIRK_SINGLE_MDIO)
fec0_mii_bus = fep->mii_bus; fec0_mii_bus = fep->mii_bus;
return 0; return 0;
......
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