Commit dac95976 authored by David S. Miller's avatar David S. Miller

Merge branch 'mt2712'

Biao Huang says:

====================
add ethernet binding and modify ethernet driver for mt2712

changes in v3:
resend this series base on the latest net-next tree.

changes in v2 as comments from Sean:
1. fix typo.
2. use capital letters for RMII/MII/RGMII in driver and bindings.

v1:
This new series is the result of discussion in:
http://lkml.org/lkml/2018/12/13/1007
http://lkml.org/lkml/2018/12/14/53

1. ethernet binding file move to this series.
2. remove fine tune property in device tree
3. remove fine tune flow in ethernet driver
4. set rgmii timing according to the value in device tree,
and don't care whether phy insert internal delay  or not.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 24894bc6 22a3a540
...@@ -22,33 +22,25 @@ Required properties: ...@@ -22,33 +22,25 @@ Required properties:
Optional properties: Optional properties:
- mediatek,tx-delay-ps: TX clock delay macro value. Default is 0. - mediatek,tx-delay-ps: TX clock delay macro value. Default is 0.
It should be defined for rgmii/rgmii-rxid/mii interface. It should be defined for RGMII/MII interface.
- mediatek,rx-delay-ps: RX clock delay macro value. Default is 0. - mediatek,rx-delay-ps: RX clock delay macro value. Default is 0.
It should be defined for rgmii/rgmii-txid/mii/rmii interface. It should be defined for RGMII/MII/RMII interface.
Both delay properties need to be a multiple of 170 for fine-tune rgmii, Both delay properties need to be a multiple of 170 for RGMII interface,
range 0~31*170. or will round down. Range 0~31*170.
Both delay properties need to be a multiple of 550 for coarse-tune rgmii, Both delay properties need to be a multiple of 550 for MII/RMII interface,
range 0~31*550. or will round down. Range 0~31*550.
Both delay properties need to be a multiple of 550 for mii/rmii,
range 0~31*550.
- mediatek,fine-tune: boolean property, if present indicates that fine delay - mediatek,rmii-rxc: boolean property, if present indicates that the RMII
is selected for rgmii interface.
If present, tx-delay-ps/rx-delay-ps is 170+/-50ps per stage.
Else tx-delay-ps/rx-delay-ps of coarse delay macro is 0.55+/-0.2ns per stage.
This property do not apply to non-rgmii PHYs.
Only coarse-tune delay is supported for mii/rmii PHYs.
- mediatek,rmii-rxc: boolean property, if present indicates that the rmii
reference clock, which is from external PHYs, is connected to RXC pin reference clock, which is from external PHYs, is connected to RXC pin
on MT2712 SoC. on MT2712 SoC.
Otherwise, is connected to TXC pin. Otherwise, is connected to TXC pin.
- mediatek,txc-inverse: boolean property, if present indicates that - mediatek,txc-inverse: boolean property, if present indicates that
1. tx clock will be inversed in mii/rgmii case, 1. tx clock will be inversed in MII/RGMII case,
2. tx clock inside MAC will be inversed relative to reference clock 2. tx clock inside MAC will be inversed relative to reference clock
which is from external PHYs in rmii case, and it rarely happen. which is from external PHYs in RMII case, and it rarely happen.
- mediatek,rxc-inverse: boolean property, if present indicates that - mediatek,rxc-inverse: boolean property, if present indicates that
1. rx clock will be inversed in mii/rgmii case. 1. rx clock will be inversed in MII/RGMII case.
2. reference clock will be inversed when arrived at MAC in rmii case. 2. reference clock will be inversed when arrived at MAC in RMII case.
- assigned-clocks: mac_main and ptp_ref clocks - assigned-clocks: mac_main and ptp_ref clocks
- assigned-clock-parents: parent clocks of the assigned clocks - assigned-clock-parents: parent clocks of the assigned clocks
...@@ -76,7 +68,6 @@ Example: ...@@ -76,7 +68,6 @@ Example:
mediatek,pericfg = <&pericfg>; mediatek,pericfg = <&pericfg>;
mediatek,tx-delay-ps = <1530>; mediatek,tx-delay-ps = <1530>;
mediatek,rx-delay-ps = <1530>; mediatek,rx-delay-ps = <1530>;
mediatek,fine-tune;
mediatek,rmii-rxc; mediatek,rmii-rxc;
mediatek,txc-inverse; mediatek,txc-inverse;
mediatek,rxc-inverse; mediatek,rxc-inverse;
......
...@@ -44,7 +44,6 @@ struct mac_delay_struct { ...@@ -44,7 +44,6 @@ struct mac_delay_struct {
u32 rx_delay; u32 rx_delay;
bool tx_inv; bool tx_inv;
bool rx_inv; bool rx_inv;
bool fine_tune;
}; };
struct mediatek_dwmac_plat_data { struct mediatek_dwmac_plat_data {
...@@ -105,16 +104,28 @@ static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat) ...@@ -105,16 +104,28 @@ static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
return 0; return 0;
} }
static void mt2712_delay_ps2stage(struct mac_delay_struct *mac_delay) static void mt2712_delay_ps2stage(struct mediatek_dwmac_plat_data *plat)
{ {
if (mac_delay->fine_tune) { struct mac_delay_struct *mac_delay = &plat->mac_delay;
/* 170ps per stage for fine tune delay macro circuit*/
mac_delay->tx_delay /= 170; switch (plat->phy_mode) {
mac_delay->rx_delay /= 170; case PHY_INTERFACE_MODE_MII:
} else { case PHY_INTERFACE_MODE_RMII:
/* 550ps per stage for coarse tune delay macro circuit*/ /* 550ps per stage for MII/RMII */
mac_delay->tx_delay /= 550; mac_delay->tx_delay /= 550;
mac_delay->rx_delay /= 550; mac_delay->rx_delay /= 550;
break;
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_TXID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_ID:
/* 170ps per stage for RGMII */
mac_delay->tx_delay /= 170;
mac_delay->rx_delay /= 170;
break;
default:
dev_err(plat->dev, "phy interface not supported\n");
break;
} }
} }
...@@ -123,7 +134,7 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) ...@@ -123,7 +134,7 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
struct mac_delay_struct *mac_delay = &plat->mac_delay; struct mac_delay_struct *mac_delay = &plat->mac_delay;
u32 delay_val = 0, fine_val = 0; u32 delay_val = 0, fine_val = 0;
mt2712_delay_ps2stage(mac_delay); mt2712_delay_ps2stage(plat);
switch (plat->phy_mode) { switch (plat->phy_mode) {
case PHY_INTERFACE_MODE_MII: case PHY_INTERFACE_MODE_MII:
...@@ -167,13 +178,10 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) ...@@ -167,13 +178,10 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
fine_val = ETH_RMII_DLY_TX_INV; fine_val = ETH_RMII_DLY_TX_INV;
break; break;
case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII:
/* the PHY is not responsible for inserting any internal case PHY_INTERFACE_MODE_RGMII_TXID:
* delay by itself in PHY_INTERFACE_MODE_RGMII case, case PHY_INTERFACE_MODE_RGMII_RXID:
* so Ethernet MAC will insert delays for both transmit case PHY_INTERFACE_MODE_RGMII_ID:
* and receive path here. fine_val = ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC;
*/
if (mac_delay->fine_tune)
fine_val = ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC;
delay_val |= FIELD_PREP(ETH_DLY_GTXC_ENABLE, !!mac_delay->tx_delay); delay_val |= FIELD_PREP(ETH_DLY_GTXC_ENABLE, !!mac_delay->tx_delay);
delay_val |= FIELD_PREP(ETH_DLY_GTXC_STAGES, mac_delay->tx_delay); delay_val |= FIELD_PREP(ETH_DLY_GTXC_STAGES, mac_delay->tx_delay);
...@@ -183,36 +191,6 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat) ...@@ -183,36 +191,6 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
delay_val |= FIELD_PREP(ETH_DLY_RXC_STAGES, mac_delay->rx_delay); delay_val |= FIELD_PREP(ETH_DLY_RXC_STAGES, mac_delay->rx_delay);
delay_val |= FIELD_PREP(ETH_DLY_RXC_INV, mac_delay->rx_inv); delay_val |= FIELD_PREP(ETH_DLY_RXC_INV, mac_delay->rx_inv);
break; break;
case PHY_INTERFACE_MODE_RGMII_TXID:
/* the PHY should insert an internal delay for the transmit
* path in PHY_INTERFACE_MODE_RGMII_TXID case,
* so Ethernet MAC will insert the delay for receive path here.
*/
if (mac_delay->fine_tune)
fine_val = ETH_FINE_DLY_RXC;
delay_val |= FIELD_PREP(ETH_DLY_RXC_ENABLE, !!mac_delay->rx_delay);
delay_val |= FIELD_PREP(ETH_DLY_RXC_STAGES, mac_delay->rx_delay);
delay_val |= FIELD_PREP(ETH_DLY_RXC_INV, mac_delay->rx_inv);
break;
case PHY_INTERFACE_MODE_RGMII_RXID:
/* the PHY should insert an internal delay for the receive
* path in PHY_INTERFACE_MODE_RGMII_RXID case,
* so Ethernet MAC will insert the delay for transmit path here.
*/
if (mac_delay->fine_tune)
fine_val = ETH_FINE_DLY_GTXC;
delay_val |= FIELD_PREP(ETH_DLY_GTXC_ENABLE, !!mac_delay->tx_delay);
delay_val |= FIELD_PREP(ETH_DLY_GTXC_STAGES, mac_delay->tx_delay);
delay_val |= FIELD_PREP(ETH_DLY_GTXC_INV, mac_delay->tx_inv);
break;
case PHY_INTERFACE_MODE_RGMII_ID:
/* the PHY should insert internal delays for both transmit
* and receive path in PHY_INTERFACE_MODE_RGMII_RXID case,
* so Ethernet MAC will NOT insert any delay here.
*/
break;
default: default:
dev_err(plat->dev, "phy interface not supported\n"); dev_err(plat->dev, "phy interface not supported\n");
return -EINVAL; return -EINVAL;
...@@ -270,7 +248,6 @@ static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat) ...@@ -270,7 +248,6 @@ static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat)
mac_delay->tx_inv = of_property_read_bool(plat->np, "mediatek,txc-inverse"); mac_delay->tx_inv = of_property_read_bool(plat->np, "mediatek,txc-inverse");
mac_delay->rx_inv = of_property_read_bool(plat->np, "mediatek,rxc-inverse"); mac_delay->rx_inv = of_property_read_bool(plat->np, "mediatek,rxc-inverse");
mac_delay->fine_tune = of_property_read_bool(plat->np, "mediatek,fine-tune");
plat->rmii_rxc = of_property_read_bool(plat->np, "mediatek,rmii-rxc"); plat->rmii_rxc = of_property_read_bool(plat->np, "mediatek,rmii-rxc");
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