Commit 6e36145d authored by David S. Miller's avatar David S. Miller

Merge branch 'stmmac'

Giuseppe Cavallaro says:

====================
stmmac: review and fix the dwmac-sti glue-logic

This patch is to review the whole glue logic adopted on STi SoCs that
was bugged.
In the old glue-logic there was a lot of confusion when setup the
retiming especially for STiD127 where, for example, the bits 6 and 7
(in the GMAC  control register) have a different meaning of what is
used for STiH4xx SoCs. So we cannot adopt the same glue for all these
SoCs.
Moreover, GiGa on STiD127 didn't work and, for all the SoCs, the RGMII
couldn't run when the speed was 10Mbps (because the clock was not properly
managed).
Note that the phy clock needs to be provided by the platform as well as
documented in the related binding file (updated as consequence).

The old code supported too many configurations never adopted and validated.
This made the code very complex to maintain and debug in case of issues.

The patch simplifies all the configurations as commented in the tables
inside the file and obviously it has been tested on all the boards
based on the SoCs mentioned.

With this patch, the dwmac-sti is also ready to support new configurations that
will be available on next SoC generations.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8c2a7a5d 53b26b9b
STMicroelectronics SoC DWMAC glue layer controller STMicroelectronics SoC DWMAC glue layer controller
This file documents differences between the core properties in
Documentation/devicetree/bindings/net/stmmac.txt
and what is needed on STi platforms to program the stmmac glue logic.
The device node has following properties. The device node has following properties.
Required properties: Required properties:
- compatible : Can be "st,stih415-dwmac", "st,stih416-dwmac" or - compatible : Can be "st,stih415-dwmac", "st,stih416-dwmac",
"st,stid127-dwmac". "st,stih407-dwmac", "st,stid127-dwmac".
- reg : Offset of the glue configuration register map in system - reg : Offset of the glue configuration register map in system
configuration regmap pointed by st,syscon property and size. configuration regmap pointed by st,syscon property and size.
- reg-names : Should be "sti-ethconf".
- st,syscon : Should be phandle to system configuration node which - st,syscon : Should be phandle to system configuration node which
encompases this glue registers. encompases this glue registers.
- st,gmac_en: this is to enable the gmac into a dedicated sysctl control
register available on STiH407 SoC.
- sti-ethconf: this is the gmac glue logic register to enable the GMAC,
select among the different modes and program the clk retiming.
- pinctrl-0: pin-control for all the MII mode supported.
- st,tx-retime-src: On STi Parts for Giga bit speeds, 125Mhz clocks can be Optional properties:
wired up in from different sources. One via TXCLK pin and other via CLK_125 - resets : phandle pointing to the system reset controller with correct
pin. This wiring is totally board dependent. However the retiming glue reset line index for ethernet reset.
logic should be configured accordingly. Possible values for this property - st,ext-phyclk: valid only for RMII where PHY can generate 50MHz clock or
MAC can generate it.
"txclk" - if 125Mhz clock is wired up via txclk line. - st,tx-retime-src: This specifies which clk is wired up to the mac for
"clk_125" - if 125Mhz clock is wired up via clk_125 line. retimeing tx lines. This is totally board dependent and can take one of the
posssible values from "txclk", "clk_125" or "clkgen".
This property is only valid for Giga bit setup( GMII, RGMII), and it is If not passed, the internal clock will be used by default.
un-used for non-giga bit (MII and RMII) setups. Also note that internal - sti-ethclk: this is the phy clock.
clockgen can not generate stable 125Mhz clock. - sti-clkconf: this is an extra sysconfig register, available in new SoCs,
to program the clk retiming.
- st,ext-phyclk: This boolean property indicates who is generating the clock - st,gmac_en: to enable the GMAC, this only is present in some SoCs; e.g.
for tx and rx. This property is only valid for RMII case where the clock can STiH407.
be generated from the MAC or PHY.
- clock-names: should be "sti-ethclk".
- clocks: Should point to ethernet clockgen which can generate phyclk.
Example: Example:
ethernet0: dwmac@fe810000 { ethernet0: dwmac@9630000 {
device_type = "network"; device_type = "network";
compatible = "st,stih416-dwmac", "snps,dwmac", "snps,dwmac-3.710"; status = "disabled";
reg = <0xfe810000 0x8000>, <0x8bc 0x4>; compatible = "st,stih407-dwmac", "snps,dwmac", "snps,dwmac-3.710";
reg = <0x9630000 0x8000>, <0x80 0x4>;
reg-names = "stmmaceth", "sti-ethconf"; reg-names = "stmmaceth", "sti-ethconf";
interrupts = <0 133 0>, <0 134 0>, <0 135 0>;
interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
phy-mode = "mii";
st,syscon = <&syscfg_rear>; st,syscon = <&syscfg_sbc_reg>;
st,gmac_en;
resets = <&softreset STIH407_ETH1_SOFTRESET>;
reset-names = "stmmaceth";
interrupts = <GIC_SPI 98 IRQ_TYPE_NONE>,
<GIC_SPI 99 IRQ_TYPE_NONE>,
<GIC_SPI 100 IRQ_TYPE_NONE>;
interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
snps,pbl = <32>; snps,pbl = <32>;
snps,mixed-burst; snps,mixed-burst;
resets = <&softreset STIH416_ETH0_SOFTRESET>;
reset-names = "stmmaceth";
pinctrl-0 = <&pinctrl_mii0>;
pinctrl-names = "default"; pinctrl-names = "default";
clocks = <&CLK_S_GMAC0_PHY>; pinctrl-0 = <&pinctrl_rgmii1>;
clock-names = "stmmaceth";
clock-names = "stmmaceth", "sti-ethclk";
clocks = <&CLK_S_C0_FLEXGEN CLK_EXT2F_A9>,
<&CLK_S_C0_FLEXGEN CLK_ETH_PHY>;
}; };
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2003-2014 STMicroelectronics (R&D) Limited * Copyright (C) 2003-2014 STMicroelectronics (R&D) Limited
* Author: Srinivas Kandagatla <srinivas.kandagatla@st.com> * Author: Srinivas Kandagatla <srinivas.kandagatla@st.com>
* * Contributors: Giuseppe Cavallaro <peppe.cavallaro@st.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -22,45 +22,22 @@ ...@@ -22,45 +22,22 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_net.h> #include <linux/of_net.h>
#define DWMAC_125MHZ 125000000
#define DWMAC_50MHZ 50000000
#define DWMAC_25MHZ 25000000
#define DWMAC_2_5MHZ 2500000
#define IS_PHY_IF_MODE_RGMII(iface) (iface == PHY_INTERFACE_MODE_RGMII || \
iface == PHY_INTERFACE_MODE_RGMII_ID || \
iface == PHY_INTERFACE_MODE_RGMII_RXID || \
iface == PHY_INTERFACE_MODE_RGMII_TXID)
#define IS_PHY_IF_MODE_GBIT(iface) (IS_PHY_IF_MODE_RGMII(iface) || \
iface == PHY_INTERFACE_MODE_GMII)
/* STiH4xx register definitions (STiH415/STiH416/STiH407/STiH410 families) */
/** /**
* STi GMAC glue logic.
* --------------------
*
* _
* | \
* --------|0 \ ETH_SEL_INTERNAL_NOTEXT_PHYCLK
* phyclk | |___________________________________________
* | | | (phyclk-in)
* --------|1 / |
* int-clk |_ / |
* | _
* | | \
* |_______|1 \ ETH_SEL_TX_RETIME_CLK
* | |___________________________
* | | (tx-retime-clk)
* _______|0 /
* | |_ /
* _ |
* | \ |
* --------|0 \ |
* clk_125 | |__|
* | | ETH_SEL_TXCLK_NOT_CLK125
* --------|1 /
* txclk |_ /
*
*
* ETH_SEL_INTERNAL_NOTEXT_PHYCLK is valid only for RMII where PHY can
* generate 50MHz clock or MAC can generate it.
* This bit is configured by "st,ext-phyclk" property.
*
* ETH_SEL_TXCLK_NOT_CLK125 is only valid for gigabit modes, where the 125Mhz
* clock either comes from clk-125 pin or txclk pin. This configuration is
* totally driven by the board wiring. This bit is configured by
* "st,tx-retime-src" property.
*
* TXCLK configuration is different for different phy interface modes
* and changes according to link speed in modes like RGMII.
*
* Below table summarizes the clock requirement and clock sources for * Below table summarizes the clock requirement and clock sources for
* supported phy interface modes with link speeds. * supported phy interface modes with link speeds.
* ________________________________________________ * ________________________________________________
...@@ -74,44 +51,58 @@ ...@@ -74,44 +51,58 @@
* ------------------------------------------------ * ------------------------------------------------
*| RGMII | 125Mhz | 25Mhz | *| RGMII | 125Mhz | 25Mhz |
*| | clk-125/txclk | clkgen | *| | clk-125/txclk | clkgen |
*| | clkgen | |
* ------------------------------------------------ * ------------------------------------------------
*| RMII | n/a | 25Mhz | *| RMII | n/a | 25Mhz |
*| | |clkgen/phyclk-in | *| | |clkgen/phyclk-in |
* ------------------------------------------------ * ------------------------------------------------
* *
* TX lines are always retimed with a clk, which can vary depending * Register Configuration
* on the board configuration. Below is the table of these bits *-------------------------------
* in eth configuration register depending on source of retime clk. * src |BIT(8)| BIT(7)| BIT(6)|
* *-------------------------------
*---------------------------------------------------------------
* src | tx_rt_clk | int_not_ext_phyclk | txclk_n_clk125|
*---------------------------------------------------------------
* txclk | 0 | n/a | 1 | * txclk | 0 | n/a | 1 |
*--------------------------------------------------------------- *-------------------------------
* ck_125| 0 | n/a | 0 | * ck_125| 0 | n/a | 0 |
*--------------------------------------------------------------- *-------------------------------
* phyclk| 1 | 0 | n/a | * phyclk| 1 | 0 | n/a |
*--------------------------------------------------------------- *-------------------------------
* clkgen| 1 | 1 | n/a | * clkgen| 1 | 1 | n/a |
*--------------------------------------------------------------- *-------------------------------
*/ */
/* Register definition */ #define STIH4XX_RETIME_SRC_MASK GENMASK(8, 6)
#define STIH4XX_ETH_SEL_TX_RETIME_CLK BIT(8)
#define STIH4XX_ETH_SEL_INTERNAL_NOTEXT_PHYCLK BIT(7)
#define STIH4XX_ETH_SEL_TXCLK_NOT_CLK125 BIT(6)
/* 3 bits [8:6] /* STiD127 register definitions */
* [6:6] ETH_SEL_TXCLK_NOT_CLK125
* [7:7] ETH_SEL_INTERNAL_NOTEXT_PHYCLK /**
* [8:8] ETH_SEL_TX_RETIME_CLK *-----------------------
* * src |BIT(6)| BIT(7)|
*-----------------------
* MII | 1 | n/a |
*-----------------------
* RMII | n/a | 1 |
* clkgen| | |
*-----------------------
* RMII | n/a | 0 |
* phyclk| | |
*-----------------------
* RGMII | 1 | n/a |
* clkgen| | |
*-----------------------
*/ */
#define TX_RETIME_SRC_MASK GENMASK(8, 6) #define STID127_RETIME_SRC_MASK GENMASK(7, 6)
#define ETH_SEL_TX_RETIME_CLK BIT(8) #define STID127_ETH_SEL_INTERNAL_NOTEXT_PHYCLK BIT(7)
#define ETH_SEL_INTERNAL_NOTEXT_PHYCLK BIT(7) #define STID127_ETH_SEL_INTERNAL_NOTEXT_TXCLK BIT(6)
#define ETH_SEL_TXCLK_NOT_CLK125 BIT(6)
#define ENMII_MASK GENMASK(5, 5) #define ENMII_MASK GENMASK(5, 5)
#define ENMII BIT(5) #define ENMII BIT(5)
#define EN_MASK GENMASK(1, 1)
#define EN BIT(1)
/** /**
* 3 bits [4:2] * 3 bits [4:2]
...@@ -127,22 +118,16 @@ ...@@ -127,22 +118,16 @@
#define ETH_PHY_SEL_GMII 0x0 #define ETH_PHY_SEL_GMII 0x0
#define ETH_PHY_SEL_MII 0x0 #define ETH_PHY_SEL_MII 0x0
#define IS_PHY_IF_MODE_RGMII(iface) (iface == PHY_INTERFACE_MODE_RGMII || \
iface == PHY_INTERFACE_MODE_RGMII_ID || \
iface == PHY_INTERFACE_MODE_RGMII_RXID || \
iface == PHY_INTERFACE_MODE_RGMII_TXID)
#define IS_PHY_IF_MODE_GBIT(iface) (IS_PHY_IF_MODE_RGMII(iface) || \
iface == PHY_INTERFACE_MODE_GMII)
struct sti_dwmac { struct sti_dwmac {
int interface; int interface; /* MII interface */
bool ext_phyclk; bool ext_phyclk; /* Clock from external PHY */
bool is_tx_retime_src_clk_125; u32 tx_retime_src; /* TXCLK Retiming*/
struct clk *clk; struct clk *clk; /* PHY clock */
int reg; int ctrl_reg; /* GMAC glue-logic control register */
int clk_sel_reg; /* GMAC ext clk selection register */
struct device *dev; struct device *dev;
struct regmap *regmap; struct regmap *regmap;
u32 speed;
}; };
static u32 phy_intf_sels[] = { static u32 phy_intf_sels[] = {
...@@ -162,74 +147,133 @@ enum { ...@@ -162,74 +147,133 @@ enum {
TX_RETIME_SRC_CLKGEN, TX_RETIME_SRC_CLKGEN,
}; };
static const char *const tx_retime_srcs[] = { static u32 stih4xx_tx_retime_val[] = {
[TX_RETIME_SRC_NA] = "", [TX_RETIME_SRC_TXCLK] = STIH4XX_ETH_SEL_TXCLK_NOT_CLK125,
[TX_RETIME_SRC_TXCLK] = "txclk",
[TX_RETIME_SRC_CLK_125] = "clk_125",
[TX_RETIME_SRC_PHYCLK] = "phyclk",
[TX_RETIME_SRC_CLKGEN] = "clkgen",
};
static u32 tx_retime_val[] = {
[TX_RETIME_SRC_TXCLK] = ETH_SEL_TXCLK_NOT_CLK125,
[TX_RETIME_SRC_CLK_125] = 0x0, [TX_RETIME_SRC_CLK_125] = 0x0,
[TX_RETIME_SRC_PHYCLK] = ETH_SEL_TX_RETIME_CLK, [TX_RETIME_SRC_PHYCLK] = STIH4XX_ETH_SEL_TX_RETIME_CLK,
[TX_RETIME_SRC_CLKGEN] = ETH_SEL_TX_RETIME_CLK | [TX_RETIME_SRC_CLKGEN] = STIH4XX_ETH_SEL_TX_RETIME_CLK
ETH_SEL_INTERNAL_NOTEXT_PHYCLK, | STIH4XX_ETH_SEL_INTERNAL_NOTEXT_PHYCLK,
}; };
static void setup_retime_src(struct sti_dwmac *dwmac, u32 spd) static void stih4xx_fix_retime_src(void *priv, u32 spd)
{ {
u32 src = 0, freq = 0; struct sti_dwmac *dwmac = priv;
u32 src = dwmac->tx_retime_src;
u32 reg = dwmac->ctrl_reg;
u32 freq = 0;
if (spd == SPEED_100) { if (dwmac->interface == PHY_INTERFACE_MODE_MII) {
if (dwmac->interface == PHY_INTERFACE_MODE_MII ||
dwmac->interface == PHY_INTERFACE_MODE_GMII) {
src = TX_RETIME_SRC_TXCLK; src = TX_RETIME_SRC_TXCLK;
} else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) { } else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) {
if (dwmac->ext_phyclk) { if (dwmac->ext_phyclk) {
src = TX_RETIME_SRC_PHYCLK; src = TX_RETIME_SRC_PHYCLK;
} else { } else {
src = TX_RETIME_SRC_CLKGEN; src = TX_RETIME_SRC_CLKGEN;
freq = 50000000; freq = DWMAC_50MHZ;
} }
} else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) {
/* On GiGa clk source can be either ext or from clkgen */
if (spd == SPEED_1000) {
freq = DWMAC_125MHZ;
} else {
/* Switch to clkgen for these speeds */
src = TX_RETIME_SRC_CLKGEN; src = TX_RETIME_SRC_CLKGEN;
freq = 25000000; if (spd == SPEED_100)
freq = DWMAC_25MHZ;
else if (spd == SPEED_10)
freq = DWMAC_2_5MHZ;
}
} }
if (src == TX_RETIME_SRC_CLKGEN && dwmac->clk) if (src == TX_RETIME_SRC_CLKGEN && dwmac->clk && freq)
clk_set_rate(dwmac->clk, freq); clk_set_rate(dwmac->clk, freq);
} else if (spd == SPEED_1000) { regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK,
if (dwmac->is_tx_retime_src_clk_125) stih4xx_tx_retime_val[src]);
src = TX_RETIME_SRC_CLK_125; }
else
src = TX_RETIME_SRC_TXCLK; static void stid127_fix_retime_src(void *priv, u32 spd)
{
struct sti_dwmac *dwmac = priv;
u32 reg = dwmac->ctrl_reg;
u32 freq = 0;
u32 val = 0;
if (dwmac->interface == PHY_INTERFACE_MODE_MII) {
val = STID127_ETH_SEL_INTERNAL_NOTEXT_TXCLK;
} else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) {
if (!dwmac->ext_phyclk) {
val = STID127_ETH_SEL_INTERNAL_NOTEXT_PHYCLK;
freq = DWMAC_50MHZ;
} }
} else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) {
val = STID127_ETH_SEL_INTERNAL_NOTEXT_TXCLK;
if (spd == SPEED_1000)
freq = DWMAC_125MHZ;
else if (spd == SPEED_100)
freq = DWMAC_25MHZ;
else if (spd == SPEED_10)
freq = DWMAC_2_5MHZ;
}
if (dwmac->clk && freq)
clk_set_rate(dwmac->clk, freq);
regmap_update_bits(dwmac->regmap, dwmac->reg, regmap_update_bits(dwmac->regmap, reg, STID127_RETIME_SRC_MASK, val);
TX_RETIME_SRC_MASK, tx_retime_val[src]);
} }
static void sti_dwmac_exit(struct platform_device *pdev, void *priv) static void sti_dwmac_ctrl_init(struct sti_dwmac *dwmac)
{ {
struct sti_dwmac *dwmac = priv; struct regmap *regmap = dwmac->regmap;
int iface = dwmac->interface;
struct device *dev = dwmac->dev;
struct device_node *np = dev->of_node;
u32 reg = dwmac->ctrl_reg;
u32 val;
if (dwmac->clk) if (dwmac->clk)
clk_disable_unprepare(dwmac->clk); clk_prepare_enable(dwmac->clk);
if (of_property_read_bool(np, "st,gmac_en"))
regmap_update_bits(regmap, reg, EN_MASK, EN);
regmap_update_bits(regmap, reg, MII_PHY_SEL_MASK, phy_intf_sels[iface]);
val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
regmap_update_bits(regmap, reg, ENMII_MASK, val);
}
static int stix4xx_init(struct platform_device *pdev, void *priv)
{
struct sti_dwmac *dwmac = priv;
u32 spd = dwmac->speed;
sti_dwmac_ctrl_init(dwmac);
stih4xx_fix_retime_src(priv, spd);
return 0;
} }
static void sti_fix_mac_speed(void *priv, unsigned int spd) static int stid127_init(struct platform_device *pdev, void *priv)
{ {
struct sti_dwmac *dwmac = priv; struct sti_dwmac *dwmac = priv;
u32 spd = dwmac->speed;
setup_retime_src(dwmac, spd); sti_dwmac_ctrl_init(dwmac);
return; stid127_fix_retime_src(priv, spd);
return 0;
} }
static void sti_dwmac_exit(struct platform_device *pdev, void *priv)
{
struct sti_dwmac *dwmac = priv;
if (dwmac->clk)
clk_disable_unprepare(dwmac->clk);
}
static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
struct platform_device *pdev) struct platform_device *pdev)
{ {
...@@ -245,6 +289,13 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, ...@@ -245,6 +289,13 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-ethconf"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-ethconf");
if (!res) if (!res)
return -ENODATA; return -ENODATA;
dwmac->ctrl_reg = res->start;
/* clk selection from extra syscfg register */
dwmac->clk_sel_reg = -ENXIO;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-clkconf");
if (res)
dwmac->clk_sel_reg = res->start;
regmap = syscon_regmap_lookup_by_phandle(np, "st,syscon"); regmap = syscon_regmap_lookup_by_phandle(np, "st,syscon");
if (IS_ERR(regmap)) if (IS_ERR(regmap))
...@@ -253,53 +304,31 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, ...@@ -253,53 +304,31 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
dwmac->dev = dev; dwmac->dev = dev;
dwmac->interface = of_get_phy_mode(np); dwmac->interface = of_get_phy_mode(np);
dwmac->regmap = regmap; dwmac->regmap = regmap;
dwmac->reg = res->start;
dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk");
dwmac->is_tx_retime_src_clk_125 = false; dwmac->tx_retime_src = TX_RETIME_SRC_NA;
dwmac->speed = SPEED_100;
if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) { if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) {
const char *rs; const char *rs;
dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN;
err = of_property_read_string(np, "st,tx-retime-src", &rs); err = of_property_read_string(np, "st,tx-retime-src", &rs);
if (err < 0) { if (err < 0)
dev_err(dev, "st,tx-retime-src not specified\n"); dev_warn(dev, "Use internal clock source\n");
return err;
}
if (!strcasecmp(rs, "clk_125")) if (!strcasecmp(rs, "clk_125"))
dwmac->is_tx_retime_src_clk_125 = true; dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125;
else if (!strcasecmp(rs, "txclk"))
dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK;
dwmac->speed = SPEED_1000;
} }
dwmac->clk = devm_clk_get(dev, "sti-ethclk"); dwmac->clk = devm_clk_get(dev, "sti-ethclk");
if (IS_ERR(dwmac->clk)) {
if (IS_ERR(dwmac->clk)) dev_warn(dev, "No phy clock provided...\n");
dwmac->clk = NULL; dwmac->clk = NULL;
}
return 0;
}
static int sti_dwmac_init(struct platform_device *pdev, void *priv)
{
struct sti_dwmac *dwmac = priv;
struct regmap *regmap = dwmac->regmap;
int iface = dwmac->interface;
u32 reg = dwmac->reg;
u32 val, spd;
if (dwmac->clk)
clk_prepare_enable(dwmac->clk);
regmap_update_bits(regmap, reg, MII_PHY_SEL_MASK, phy_intf_sels[iface]);
val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
regmap_update_bits(regmap, reg, ENMII_MASK, val);
if (IS_PHY_IF_MODE_GBIT(iface))
spd = SPEED_1000;
else
spd = SPEED_100;
setup_retime_src(dwmac, spd);
return 0; return 0;
} }
...@@ -322,9 +351,16 @@ static void *sti_dwmac_setup(struct platform_device *pdev) ...@@ -322,9 +351,16 @@ static void *sti_dwmac_setup(struct platform_device *pdev)
return dwmac; return dwmac;
} }
const struct stmmac_of_data sti_gmac_data = { const struct stmmac_of_data stih4xx_dwmac_data = {
.fix_mac_speed = sti_fix_mac_speed, .fix_mac_speed = stih4xx_fix_retime_src,
.setup = sti_dwmac_setup,
.init = stix4xx_init,
.exit = sti_dwmac_exit,
};
const struct stmmac_of_data stid127_dwmac_data = {
.fix_mac_speed = stid127_fix_retime_src,
.setup = sti_dwmac_setup, .setup = sti_dwmac_setup,
.init = sti_dwmac_init, .init = stid127_init,
.exit = sti_dwmac_exit, .exit = sti_dwmac_exit,
}; };
...@@ -40,6 +40,7 @@ static const struct of_device_id stmmac_dt_ids[] = { ...@@ -40,6 +40,7 @@ static const struct of_device_id stmmac_dt_ids[] = {
{ .compatible = "st,stih415-dwmac", .data = &sti_gmac_data}, { .compatible = "st,stih415-dwmac", .data = &sti_gmac_data},
{ .compatible = "st,stih416-dwmac", .data = &sti_gmac_data}, { .compatible = "st,stih416-dwmac", .data = &sti_gmac_data},
{ .compatible = "st,stid127-dwmac", .data = &sti_gmac_data}, { .compatible = "st,stid127-dwmac", .data = &sti_gmac_data},
{ .compatible = "st,stih407-dwmac", .data = &sti_gmac_data},
#endif #endif
#ifdef CONFIG_DWMAC_SOCFPGA #ifdef CONFIG_DWMAC_SOCFPGA
{ .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_data }, { .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_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