x86, UV: Fix RTC latency bug by reading replicated cachelines
[safe/jmp/linux-2.6] / drivers / input / keyboard / bf54x-keys.c
index e348cfc..fe376a2 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * Modified:
- *               Copyright 2007 Analog Devices Inc.
+ *               Copyright 2007-2008 Analog Devices Inc.
  *
  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
  *
@@ -81,6 +81,9 @@ struct bf54x_kpad {
        unsigned short *keycode;
        struct timer_list timer;
        unsigned int keyup_test_jiffies;
+       unsigned short kpad_msel;
+       unsigned short kpad_prescale;
+       unsigned short kpad_ctl;
 };
 
 static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad,
@@ -181,14 +184,13 @@ static int __devinit bfin_kpad_probe(struct platform_device *pdev)
        int i, error;
 
        if (!pdata->rows || !pdata->cols || !pdata->keymap) {
-               printk(KERN_ERR DRV_NAME
-                       ": No rows, cols or keymap from pdata\n");
+               dev_err(&pdev->dev, "no rows, cols or keymap from pdata\n");
                return -EINVAL;
        }
 
        if (!pdata->keymapsize ||
            pdata->keymapsize > (pdata->rows * pdata->cols)) {
-               printk(KERN_ERR DRV_NAME ": Invalid keymapsize\n");
+               dev_err(&pdev->dev, "invalid keymapsize\n");
                return -EINVAL;
        }
 
@@ -206,10 +208,10 @@ static int __devinit bfin_kpad_probe(struct platform_device *pdev)
                goto out;
        }
 
-       if (!pdata->debounce_time || !pdata->debounce_time > MAX_MULT ||
-           !pdata->coldrive_time || !pdata->coldrive_time > MAX_MULT) {
-               printk(KERN_ERR DRV_NAME
-                       ": Invalid Debounce/Columdrive Time from pdata\n");
+       if (!pdata->debounce_time || pdata->debounce_time > MAX_MULT ||
+           !pdata->coldrive_time || pdata->coldrive_time > MAX_MULT) {
+               dev_warn(&pdev->dev,
+                       "invalid platform debounce/columndrive time\n");
                bfin_write_KPAD_MSEL(0xFF0);    /* Default MSEL */
        } else {
                bfin_write_KPAD_MSEL(
@@ -228,16 +230,14 @@ static int __devinit bfin_kpad_probe(struct platform_device *pdev)
 
        if (peripheral_request_list((u16 *)&per_rows[MAX_RC - pdata->rows],
                                    DRV_NAME)) {
-               printk(KERN_ERR DRV_NAME
-                       ": Requesting Peripherals failed\n");
+               dev_err(&pdev->dev, "requesting peripherals failed\n");
                error = -EFAULT;
                goto out0;
        }
 
        if (peripheral_request_list((u16 *)&per_cols[MAX_RC - pdata->cols],
                                    DRV_NAME)) {
-               printk(KERN_ERR DRV_NAME
-                       ": Requesting Peripherals failed\n");
+               dev_err(&pdev->dev, "requesting peripherals failed\n");
                error = -EFAULT;
                goto out1;
        }
@@ -249,11 +249,10 @@ static int __devinit bfin_kpad_probe(struct platform_device *pdev)
        }
 
        error = request_irq(bf54x_kpad->irq, bfin_kpad_isr,
-                                IRQF_SAMPLE_RANDOM, DRV_NAME, pdev);
+                               0, DRV_NAME, pdev);
        if (error) {
-               printk(KERN_ERR DRV_NAME
-                       ": unable to claim irq %d; error %d\n",
-                       bf54x_kpad->irq, error);
+               dev_err(&pdev->dev, "unable to claim irq %d\n",
+                       bf54x_kpad->irq);
                goto out2;
        }
 
@@ -294,8 +293,7 @@ static int __devinit bfin_kpad_probe(struct platform_device *pdev)
 
        error = input_register_device(input);
        if (error) {
-               printk(KERN_ERR DRV_NAME
-                       ": Unable to register input device (%d)\n", error);
+               dev_err(&pdev->dev, "unable to register input device\n");
                goto out4;
        }
 
@@ -313,9 +311,6 @@ static int __devinit bfin_kpad_probe(struct platform_device *pdev)
 
        device_init_wakeup(&pdev->dev, 1);
 
-       printk(KERN_ERR DRV_NAME
-               ": Blackfin BF54x Keypad registered IRQ %d\n", bf54x_kpad->irq);
-
        return 0;
 
 out4:
@@ -360,6 +355,10 @@ static int bfin_kpad_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);
 
+       bf54x_kpad->kpad_msel = bfin_read_KPAD_MSEL();
+       bf54x_kpad->kpad_prescale = bfin_read_KPAD_PRESCALE();
+       bf54x_kpad->kpad_ctl = bfin_read_KPAD_CTL();
+
        if (device_may_wakeup(&pdev->dev))
                enable_irq_wake(bf54x_kpad->irq);
 
@@ -370,6 +369,10 @@ static int bfin_kpad_resume(struct platform_device *pdev)
 {
        struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);
 
+       bfin_write_KPAD_MSEL(bf54x_kpad->kpad_msel);
+       bfin_write_KPAD_PRESCALE(bf54x_kpad->kpad_prescale);
+       bfin_write_KPAD_CTL(bf54x_kpad->kpad_ctl);
+
        if (device_may_wakeup(&pdev->dev))
                disable_irq_wake(bf54x_kpad->irq);