[U-Boot] [PATCH 31/52] rockchip: pinctrl: rk3368: add GMAC (RGMII only) support

Philipp Tomsich philipp.tomsich at theobroma-systems.com
Tue Jul 18 20:36:11 UTC 2017


To add GMAC (Gigabit Ethernet) support (limited to RGMII only at this
point), we need support for additional pin-configuration.  This commit
adds the pinctrl support for GMAC in RGMII mode:
 * adds a PERIPH_ID_GMAC and the mapping from IRQ number to PERIPH_ID
 * configures the RGMII pins

Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
---

 drivers/pinctrl/rockchip/pinctrl_rk3368.c | 36 +++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3368.c b/drivers/pinctrl/rockchip/pinctrl_rk3368.c
index b77c5ab..aecd11d 100644
--- a/drivers/pinctrl/rockchip/pinctrl_rk3368.c
+++ b/drivers/pinctrl/rockchip/pinctrl_rk3368.c
@@ -54,6 +54,33 @@ static void pinctrl_rk3368_uart_config(struct rk3368_pinctrl_priv *priv,
 	}
 }
 
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
+static void pinctrl_rk3368_gmac_config(struct rk3368_grf *grf, int gmac_id)
+{
+	rk_clrsetreg(&grf->gpio3b_iomux,
+		     RK3368_GPIO3B0_MASK | RK3368_GPIO3B1_MASK |
+		     RK3368_GPIO3B2_MASK | RK3368_GPIO3B5_MASK |
+		     RK3368_GPIO3B6_MASK | RK3368_GPIO3B7_MASK,
+		     RK3368_GPIO3B0_MAC_TXD0 | RK3368_GPIO3B1_MAC_TXD1 |
+		     RK3368_GPIO3B2_MAC_TXD2 | RK3368_GPIO3B5_MAC_TXEN |
+		     RK3368_GPIO3B6_MAC_TXD3 | RK3368_GPIO3B7_MAC_RXD0);
+	rk_clrsetreg(&grf->gpio3c_iomux,
+		     RK3368_GPIO3C0_MASK | RK3368_GPIO3C1_MASK |
+		     RK3368_GPIO3C2_MASK | RK3368_GPIO3C3_MASK |
+		     RK3368_GPIO3C4_MASK | RK3368_GPIO3C5_MASK |
+		     RK3368_GPIO3C6_MASK,
+		     RK3368_GPIO3C0_MAC_RXD1 | RK3368_GPIO3C1_MAC_RXD2 |
+		     RK3368_GPIO3C2_MAC_RXD3 | RK3368_GPIO3C3_MAC_MDC |
+		     RK3368_GPIO3C4_MAC_RXDV | RK3368_GPIO3C5_MAC_RXEN |
+		     RK3368_GPIO3C6_MAC_CLK);
+	rk_clrsetreg(&grf->gpio3d_iomux,
+		     RK3368_GPIO3D0_MASK | RK3368_GPIO3D1_MASK |
+		     RK3368_GPIO3D4_MASK,
+		     RK3368_GPIO3D0_MAC_MDIO | RK3368_GPIO3D1_MAC_RXCLK |
+		     RK3368_GPIO3D4_MAC_TXCLK);
+}
+#endif
+
 static int rk3368_pinctrl_request(struct udevice *dev, int func, int flags)
 {
 	struct rk3368_pinctrl_priv *priv = dev_get_priv(dev);
@@ -67,6 +94,11 @@ static int rk3368_pinctrl_request(struct udevice *dev, int func, int flags)
 	case PERIPH_ID_UART4:
 		pinctrl_rk3368_uart_config(priv, func);
 		break;
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
+	case PERIPH_ID_GMAC:
+		pinctrl_rk3368_gmac_config(priv->grf, func);
+		break;
+#endif
 	default:
 		return -EINVAL;
 	}
@@ -96,6 +128,10 @@ static int rk3368_pinctrl_get_periph_id(struct udevice *dev,
 		return PERIPH_ID_UART1;
 	case 55:
 		return PERIPH_ID_UART0;
+#if CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
+	case 27:
+		return PERIPH_ID_GMAC;
+#endif
 	}
 
 	return -ENOENT;
-- 
2.1.4



More information about the U-Boot mailing list