]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/touchscreen/ads7846.c
Merge branch 'for-linus' of git://git.o-hand.com/linux-mfd
[linux-2.6-omap-h63xx.git] / drivers / input / touchscreen / ads7846.c
index a571aa965da0dadc026acaa7f8a323c502631b44..ce6f48c695f553a703a9c9af3c739996bc2c971c 100644 (file)
 #include <linux/spi/ads7846.h>
 #include <asm/irq.h>
 
-#ifdef CONFIG_ARM
-#include <asm/mach-types.h>
-#ifdef CONFIG_ARCH_OMAP
-#include <asm/arch/gpio.h>
-#endif
-#endif
-
 
 /*
  * This code has been heavily tested on a Nokia 770, and lightly
@@ -524,7 +517,9 @@ static void ads7846_rx(void *ads)
        if (x == MAX_12BIT)
                x = 0;
 
-       if (likely(x && z1)) {
+       if (ts->model == 7843) {
+               Rt = ts->pressure_max / 2;
+       } else if (likely(x && z1)) {
                /* compute touch pressure resistance using equation #2 */
                Rt = z2;
                Rt -= z1;
@@ -532,11 +527,9 @@ static void ads7846_rx(void *ads)
                Rt *= ts->x_plate_ohms;
                Rt /= z1;
                Rt = (Rt + 2047) >> 12;
-       } else
+       } else {
                Rt = 0;
-
-       if (ts->model == 7843)
-               Rt = ts->pressure_max / 2;
+       }
 
        /* Sample found inconsistent by debouncing or pressure is beyond
         * the maximum. Don't report it to user space, repeat at least
@@ -640,19 +633,17 @@ static void ads7846_rx_val(void *ads)
        struct ads7846 *ts = ads;
        struct spi_message *m;
        struct spi_transfer *t;
-       u16 *rx_val;
        int val;
        int action;
        int status;
 
        m = &ts->msg[ts->msg_idx];
        t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
-       rx_val = t->rx_buf;
 
        /* adjust:  on-wire is a must-ignore bit, a BE12 value, then padding;
         * built from two 8 bit values written msb-first.
         */
-       val = be16_to_cpu(*rx_val) >> 3;
+       val = be16_to_cpup((__be16 *)t->rx_buf) >> 3;
 
        action = ts->filter(ts->filter_data, ts->msg_idx, &val);
        switch (action) {
@@ -666,7 +657,7 @@ static void ads7846_rx_val(void *ads)
                m = ts->last_msg;
                break;
        case ADS7846_FILTER_OK:
-               *rx_val = val;
+               *(u16 *)t->rx_buf = val;
                ts->tc.ignore = 0;
                m = &ts->msg[++ts->msg_idx];
                break;
@@ -1172,31 +1163,6 @@ static struct spi_driver ads7846_driver = {
 
 static int __init ads7846_init(void)
 {
-       /* grr, board-specific init should stay out of drivers!! */
-
-#ifdef CONFIG_ARCH_OMAP
-       if (machine_is_omap_osk()) {
-               /* GPIO4 = PENIRQ; GPIO6 = BUSY */
-               omap_request_gpio(4);
-               omap_set_gpio_direction(4, 1);
-               omap_request_gpio(6);
-               omap_set_gpio_direction(6, 1);
-       }
-       // also TI 1510 Innovator, bitbanging through FPGA
-       // also Nokia 770
-       // also Palm Tungsten T2
-#endif
-
-       // PXA:
-       // also Dell Axim X50
-       // also HP iPaq H191x/H192x/H415x/H435x
-       // also Intel Lubbock (additional to UCB1400; as temperature sensor)
-       // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
-
-       // Atmel at91sam9261-EK uses ads7843
-
-       // also various AMD Au1x00 devel boards
-
        return spi_register_driver(&ads7846_driver);
 }
 module_init(ads7846_init);
@@ -1204,14 +1170,6 @@ module_init(ads7846_init);
 static void __exit ads7846_exit(void)
 {
        spi_unregister_driver(&ads7846_driver);
-
-#ifdef CONFIG_ARCH_OMAP
-       if (machine_is_omap_osk()) {
-               omap_free_gpio(4);
-               omap_free_gpio(6);
-       }
-#endif
-
 }
 module_exit(ads7846_exit);