|
@@ -10,6 +10,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include <common.h>
|
|
#include <common.h>
|
|
|
|
+#include <clk.h>
|
|
#include <dm.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <errno.h>
|
|
#include <miiphy.h>
|
|
#include <miiphy.h>
|
|
@@ -120,6 +121,7 @@ struct ravb_priv {
|
|
struct phy_device *phydev;
|
|
struct phy_device *phydev;
|
|
struct mii_dev *bus;
|
|
struct mii_dev *bus;
|
|
void __iomem *iobase;
|
|
void __iomem *iobase;
|
|
|
|
+ struct clk clk;
|
|
};
|
|
};
|
|
|
|
|
|
static inline void ravb_flush_dcache(u32 addr, u32 len)
|
|
static inline void ravb_flush_dcache(u32 addr, u32 len)
|
|
@@ -432,27 +434,38 @@ int ravb_start(struct udevice *dev)
|
|
struct ravb_priv *eth = dev_get_priv(dev);
|
|
struct ravb_priv *eth = dev_get_priv(dev);
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
- ret = ravb_reset(dev);
|
|
|
|
|
|
+ ret = clk_enable(ð->clk);
|
|
if (ret)
|
|
if (ret)
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
|
|
+ ret = ravb_reset(dev);
|
|
|
|
+ if (ret)
|
|
|
|
+ goto err;
|
|
|
|
+
|
|
ravb_base_desc_init(eth);
|
|
ravb_base_desc_init(eth);
|
|
ravb_tx_desc_init(eth);
|
|
ravb_tx_desc_init(eth);
|
|
ravb_rx_desc_init(eth);
|
|
ravb_rx_desc_init(eth);
|
|
|
|
|
|
ret = ravb_config(dev);
|
|
ret = ravb_config(dev);
|
|
if (ret)
|
|
if (ret)
|
|
- return ret;
|
|
|
|
|
|
+ goto err;
|
|
|
|
|
|
/* Setting the control will start the AVB-DMAC process. */
|
|
/* Setting the control will start the AVB-DMAC process. */
|
|
writel(CCC_OPC_OPERATION, eth->iobase + RAVB_REG_CCC);
|
|
writel(CCC_OPC_OPERATION, eth->iobase + RAVB_REG_CCC);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
|
+
|
|
|
|
+err:
|
|
|
|
+ clk_disable(ð->clk);
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
static void ravb_stop(struct udevice *dev)
|
|
static void ravb_stop(struct udevice *dev)
|
|
{
|
|
{
|
|
|
|
+ struct ravb_priv *eth = dev_get_priv(dev);
|
|
|
|
+
|
|
ravb_reset(dev);
|
|
ravb_reset(dev);
|
|
|
|
+ clk_disable(ð->clk);
|
|
}
|
|
}
|
|
|
|
|
|
static int ravb_probe(struct udevice *dev)
|
|
static int ravb_probe(struct udevice *dev)
|
|
@@ -466,6 +479,10 @@ static int ravb_probe(struct udevice *dev)
|
|
iobase = map_physmem(pdata->iobase, 0x1000, MAP_NOCACHE);
|
|
iobase = map_physmem(pdata->iobase, 0x1000, MAP_NOCACHE);
|
|
eth->iobase = iobase;
|
|
eth->iobase = iobase;
|
|
|
|
|
|
|
|
+ ret = clk_get_by_index(dev, 0, ð->clk);
|
|
|
|
+ if (ret < 0)
|
|
|
|
+ goto err_mdio_alloc;
|
|
|
|
+
|
|
mdiodev = mdio_alloc();
|
|
mdiodev = mdio_alloc();
|
|
if (!mdiodev) {
|
|
if (!mdiodev) {
|
|
ret = -ENOMEM;
|
|
ret = -ENOMEM;
|