From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 16 Oct 2018 11:22:47 +0200 Subject: [U-Boot] [PATCH v4 08/13] net: ftgmac100: add clock support In-Reply-To: <20181016092252.11664-1-clg@kaod.org> References: <20181016092252.11664-1-clg@kaod.org> Message-ID: <20181016092252.11664-9-clg@kaod.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Joel Stanley Acked-by: Joe Hershberger --- drivers/net/ftgmac100.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index 9adfe109ebc2..e1104a544748 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -11,6 +11,7 @@ * Copyright (C) 2018, IBM Corporation. */ =20 +#include #include #include #include @@ -55,6 +56,7 @@ * @bus: The mdio bus * @phy_mode: The mode of the PHY interface (rgmii, rmii, ...) * @max_speed: Maximum speed of Ethernet connection supported by MAC + * @clks: The bulk of clocks assigned to the device in the DT */ struct ftgmac100_data { struct ftgmac100 *iobase; @@ -69,6 +71,8 @@ struct ftgmac100_data { struct mii_dev *bus; u32 phy_mode; u32 max_speed; + + struct clk_bulk clks; }; =20 /* @@ -509,6 +513,7 @@ static int ftgmac100_write_hwaddr(struct udevice *dev) static int ftgmac100_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata =3D dev_get_platdata(dev); + struct ftgmac100_data *priv =3D dev_get_priv(dev); const char *phy_mode; =20 pdata->iobase =3D devfdt_get_addr(dev); @@ -523,7 +528,7 @@ static int ftgmac100_ofdata_to_platdata(struct udevice = *dev) =20 pdata->max_speed =3D dev_read_u32_default(dev, "max-speed", 0); =20 - return 0; + return clk_get_bulk(dev, &priv->clks); } =20 static int ftgmac100_probe(struct udevice *dev) @@ -537,6 +542,10 @@ static int ftgmac100_probe(struct udevice *dev) priv->max_speed =3D pdata->max_speed; priv->phy_addr =3D 0; =20 + ret =3D clk_enable_bulk(&priv->clks); + if (ret) + goto out; + ret =3D ftgmac100_mdio_init(dev); if (ret) { dev_err(dev, "Failed to initialize mdiobus: %d\n", ret); @@ -550,6 +559,9 @@ static int ftgmac100_probe(struct udevice *dev) } =20 out: + if (ret) + clk_release_bulk(&priv->clks); + return ret; } =20 @@ -560,6 +572,7 @@ static int ftgmac100_remove(struct udevice *dev) free(priv->phydev); mdio_unregister(priv->bus); mdio_free(priv->bus); + clk_release_bulk(&priv->clks); =20 return 0; } --=20 2.17.2