rockchip: rk3288: Add clock support for the gmac ethernet interface
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Sun, 28 Feb 2016 21:24:59 +0000 (22:24 +0100)
committerSimon Glass <sjg@chromium.org>
Fri, 27 May 2016 15:00:48 +0000 (09:00 -0600)
Setup the clocks for the gmac ethernet interface. This assumes the mac
clock is fed by an external clock which is common on RK3288 based
devices.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/arm/include/asm/arch-rockchip/cru_rk3288.h
drivers/clk/clk_rk3288.c

index d2690c77886bee5395e81e71d67cd1dc4571c2b6..8a8ca9c9aad9e6d026eec291222ad1fd6a85f9f1 100644 (file)
@@ -90,6 +90,23 @@ enum {
        SDIO0_DIV_MASK          = 0x3f,
 };
 
+/* CRU_CLKSEL21_CON */
+enum {
+       MAC_DIV_CON_SHIFT = 0xf,
+       MAC_DIV_CON_MASK = 0x1f,
+
+       RMII_EXTCLK_SHIFT = 4,
+       RMII_EXTCLK_MASK = 1,
+       RMII_EXTCLK_SELECT_INT_DIV_CLK = 0,
+       RMII_EXTCLK_SELECT_EXT_CLK = 1,
+
+       EMAC_PLL_SHIFT = 0,
+       EMAC_PLL_MASK = 0x3,
+       EMAC_PLL_SELECT_NEW = 0x0,
+       EMAC_PLL_SELECT_CODEC = 0x1,
+       EMAC_PLL_SELECT_GENERAL = 0x2,
+};
+
 /* CRU_CLKSEL25_CON */
 enum {
        SPI1_PLL_SHIFT          = 0xf,
index 2a85e93a6cc3f534ac165e17343de18344c43619..a110a1c160e3d89d2cbe649d8aefa7970afb9030 100644 (file)
@@ -326,6 +326,17 @@ static int pll_para_config(ulong freq_hz, struct pll_div *div, uint *ext_div)
        return 0;
 }
 
+static int rockchip_mac_set_clk(struct rk3288_cru *cru,
+                                 int periph, uint freq)
+{
+       /* Assuming mac_clk is fed by an external clock */
+       rk_clrsetreg(&cru->cru_clksel_con[21],
+                    RMII_EXTCLK_MASK << RMII_EXTCLK_SHIFT,
+                    RMII_EXTCLK_SELECT_EXT_CLK << RMII_EXTCLK_SHIFT);
+
+        return 0;
+}
+
 static int rockchip_vop_set_clk(struct rk3288_cru *cru, struct rk3288_grf *grf,
                                int periph, unsigned int rate_hz)
 {
@@ -759,6 +770,9 @@ static ulong rk3288_set_periph_rate(struct udevice *dev, int periph, ulong rate)
                new_rate = rockchip_spi_set_clk(cru, gclk_rate, periph, rate);
                break;
 #ifndef CONFIG_SPL_BUILD
+       case SCLK_MAC:
+               new_rate = rockchip_mac_set_clk(priv->cru, periph, rate);
+               break;
        case DCLK_VOP0:
        case DCLK_VOP1:
                new_rate = rockchip_vop_set_clk(cru, priv->grf, periph, rate);