newton: add irda suspend and resume functions

This commit is contained in:
lyx
2011-07-06 00:53:38 -07:00
parent 42df56ac6d
commit 2194013403
2 changed files with 106 additions and 32 deletions

View File

@@ -128,8 +128,8 @@ int irda_hw_shutdown(struct rk29_irda *si)
//PWR/FIT (default)
BU92725GUW_WRITE_REG(REG_PWR_FIT_ADDR, REG_PWR_FIT_MPW_3 | REG_PWR_FIT_FPW_2 | REG_PWR_FIT_FIT_0);
//TRCR (idle, clr fifo, IrDA power down)
BU92725GUW_WRITE_REG(REG_TRCR_ADDR, REG_TRCR_FCLR | REG_TRCR_IRPD);
//TRCR (idle, clr fifo, IrDA , rx, tx power down)
BU92725GUW_WRITE_REG(REG_TRCR_ADDR, REG_TRCR_FCLR | REG_TRCR_IRPD |REG_TRCR_TXPWD | REG_TRCR_RXPWD);
//FTLV
BU92725GUW_WRITE_REG(REG_FTLV_ADDR, 0x0000);
@@ -660,34 +660,6 @@ static void internal_set(u8 modeChg)
}
}
/* TRCR */
switch (curTrans_way) {
case BU92725GUW_IDLE:
val = 0x0000;
break;
case BU92725GUW_REV:
case BU92725GUW_MIR_REV:
case BU92725GUW_FIR_REV:
val = REG_TRCR_RX_EN;
break;
case BU92725GUW_AUTO_MULTI_REV:
val = REG_TRCR_RX_EN | REG_TRCR_AUTO_FLV_CP;
break;
case BU92725GUW_MULTI_REV:
val = REG_TRCR_RX_EN | REG_TRCR_RX_CON;//FIR
break;
case BU92725GUW_SEND:
case BU92725GUW_MIR_SEND:
case BU92725GUW_FIR_SEND:
val = 0x0000;
break;
case BU92725GUW_MULTI_SEND:
val = REG_TRCR_TX_CON;
break;
}
BU92725GUW_WRITE_REG(REG_TRCR_ADDR, val);
RK29IR_DBG("REG_TRCR_ADDR: 0x%x\n", val);
/* IER */
switch (curTrans_way) {
case BU92725GUW_IDLE:
@@ -734,6 +706,34 @@ static void internal_set(u8 modeChg)
BU92725GUW_WRITE_REG(REG_IER_ADDR, val);
RK29IR_DBG("REG_IER_ADDR: 0x%x\n", val);
/* TRCR */
switch (curTrans_way) {
case BU92725GUW_IDLE:
val = 0x0000;
break;
case BU92725GUW_REV:
case BU92725GUW_MIR_REV:
case BU92725GUW_FIR_REV:
val = REG_TRCR_RX_EN;
break;
case BU92725GUW_AUTO_MULTI_REV:
val = REG_TRCR_RX_EN | REG_TRCR_AUTO_FLV_CP;
break;
case BU92725GUW_MULTI_REV:
val = REG_TRCR_RX_EN | REG_TRCR_RX_CON;//FIR
break;
case BU92725GUW_SEND:
case BU92725GUW_MIR_SEND:
case BU92725GUW_FIR_SEND:
val = 0x0000;
break;
case BU92725GUW_MULTI_SEND:
val = REG_TRCR_TX_CON;
break;
}
BU92725GUW_WRITE_REG(REG_TRCR_ADDR, val);
RK29IR_DBG("REG_TRCR_ADDR: 0x%x\n", val);
}

View File

@@ -378,6 +378,8 @@ static int rk29_irda_start(struct net_device *dev)
err_irlap:
si->open = 0;
irda_hw_shutdown(si);
if (si->pdata->irda_pwr_ctl)
si->pdata->irda_pwr_ctl(0);
err_startup:
free_irq(dev->irq, dev);
err_irq:
@@ -678,6 +680,78 @@ static int rk29_irda_remove(struct platform_device *pdev)
return 0;
}
#ifdef CONFIG_PM
/*
* Suspend the IrDA interface.
*/
static int rk29_irda_suspend(struct platform_device *pdev, pm_message_t state)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct rk29_irda *si;
if (!dev)
return 0;
si = netdev_priv(dev);
if (si->open) {
/*
* Stop the transmit queue
*/
netif_device_detach(dev);
disable_irq(dev->irq);
irda_hw_shutdown(si);
if (si->pdata->irda_pwr_ctl)
si->pdata->irda_pwr_ctl(0);
}
return 0;
}
/*
* Resume the IrDA interface.
*/
static int rk29_irda_resume(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct rk29_irda *si;
if (!dev)
return 0;
si = netdev_priv(dev);
if (si->open) {
if (si->pdata->irda_pwr_ctl)
si->pdata->irda_pwr_ctl(1);
/*
* If we missed a speed change, initialise at the new speed
* directly. It is debatable whether this is actually
* required, but in the interests of continuing from where
* we left off it is desireable. The converse argument is
* that we should re-negotiate at 9600 baud again.
*/
if (si->newspeed) {
si->speed = si->newspeed;
si->newspeed = 0;
}
irda_hw_startup(si);
enable_irq(dev->irq);
/*
* This automatically wakes up the queue
*/
netif_device_attach(dev);
}
return 0;
}
#else
#define rk29_irda_suspend NULL
#define rk29_irda_resume NULL
#endif
static struct platform_driver irda_driver = {
.driver = {
@@ -686,8 +760,8 @@ static struct platform_driver irda_driver = {
},
.probe = rk29_irda_probe,
.remove = rk29_irda_remove,
//.suspend = rk29_irda_suspend,
//.resume = rk29_irda_resume,
.suspend = rk29_irda_suspend,
.resume = rk29_irda_resume,
};
static int __init irda_init(void)