cwz update tps65910 irq
authorubuntu <superboy@ubuntu.(none)>
Fri, 4 Mar 2011 03:09:16 +0000 (19:09 -0800)
committerubuntu <superboy@ubuntu.(none)>
Fri, 4 Mar 2011 03:09:16 +0000 (19:09 -0800)
arch/arm/mach-rk29/board-rk29-fih.c
drivers/mfd/tps65910-core.c
drivers/rtc/rtc-tps65910.c
include/linux/i2c/tps65910.h

index 1c37ba677bd02d3e0387c43c84028e3564c1dff1..72c365ccb76297e6199a76fb48d74654a9dd10ee 100755 (executable)
@@ -1856,6 +1856,9 @@ static void __init rk29_board_iomux_init(void)
        #ifdef CONFIG_RK29_PWM_REGULATOR
        rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
        #endif
+       #if defined (CONFIG_TPS65910_CORE)
+    rk29_mux_api_set(GPIO4D32_CPUTRACEDATA32_NAME, GPIO4H_GPIO4D32);
+       #endif
 }
 
 static struct platform_device *devices[] __initdata = {
index 16163426a879fbb99fa554dccef479aa3e549396..55e16e4c95ec535b7ba9d88e7a13f4fcd28f3858 100644 (file)
@@ -68,7 +68,7 @@
 #define TPS65910_SMARTREFLEX           1
 
 
-struct tps65910_platform_data *the_tps65910;
+struct tps65910_platform_data *gtps65910_platform = NULL;
 
 enum tps65910x_model {
        TPS65910,       /* TI processors OMAP3 family */
@@ -251,7 +251,7 @@ int tps65910_add_irq_work(int irq,
                void (*handler)(void *data))
 {
        int ret = 0;
-       the_tps65910->handlers[irq] = handler;
+       gtps65910_platform->handlers[irq] = handler;
        ret = tps65910_enable_irq(irq);
 
        return ret;
@@ -262,7 +262,7 @@ int tps65910_remove_irq_work(int irq)
 {
        int ret = 0;
        ret = tps65910_disable_irq(irq);
-       the_tps65910->handlers[irq] = NULL;
+       gtps65910_platform->handlers[irq] = NULL;
        return ret;
 }
 EXPORT_SYMBOL(tps65910_remove_irq_work);
@@ -278,6 +278,7 @@ static void tps65910_core_work(struct work_struct *work)
        u16 irq = 0;
        void    (*handler)(void *data) = NULL;
 
+       DBG("Enter::%s %d\n",__FUNCTION__,__LINE__);
        mutex_lock(&work_lock);
        while (1) {
                tps65910_i2c_read_u8(TPS65910_I2C_ID0, &status2,
@@ -298,12 +299,12 @@ static void tps65910_core_work(struct work_struct *work)
                while (isr) {
                        irq = fls(isr) - 1;
                        isr &= ~(1 << irq);
-                       handler = the_tps65910->handlers[irq];
+                       handler = gtps65910_platform->handlers[irq];
                        if (handler)
-                               handler(the_tps65910);
+                               handler(gtps65910_platform);
                }
        }
-       enable_irq(the_tps65910->irq_num);
+       enable_irq(gtps65910_platform->irq_num);
        mutex_unlock(&work_lock);
 }
 
@@ -499,7 +500,7 @@ tps65910_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
        struct tps65910_platform_data   *pdata;
  
        pdata = client->dev.platform_data;
-       the_tps65910 = pdata;
+       gtps65910_platform = pdata;
 
        DBG("cwz: tps65910_i2c_probe\n");
        
@@ -544,7 +545,6 @@ tps65910_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
        if (pdata->board_tps65910_config != NULL)
                pdata->board_tps65910_config(pdata);
 
-#if 0  //      cwz close, the tps65910_core_work may have some error.
        if (pdata->irq_num) {
                /* TPS65910 power ON interrupt(s) would have already been
                 * occurred, so immediately after request_irq the control will
@@ -554,17 +554,27 @@ tps65910_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
                 * initialization before requesting IRQ
                 */
                mutex_init(&work_lock);
-               INIT_WORK(&core_work, tps65910_core_work);
+
+               if(gpio_request(client->irq, "tps65910 irq"))
+               {
+                       dev_err(&client->dev, "gpio request fail\n");
+                       gpio_free(client->irq);
+                       goto fail;
+               }
+               
+               pdata->irq_num = gpio_to_irq(client->irq);
+               gpio_pull_updown(client->irq,GPIOPullUp);
 
                status = request_irq(pdata->irq_num, tps65910_isr,
-                                       IRQF_DISABLED, "tps65910", pdata);
+                                       IRQF_TRIGGER_FALLING, client->dev.driver->name, pdata);
                if (status < 0) {
                        pr_err("tps65910: could not claim irq%d: %d\n",
                                        pdata->irq_num, status);
                        goto fail;
                }
+               enable_irq_wake(pdata->irq_num);
+               INIT_WORK(&core_work, tps65910_core_work);
        }
-#endif
 
        status = add_children(pdata, 0x00);
        if (status < 0)
@@ -652,9 +662,13 @@ module_exit(tps65910_exit);
 static int proc_tps65910_show(struct seq_file *s, void *v)
 {
     u8 val = 0;
-    struct regulator *vldo;
        
        seq_printf(s, "\n\nTPS65910 Registers is:\n");
+
+       tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_REF);
+       seq_printf(s, "REF_REG=0x%x, Value=0x%x\n", TPS65910_REG_REF, val);
+       tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VRTC);
+       seq_printf(s, "VRTC_REG=0x%x, Value=0x%x\n", TPS65910_REG_VRTC, val);
        
        tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD1);
        seq_printf(s, "VDD1_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDD1, val);
@@ -692,6 +706,9 @@ static int proc_tps65910_show(struct seq_file *s, void *v)
        seq_printf(s, "DEVCTRL2_REG=0x%x, Value=0x%x\n", TPS65910_REG_DEVCTRL2, val);
 
 #if 0  //      cwz 1 test vcore
+{
+    struct regulator *vldo;
+       
        vldo = regulator_get(NULL, "vcore");
        if (vldo != NULL)
        {
@@ -703,6 +720,7 @@ static int proc_tps65910_show(struct seq_file *s, void *v)
                uV = regulator_get_voltage(vldo);
                seq_printf(s, "Get VCORE=%d(uV).\n", uV);
        }
+}
 #endif 
        return 0;
 }
index 4aacea9cc549ddee2e3733ddaf501e530c804b9d..8f10a636c2aea7caf8dab391083e5e189d93f8cd 100644 (file)
@@ -448,13 +448,14 @@ struct work_struct rtc_wq;
 unsigned long rtc_events;
 struct rtc_device *global_rtc;
 
-void  rtc_work(void  *data)
+void tps65910_rtc_work(void  *data)
 {
-
        int res;
        u8 rd_reg;
        unsigned long events = 0;
 
+       DBG("Enter::%s %d\n",__FUNCTION__,__LINE__);
+
        res = tps65910_rtc_read_u8(&rd_reg, TPS65910_REG_INT_STS);
 
        if (res < 0)
@@ -511,9 +512,9 @@ static struct rtc_class_ops tps65910_rtc_ops = {
 static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
 {
        struct rtc_device *rtc;
-       int ret = 0;
+       int ret = 0, stop_run = 0;
        u8 rd_reg;
-       struct rtc_time tm_def = {      //      2011.1.1 12:00 Saturday
+       struct rtc_time tm_def = {      //      2011.1.1 12:00:00 Saturday
                .tm_wday = 6,
                .tm_year = 111,
                .tm_mon = 0,
@@ -536,7 +537,6 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
        printk(KERN_INFO "TPS65910 RTC device successfully registered\n");
 
        platform_set_drvdata(pdev, rtc);
-
        /* Take rtc out of reset */
        tps65910_rtc_read_u8(&rd_reg, TPS65910_REG_DEVCTRL);
        rd_reg &= ~BIT_RTC_PWDN;
@@ -545,8 +545,7 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
        /* Dummy read to ensure that the register gets updated.
         * Please refer tps65910 TRM table:25 for details
         */
-       tps65910_rtc_read_u8(&rd_reg, TPS65910_REG_RTC_STATUS);
-
+       stop_run = 0;
        ret = tps65910_rtc_read_u8(&rd_reg, TPS65910_REG_RTC_STATUS);
        if (ret < 0) {
                printk(KERN_ERR "TPS65910 RTC STATUS REG READ FAILED\n");
@@ -556,12 +555,13 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
        if (rd_reg & BIT_RTC_STATUS_REG_POWER_UP_M) {
                dev_warn(&pdev->dev, "Power up reset detected.\n");
                //      cwz:if rtc power up reset, set default time.
-#if 1
                printk(KERN_INFO "TPS65910 RTC set to default time\n");
                tps65910_rtc_set_time(rtc, &tm_def);
-#endif
        }
-       
+       if (!(rd_reg & BIT_RTC_STATUS_REG_RUN_M)) {
+               dev_warn(&pdev->dev, "RTC stop run.\n");
+               stop_run = 1;
+       }
        if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M)
                dev_warn(&pdev->dev, "Pending Alarm interrupt detected.\n");
 
@@ -569,6 +569,7 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
        ret = tps65910_rtc_write_u8(rd_reg, TPS65910_REG_RTC_STATUS);
        if (ret < 0)
                goto out1;
+       
        ret = tps65910_rtc_read_u8(&rd_reg, TPS65910_REG_INT_STS);
        if (ret < 0) {
                printk(KERN_ERR "TPS65910 RTC STATUS REG READ FAILED\n");
@@ -583,21 +584,19 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
        global_rtc = rtc;
 
        /* Link RTC IRQ handler to TPS65910 Core */
-       tps65910_add_irq_work(TPS65910_RTC_ALARM_IRQ, rtc_work);
-       tps65910_add_irq_work(TPS65910_RTC_PERIOD_IRQ, rtc_work);
+       tps65910_add_irq_work(TPS65910_RTC_ALARM_IRQ, tps65910_rtc_work);
+       tps65910_add_irq_work(TPS65910_RTC_PERIOD_IRQ, tps65910_rtc_work);
 
        /* Check RTC module status, Enable if it is off */
-       ret = tps65910_rtc_read_u8(&rd_reg, TPS65910_REG_RTC_CTRL);
-       if (ret < 0)
-               goto out1;
-
-       if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) {          
+       if (stop_run) {
                dev_info(&pdev->dev, "Enabling TPS65910-RTC.\n");
                //      cwz:if rtc stop, set default time, then enable rtc
-#if 1
                printk(KERN_INFO "TPS65910 RTC set to default time\n");
                tps65910_rtc_set_time(rtc, &tm_def);
-#endif
+               ret = tps65910_rtc_read_u8(&rd_reg, TPS65910_REG_RTC_CTRL);
+               if (ret < 0)
+                       goto out1;
+
                rd_reg |= BIT_RTC_CTRL_REG_STOP_RTC_M;
                ret = tps65910_rtc_write_u8(rd_reg, TPS65910_REG_RTC_CTRL);
                if (ret < 0)
index d6deb368c3373eb8de8e87447dd3b96a8edbb8d6..3127470976372f5abcc100f0994b6071f5c9763d 100644 (file)
@@ -36,7 +36,7 @@
 #define        TPS65910_I2C_ID1        0x12 /* Smart Reflex */
 
 /* TPS65910 to host IRQ */
-#define TPS65910_HOST_IRQ      RK29_PIN6_PD3
+#define TPS65910_HOST_IRQ      RK29_PIN4_PD3
 
 /* TPS65910 MAX GPIOs */
 #define TPS65910_GPIO_MAX      1