net: stmmac: dwmac-rk: Add integrated PHY support for rk3228
authorDavid Wu <david.wu@rock-chips.com>
Thu, 10 Aug 2017 14:00:25 +0000 (22:00 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Aug 2017 21:28:58 +0000 (14:28 -0700)
There is only one mac controller in rk3228, which could connect to
external PHY or integrated PHY, use the grf_com_mux bit15 to route
external/integrated PHY.

Signed-off-by: David Wu <david.wu@rock-chips.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c

index 90199175cf2c0f2c40865230e757cc78c1b11afe..b6db3ff38606d4212691f61bc09e4c40be8d634e 100644 (file)
@@ -86,6 +86,8 @@ struct rk_priv_data {
 #define RK3228_GRF_MAC_CON0    0x0900
 #define RK3228_GRF_MAC_CON1    0x0904
 
+#define RK3228_GRF_CON_MUX     0x50
+
 /* RK3228_GRF_MAC_CON0 */
 #define RK3228_GMAC_CLK_RX_DL_CFG(val) HIWORD_UPDATE(val, 0x7F, 7)
 #define RK3228_GMAC_CLK_TX_DL_CFG(val) HIWORD_UPDATE(val, 0x7F, 0)
@@ -111,6 +113,9 @@ struct rk_priv_data {
 #define RK3228_GMAC_RXCLK_DLY_ENABLE   GRF_BIT(1)
 #define RK3228_GMAC_RXCLK_DLY_DISABLE  GRF_CLR_BIT(1)
 
+/* RK3228_GRF_COM_MUX */
+#define RK3228_GRF_CON_MUX_GMAC_INTEGRATED_PHY GRF_BIT(15)
+
 static void rk3228_set_to_rgmii(struct rk_priv_data *bsp_priv,
                                int tx_delay, int rx_delay)
 {
@@ -191,11 +196,18 @@ static void rk3228_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
                dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
 }
 
+static void rk3228_integrated_phy_powerup(struct rk_priv_data *priv)
+{
+       regmap_write(priv->grf, RK3228_GRF_CON_MUX,
+                    RK3228_GRF_CON_MUX_GMAC_INTEGRATED_PHY);
+}
+
 static const struct rk_gmac_ops rk3228_ops = {
        .set_to_rgmii = rk3228_set_to_rgmii,
        .set_to_rmii = rk3228_set_to_rmii,
        .set_rgmii_speed = rk3228_set_rgmii_speed,
        .set_rmii_speed = rk3228_set_rmii_speed,
+       .integrated_phy_powerup =  rk3228_integrated_phy_powerup,
 };
 
 #define RK3288_GRF_SOC_CON1    0x0248