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.
Biao Huang (2):
dt-binding: mediatek-dwmac: add binding document for MediaTek MT2712
DWMAC
net-next: stmmac: dwmac-mediatek: remove fine-tune property
.../devicetree/bindings/net/mediatek-dwmac.txt | 78 ++++++++++++++++++++
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 71 ++++++------------
2 files changed, 102 insertions(+), 47 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt
--
1.7.9.5
The commit adds the device tree binding documentation for the MediaTek DWMAC
found on MediaTek MT2712.
Signed-off-by: Biao Huang <[email protected]>
---
.../devicetree/bindings/net/mediatek-dwmac.txt | 78 ++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt
diff --git a/Documentation/devicetree/bindings/net/mediatek-dwmac.txt b/Documentation/devicetree/bindings/net/mediatek-dwmac.txt
new file mode 100644
index 0000000..9071063
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/mediatek-dwmac.txt
@@ -0,0 +1,78 @@
+MediaTek DWMAC glue layer controller
+
+This file documents platform glue layer for stmmac.
+Please see stmmac.txt for the other unchanged properties.
+
+The device node has following properties.
+
+Required properties:
+- compatible: Should be "mediatek,mt2712-gmac" for MT2712 SoC
+- reg: Address and length of the register set for the device
+- interrupts: Should contain the MAC interrupts
+- interrupt-names: Should contain a list of interrupt names corresponding to
+ the interrupts in the interrupts property, if available.
+ Should be "macirq" for the main MAC IRQ
+- clocks: Must contain a phandle for each entry in clock-names.
+- clock-names: The name of the clock listed in the clocks property. These are
+ "axi", "apb", "mac_main", "ptp_ref" for MT2712 SoC
+- mac-address: See ethernet.txt in the same directory
+- phy-mode: See ethernet.txt in the same directory
+- mediatek,pericfg: A phandle to the syscon node that control ethernet
+ interface and timing delay.
+
+Optional properties:
+- mediatek,tx-delay-ps: TX clock delay macro value. Default is 0.
+ It should be defined for rgmii/rgmii-rxid/mii interface.
+- mediatek,rx-delay-ps: RX clock delay macro value. Default is 0.
+ It should be defined for rgmii/rgmii-txid/mii/rmii interface.
+Both delay properties need to be a multiple of 170 for rgmii interface,
+or will round down. Range 0~31*170.
+Both delay properties need to be a multiple of 550 for mii/rmii interface,
+or will round down. Range 0~31*550.
+
+- mediatek,rmii-rxc: boolean property, if present indicates that the rmii
+ reference clock, which is from external PHYs, is connected to RXC pin
+ on MT2712 SoC.
+ Otherwise, is connected to TXC pin.
+- mediatek,txc-inverse: boolean property, if present indicates that
+ 1. tx clock will be inversed in mii/rgmii case,
+ 2. tx clock inside MAC will be inversed relative to reference clock
+ which is from external PHYs in rmii case, and it rarely happen.
+- mediatek,rxc-inverse: boolean property, if present indicates that
+ 1. rx clock will be inversed in mii/rgmii case.
+ 2. reference clock will be inversed when arrived at MAC in rmii case.
+- assigned-clocks: mac_main and ptp_ref clocks
+- assigned-clock-parents: parent clocks of the assigned clocks
+
+Example:
+ eth: ethernet@1101c000 {
+ compatible = "mediatek,mt2712-gmac";
+ reg = <0 0x1101c000 0 0x1300>;
+ interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-names = "macirq";
+ phy-mode ="rgmii";
+ mac-address = [00 55 7b b5 7d f7];
+ clock-names = "axi",
+ "apb",
+ "mac_main",
+ "ptp_ref",
+ "ptp_top";
+ clocks = <&pericfg CLK_PERI_GMAC>,
+ <&pericfg CLK_PERI_GMAC_PCLK>,
+ <&topckgen CLK_TOP_ETHER_125M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_SEL>;
+ assigned-clocks = <&topckgen CLK_TOP_ETHER_125M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_SEL>;
+ assigned-clock-parents = <&topckgen CLK_TOP_ETHERPLL_125M>,
+ <&topckgen CLK_TOP_APLL1_D3>;
+ mediatek,pericfg = <&pericfg>;
+ mediatek,tx-delay-ps = <1530>;
+ mediatek,rx-delay-ps = <1530>;
+ mediatek,rmii-rxc;
+ mediatek,txc-inverse;
+ mediatek,rxc-inverse;
+ snps,txpbl = <32>;
+ snps,rxpbl = <32>;
+ snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;
+ snps,reset-active-low;
+ };
--
1.7.9.5
1. remove fine-tune property and related setting to simplify
the timing adjustment flow.
2. set timing value according to the value from device tree,
and will not care whether PHY insert internal delay.
Signed-off-by: Biao Huang <[email protected]>
---
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 71 +++++++-------------
1 file changed, 24 insertions(+), 47 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index e400cbd..801c797 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -44,7 +44,6 @@ struct mac_delay_struct {
u32 rx_delay;
bool tx_inv;
bool rx_inv;
- bool fine_tune;
};
struct mediatek_dwmac_plat_data {
@@ -105,16 +104,28 @@ static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
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) {
- /* 170ps per stage for fine tune delay macro circuit*/
- mac_delay->tx_delay /= 170;
- mac_delay->rx_delay /= 170;
- } else {
- /* 550ps per stage for coarse tune delay macro circuit*/
+ struct mac_delay_struct *mac_delay = &plat->mac_delay;
+
+ switch (plat->phy_mode) {
+ case PHY_INTERFACE_MODE_MII:
+ case PHY_INTERFACE_MODE_RMII:
+ /* 550ps per stage for mii/rmii*/
mac_delay->tx_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 mii/rmii*/
+ 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)
struct mac_delay_struct *mac_delay = &plat->mac_delay;
u32 delay_val = 0, fine_val = 0;
- mt2712_delay_ps2stage(mac_delay);
+ mt2712_delay_ps2stage(plat);
switch (plat->phy_mode) {
case PHY_INTERFACE_MODE_MII:
@@ -167,13 +178,10 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
fine_val = ETH_RMII_DLY_TX_INV;
break;
case PHY_INTERFACE_MODE_RGMII:
- /* the PHY is not responsible for inserting any internal
- * delay by itself in PHY_INTERFACE_MODE_RGMII case,
- * so Ethernet MAC will insert delays for both transmit
- * and receive path here.
- */
- if (mac_delay->fine_tune)
- fine_val = ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC;
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ 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_STAGES, mac_delay->tx_delay);
@@ -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_INV, mac_delay->rx_inv);
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:
dev_err(plat->dev, "phy interface not supported\n");
return -EINVAL;
@@ -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->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");
return 0;
--
1.7.9.5
On Mon, Dec 17, 2018 at 6:43 PM Biao Huang <[email protected]> wrote:
>
> 1. remove fine-tune property and related setting to simplify
> the timing adjustment flow.
> 2. set timing value according to the value from device tree,
> and will not care whether PHY insert internal delay.
>
> Signed-off-by: Biao Huang <[email protected]>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 71 +++++++-------------
> 1 file changed, 24 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> index e400cbd..801c797 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
> @@ -44,7 +44,6 @@ struct mac_delay_struct {
> u32 rx_delay;
> bool tx_inv;
> bool rx_inv;
> - bool fine_tune;
> };
>
> struct mediatek_dwmac_plat_data {
> @@ -105,16 +104,28 @@ static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat)
> 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) {
> - /* 170ps per stage for fine tune delay macro circuit*/
> - mac_delay->tx_delay /= 170;
> - mac_delay->rx_delay /= 170;
> - } else {
> - /* 550ps per stage for coarse tune delay macro circuit*/
> + struct mac_delay_struct *mac_delay = &plat->mac_delay;
> +
> + switch (plat->phy_mode) {
> + case PHY_INTERFACE_MODE_MII:
> + case PHY_INTERFACE_MODE_RMII:
> + /* 550ps per stage for mii/rmii*/
> mac_delay->tx_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 mii/rmii*/
mii/rmii appear to be a typo here.
Additionally, I'd suggest using the capital letters for these abbreviations.
> + 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)
> struct mac_delay_struct *mac_delay = &plat->mac_delay;
> u32 delay_val = 0, fine_val = 0;
>
> - mt2712_delay_ps2stage(mac_delay);
> + mt2712_delay_ps2stage(plat);
>
> switch (plat->phy_mode) {
> case PHY_INTERFACE_MODE_MII:
> @@ -167,13 +178,10 @@ static int mt2712_set_delay(struct mediatek_dwmac_plat_data *plat)
> fine_val = ETH_RMII_DLY_TX_INV;
> break;
> case PHY_INTERFACE_MODE_RGMII:
> - /* the PHY is not responsible for inserting any internal
> - * delay by itself in PHY_INTERFACE_MODE_RGMII case,
> - * so Ethernet MAC will insert delays for both transmit
> - * and receive path here.
> - */
> - if (mac_delay->fine_tune)
> - fine_val = ETH_FINE_DLY_GTXC | ETH_FINE_DLY_RXC;
> + case PHY_INTERFACE_MODE_RGMII_TXID:
> + case PHY_INTERFACE_MODE_RGMII_RXID:
> + case PHY_INTERFACE_MODE_RGMII_ID:
> + 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_STAGES, mac_delay->tx_delay);
> @@ -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_INV, mac_delay->rx_inv);
> 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:
> dev_err(plat->dev, "phy interface not supported\n");
> return -EINVAL;
> @@ -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->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");
>
> return 0;
> --
> 1.7.9.5
>
>
> _______________________________________________
> Linux-mediatek mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-mediatek