Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1248491
  • 博文数量: 261
  • 博客积分: 4196
  • 博客等级: 上校
  • 技术积分: 3410
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-17 17:05
文章分类

全部博文(261)

文章存档

2018年(1)

2017年(22)

2016年(2)

2015年(8)

2014年(27)

2013年(40)

2012年(161)

分类: LINUX

2012-11-13 11:19:15

#include

... ...

#define PECR_IE(n)      ((1 << ((n) * 2)) << 28)
#define PECR_IS(n)      ((1 << ((n) * 2)) << 29)

#define PECR_E0IS    (1 << 29)    // EXT_WAKEUP<0> Interrupt Status
#define PECR_E0IE    (1 << 28)    // EXT_WAKEUP<0> Pin Interrupt Enable
#define PECR_DIR0    (1 << 4)    //Direction for EXT_WAKEUP<0>: 0/1= input/output
#define PECR_IVE0    (1 << 0)    //Input Value for EXT_WAKEUP<0>

//Currently we have
#define IRQ_WAKEUP0    PXA_IRQ(49)    /* EXT_WAKEUP0 */
#define IRQ_WAKEUP1    PXA_IRQ(50)    /* EXT_WAKEUP1 */


static int wakeup0_init(void)
{
    PECR |= PECR_E0IE;    //enable wakeup0 interrupt
    PECR &= ~PECR_DIR0;    //as input
    return 0;
}

static int disable_wakeup0_int(void)
{
    PECR &= ~PECR_E0IE;    //disable wakeup0 interrupt
    return 0;
}

static int wakeup0_ack_irq(void)
{
    PECR |= PECR_E0IS;    //interrupt state, write 1 to clear
    return 0;
}

static int XXX_init_irq(void)
{
    int err;

    err = request_irq(IRQ_WAKEUP0, &extwakeup0_handle,NULL,
                  "ext_wakeup0 detect", NULL);
    if (err) {
        pr_debug("XXX_init_irq(): can't request IRQ\n");
        return err;
    }

    return 0;
}

static int XXX_probe(struct platform_device *dev)
{
    int ret;   


    ret = misc_register(&XXX_miscdev);
    if(ret)
    {
        pr_debug("XXX_probe():initial can't register successfully!\n");
        return ret;
    }
   
    ret = wakeup0_init();
    ret = wakeup0_ack_irq();
    ret = powerbutton_init_irq();

    if(ret)
    {
        free_irq(IRQ_WAKEUP0, NULL);
        misc_deregister(&XXX_miscdev);
    }

    return 0;
}

static int XXX_remove(struct platform_device *dev)
{

    free_irq(IRQ_WAKEUP0, NULL);
    misc_deregister(&acr320_pmb_miscdev);
    return 0;
}



static irqreturn_t extwakeup0_handle(int irq, void *dev_id)
{
    int readreg;

    wakeup0_ack_irq();
    //if (!mutex_trylock(&ppwk->pmb_mutex))
    //    return -EBUSY;
   
    readreg = PECR;                //PWER

    ... ...

    wakeup0_ack_irq();
    //mutex_unlock(&ppwk->pmb_mutex);
    return IRQ_HANDLED;
}



阅读(729) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~