We can use sleeping functions when reading and writing the
PHY registers, so let us sleep instead of busy waiting for
the PHY.
Note, this also fixes a bug reading the PHY where only 100uS
was being used instead of 150uS
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
unsigned int flags;
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
unsigned int flags;
+ unsigned int in_suspend :1;
+/*
+ * Sleep, either by using msleep() or if we are suspending, then
+ * use mdelay() to sleep.
+ */
+static void dm9000_msleep(board_info_t *db, unsigned int ms)
+{
+ if (db->in_suspend)
+ mdelay(ms);
+ else
+ msleep(ms);
+}
+
/*
* Read a word from phyxcer
*/
/*
* Read a word from phyxcer
*/
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
- udelay(100); /* Wait read complete */
+ dm9000_msleep(db, 1); /* Wait read complete */
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
writeb(reg_save, db->io_addr);
spin_unlock_irqrestore(&db->lock,flags);
- udelay(500); /* Wait write complete */
+ dm9000_msleep(db, 1); /* Wait write complete */
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
spin_lock_irqsave(&db->lock,flags);
reg_save = readb(db->io_addr);
dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
{
struct net_device *ndev = platform_get_drvdata(dev);
dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
{
struct net_device *ndev = platform_get_drvdata(dev);
+ db = (board_info_t *) ndev->priv;
+ db->in_suspend = 1;
+
if (netif_running(ndev)) {
netif_device_detach(ndev);
dm9000_shutdown(ndev);
if (netif_running(ndev)) {
netif_device_detach(ndev);
dm9000_shutdown(ndev);
netif_device_attach(ndev);
}
netif_device_attach(ndev);
}